Interacting with a 3rd party application dialog window
-
Hello, I am trying to interact dynamically with a 3rd party application dialog. This dialog has the usual OK and CANCEL buttons and an edit box. I want to be able to set the text in this edit box. I have managed to enumerate the handle of the dialog, but can't see how to find the ID of the edit box in order to get it's handle and thereby set the text. Perhaps someone can point me in the right direction !! Doug
-
Hello, I am trying to interact dynamically with a 3rd party application dialog. This dialog has the usual OK and CANCEL buttons and an edit box. I want to be able to set the text in this edit box. I have managed to enumerate the handle of the dialog, but can't see how to find the ID of the edit box in order to get it's handle and thereby set the text. Perhaps someone can point me in the right direction !! Doug
You can use the call GetWindow, and use the GW_CHILD flag to start out with. Then test for the type of class of that window with a call to GetClassName. You are looking for the "EDIT" class. When you find a window whose class matches that criteria, you will have the handle to the Edit control. After testing each handle, if you have not found the correct window, then call for the next child window of the dialog, using the child window handle from the previous call to GetWindow, and this time use the GW_HWNDNEXT flag. Ex. HINSTANCE hInst; HWND hDlg; TCHAR className[_MAX_PATH]; ... HWND hChildWnd = ::GetWindow(hDlg, GW_CHILD); while (hChildWnd != NULL) { WNDCLASS wndClass; ::GetClassInfo(hChildWnd, className, sizeof(className)); if (0 == ::_tcscmp(className, _T("EDIT")) { // This is the window handle that you want. // Record the window handle here or do your special processing. ... break; } hChildWnd = ::GetWindow(hChildWnd, GW_HWNDNEXT); } If there are more than one edit controls on the dialog things get a bit trickier. You should look at the tool Spy++ that came with Visual Studio, it will allow you to peek at all of the important data regarding the windows, its class type, id etc.
-
You can use the call GetWindow, and use the GW_CHILD flag to start out with. Then test for the type of class of that window with a call to GetClassName. You are looking for the "EDIT" class. When you find a window whose class matches that criteria, you will have the handle to the Edit control. After testing each handle, if you have not found the correct window, then call for the next child window of the dialog, using the child window handle from the previous call to GetWindow, and this time use the GW_HWNDNEXT flag. Ex. HINSTANCE hInst; HWND hDlg; TCHAR className[_MAX_PATH]; ... HWND hChildWnd = ::GetWindow(hDlg, GW_CHILD); while (hChildWnd != NULL) { WNDCLASS wndClass; ::GetClassInfo(hChildWnd, className, sizeof(className)); if (0 == ::_tcscmp(className, _T("EDIT")) { // This is the window handle that you want. // Record the window handle here or do your special processing. ... break; } hChildWnd = ::GetWindow(hChildWnd, GW_HWNDNEXT); } If there are more than one edit controls on the dialog things get a bit trickier. You should look at the tool Spy++ that came with Visual Studio, it will allow you to peek at all of the important data regarding the windows, its class type, id etc.
Hi Paul, What a brilliantly comprehensive answer ! Very many thanks ! :-D :-D :-D :thumbsup: Doug