Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Programmatic send copy command (CTRL+C)

Programmatic send copy command (CTRL+C)

Scheduled Pinned Locked Moved C / C++ / MFC
c++htmlcomquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yytg
    wrote on last edited by
    #1

    I found this link http://vb-helper.com/howto_copy_all_browser_text.html I tried to imitate the function DoEvents as so void DoEvents(int milisec=5) { MSG msg; DWORD dwStart=GetTickCount(); while (true) { if(GetTickCount()-dwStart>milisec)return; if(!PreTranslateMessage(&msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } But when I call the functions - it's not working... How do I do it in C++ Thanks in advance

    L D C N 4 Replies Last reply
    0
    • Y yytg

      I found this link http://vb-helper.com/howto_copy_all_browser_text.html I tried to imitate the function DoEvents as so void DoEvents(int milisec=5) { MSG msg; DWORD dwStart=GetTickCount(); while (true) { if(GetTickCount()-dwStart>milisec)return; if(!PreTranslateMessage(&msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } But when I call the functions - it's not working... How do I do it in C++ Thanks in advance

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      The good news is you posted this in the correct forum. The bad news is you don't have the first idea what you are doing. Good luck, you're going to need it.

      led mike

      1 Reply Last reply
      0
      • Y yytg

        I found this link http://vb-helper.com/howto_copy_all_browser_text.html I tried to imitate the function DoEvents as so void DoEvents(int milisec=5) { MSG msg; DWORD dwStart=GetTickCount(); while (true) { if(GetTickCount()-dwStart>milisec)return; if(!PreTranslateMessage(&msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } But when I call the functions - it's not working... How do I do it in C++ Thanks in advance

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        What in the world does this code snippet have to with this thread's subject? :rolleyes:

        "Love people and use things, not love things and use people." - Unknown

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        1 Reply Last reply
        0
        • Y yytg

          I found this link http://vb-helper.com/howto_copy_all_browser_text.html I tried to imitate the function DoEvents as so void DoEvents(int milisec=5) { MSG msg; DWORD dwStart=GetTickCount(); while (true) { if(GetTickCount()-dwStart>milisec)return; if(!PreTranslateMessage(&msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } But when I call the functions - it's not working... How do I do it in C++ Thanks in advance

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          yytg wrote:

          I tried to imitate the function DoEvents

          :laugh:

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          1 Reply Last reply
          0
          • Y yytg

            I found this link http://vb-helper.com/howto_copy_all_browser_text.html I tried to imitate the function DoEvents as so void DoEvents(int milisec=5) { MSG msg; DWORD dwStart=GetTickCount(); while (true) { if(GetTickCount()-dwStart>milisec)return; if(!PreTranslateMessage(&msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } } But when I call the functions - it's not working... How do I do it in C++ Thanks in advance

            N Offline
            N Offline
            Nathan Holt at EMOM
            wrote on last edited by
            #5

            yytg wrote:

            I tried to imitate the function DoEvents as so

            yytg wrote:

            But when I call the functions - it's not working... How do I do it in C++

            I've had a need to implement DoEvents in C++ myself, and wrote something that works. Here is what I came up with.

            namespace
            {
                void DoEventsPumpMessage()
                {
                    CWinThread *pThread = AfxGetThread();
                    if( !pThread->PumpMessage() )
                    {
                        int nResult = (int)AfxGetCurrentMessage()->wParam;  // value from PostQuitMessage
                        ::PostQuitMessage(nResult);        // so the main message loop will get it.
                        TRACE("DoEvents Received quit message\n");
                        CQuitMessageException::Throw();
                    }
                }
            }
            
            void DoEvents( bool bAtLeastOne )
            {
                if( bAtLeastOne )
                {
                    DoEventsPumpMessage();
                }
            
                MSG message;
                while( ::PeekMessage( &message, NULL, 0, 0, PM_NOREMOVE ) )
                {
                    DoEventsPumpMessage();
                }
            }
            

            Many message loops I've seen just assume there won't be a quit message, but in my case, I really wanted to avoid runaway background threads. Nathan

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups