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. Getting child windows handle

Getting child windows handle

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 4 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.
  • P Offline
    P Offline
    PankajB
    wrote on last edited by
    #1

    Hi There. I have a Dialog based Application: Title "ABC Application" I want to launch this appiication and then want to set an edit box available on this window with some text. This is what I am doing right now.

    ShellExecute(NULL, L"open", L"C:\\Program Files\\ABC.exe", NULL, NULL, SW_SHOWNORMAL);

    HWND WndOST2PST = NULL;
    WndOST2PST = ::FindWindow(NULL,L"ABC Application");

    if(WndOST2PST == NULL)
    return false;

    //Need to get handle for child windows

    //SetWindowText(WndOST2PST, L"Pankaj");

    SendMessage(WndOST2PST, WM_DESTROY, 0, 0);

    I am not able to get handle of that specific edit control. Please provide some pointers for the same. Thanks PanB

    S S S 4 Replies Last reply
    0
    • P PankajB

      Hi There. I have a Dialog based Application: Title "ABC Application" I want to launch this appiication and then want to set an edit box available on this window with some text. This is what I am doing right now.

      ShellExecute(NULL, L"open", L"C:\\Program Files\\ABC.exe", NULL, NULL, SW_SHOWNORMAL);

      HWND WndOST2PST = NULL;
      WndOST2PST = ::FindWindow(NULL,L"ABC Application");

      if(WndOST2PST == NULL)
      return false;

      //Need to get handle for child windows

      //SetWindowText(WndOST2PST, L"Pankaj");

      SendMessage(WndOST2PST, WM_DESTROY, 0, 0);

      I am not able to get handle of that specific edit control. Please provide some pointers for the same. Thanks PanB

      S Offline
      S Offline
      Sophiya Chen
      wrote on last edited by
      #2

      hi,you'd better get the window handle from one variable. the dialog title may be not right in this course.

      1 Reply Last reply
      0
      • P PankajB

        Hi There. I have a Dialog based Application: Title "ABC Application" I want to launch this appiication and then want to set an edit box available on this window with some text. This is what I am doing right now.

        ShellExecute(NULL, L"open", L"C:\\Program Files\\ABC.exe", NULL, NULL, SW_SHOWNORMAL);

        HWND WndOST2PST = NULL;
        WndOST2PST = ::FindWindow(NULL,L"ABC Application");

        if(WndOST2PST == NULL)
        return false;

        //Need to get handle for child windows

        //SetWindowText(WndOST2PST, L"Pankaj");

        SendMessage(WndOST2PST, WM_DESTROY, 0, 0);

        I am not able to get handle of that specific edit control. Please provide some pointers for the same. Thanks PanB

        S Offline
        S Offline
        Sarath C
        wrote on last edited by
        #3

        you can do this by EnumChildWindows API. See the See the sample snippet[^]

        -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

        My blog - Sharing My Thoughts

        1 Reply Last reply
        0
        • P PankajB

          Hi There. I have a Dialog based Application: Title "ABC Application" I want to launch this appiication and then want to set an edit box available on this window with some text. This is what I am doing right now.

          ShellExecute(NULL, L"open", L"C:\\Program Files\\ABC.exe", NULL, NULL, SW_SHOWNORMAL);

          HWND WndOST2PST = NULL;
          WndOST2PST = ::FindWindow(NULL,L"ABC Application");

          if(WndOST2PST == NULL)
          return false;

          //Need to get handle for child windows

          //SetWindowText(WndOST2PST, L"Pankaj");

          SendMessage(WndOST2PST, WM_DESTROY, 0, 0);

          I am not able to get handle of that specific edit control. Please provide some pointers for the same. Thanks PanB

          S Offline
          S Offline
          sonu saini 76 gmail com
          wrote on last edited by
          #4

          Try this

          CString Text;
          CWnd *pWnd = FindWindow(NULL, "Title");
          CWnd *pChildWnd = pWnd->GetWindow(GW_CHILD);
          while(pChildWnd)
          {
          UINT uiID = pChildWnd->GetDlgCtrlID();
          pChildWnd->GetDlgItemText(uiID, Text);// To get caption
          pChildWnd->SetDlgItemText(uiID, "Test"); //To set value into edit box

             pWnd->SendMessage(WM\_COMMAND, MAKEWPARAM(uiID, BN\_CLICKED), (LPARAM)pChildWnd->m\_hWnd);// To click on the control
             pChildWnd = pChildWnd->GetWindow(GW\_HWNDNEXT);
          }
          
          1 Reply Last reply
          0
          • P PankajB

            Hi There. I have a Dialog based Application: Title "ABC Application" I want to launch this appiication and then want to set an edit box available on this window with some text. This is what I am doing right now.

            ShellExecute(NULL, L"open", L"C:\\Program Files\\ABC.exe", NULL, NULL, SW_SHOWNORMAL);

            HWND WndOST2PST = NULL;
            WndOST2PST = ::FindWindow(NULL,L"ABC Application");

            if(WndOST2PST == NULL)
            return false;

            //Need to get handle for child windows

            //SetWindowText(WndOST2PST, L"Pankaj");

            SendMessage(WndOST2PST, WM_DESTROY, 0, 0);

            I am not able to get handle of that specific edit control. Please provide some pointers for the same. Thanks PanB

            S Offline
            S Offline
            sonu saini 76 gmail com
            wrote on last edited by
            #5

            Use this to set data into text box

            SendMessage(_Edithwnd, WM_SETTEXT, 0, (LPARAM)strCaption);

            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