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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Posting Message to another Application Window

Posting Message to another Application Window

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
6 Posts 4 Posters 1 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.
  • S Offline
    S Offline
    Sethuraman K
    wrote on last edited by
    #1

    Hi All, I want to press a button in another application. I got that window handle using FindWindow(). I don't know how to post a message for press a button in that application. If u know please help me. Thanks Sethuraman.k

    Sethuraman.K

    H O N 3 Replies Last reply
    0
    • S Sethuraman K

      Hi All, I want to press a button in another application. I got that window handle using FindWindow(). I don't know how to post a message for press a button in that application. If u know please help me. Thanks Sethuraman.k

      Sethuraman.K

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      See shortes code for notepad if helpfuls

      CWnd *pwnd=FindWindowW(_T("NotePad"),NULL);
      HMENU h=::GetMenu(pwnd->m_hWnd);
      HMENU h2=GetSubMenu(h,0);
      ::SendMessage(pwnd->m_hWnd,WM_COMMAND,(WPARAM)3,(LPARAM)h2);

      S 1 Reply Last reply
      0
      • H Hamid Taebi

        See shortes code for notepad if helpfuls

        CWnd *pwnd=FindWindowW(_T("NotePad"),NULL);
        HMENU h=::GetMenu(pwnd->m_hWnd);
        HMENU h2=GetSubMenu(h,0);
        ::SendMessage(pwnd->m_hWnd,WM_COMMAND,(WPARAM)3,(LPARAM)h2);

        S Offline
        S Offline
        Sethuraman K
        wrote on last edited by
        #3

        Thanks for ur reply. My reqest is not selecting a submenu. I want press a button control in another apllication Dialog

        Sethuraman.K

        H 1 Reply Last reply
        0
        • S Sethuraman K

          Hi All, I want to press a button in another application. I got that window handle using FindWindow(). I don't know how to post a message for press a button in that application. If u know please help me. Thanks Sethuraman.k

          Sethuraman.K

          O Offline
          O Offline
          only coder
          wrote on last edited by
          #4

          you must get the control id first. to get control id, you can use FindWindow and GetDlgCtrlID()... then: HWND hWnd = FindWindow(....); ::SendMessage( hWnd, WM_COMMAND, nButtonID, 0 );

          1 Reply Last reply
          0
          • S Sethuraman K

            Thanks for ur reply. My reqest is not selecting a submenu. I want press a button control in another apllication Dialog

            Sethuraman.K

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            Yeah I understood it was for example. if you have handle to that program you can use of this code for get handle to other controls on that forum and then send your message to a control.

            for(CWnd* pWnd = needsto handle; pWnd;pWnd = pWnd ->GetNextWindow())
            {
            pWnd ->GetWindowTextW(str);
            }

            1 Reply Last reply
            0
            • S Sethuraman K

              Hi All, I want to press a button in another application. I got that window handle using FindWindow(). I don't know how to post a message for press a button in that application. If u know please help me. Thanks Sethuraman.k

              Sethuraman.K

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #6

              Send WM_COMMAND message to the parent of the button, and set the WPARAM and LPARAM as follows wparam = MAKEWPARAM( , BN_CLICKED ); lParam = (LPARAM);

              nave [OpenedFileFinder]

              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