Getting child windows handle
-
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
-
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
hi,you'd better get the window handle from one variable. the dialog title may be not right in this course.
-
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
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
-
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
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 boxpWnd->SendMessage(WM\_COMMAND, MAKEWPARAM(uiID, BN\_CLICKED), (LPARAM)pChildWnd->m\_hWnd);// To click on the control pChildWnd = pChildWnd->GetWindow(GW\_HWNDNEXT); }
-
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
Use this to set data into text box
SendMessage(_Edithwnd, WM_SETTEXT, 0, (LPARAM)strCaption);