How to find Child window?
-
Hey all My question is how to find a child window! well, I know that I can use
FindWindow("hwndclass", NULL);
but how to find a child window of a program? I tried usingFindWindow()
but it couldn't recognize the child window... is there any way? thanks in advance -
Hey all My question is how to find a child window! well, I know that I can use
FindWindow("hwndclass", NULL);
but how to find a child window of a program? I tried usingFindWindow()
but it couldn't recognize the child window... is there any way? thanks in advance -
and GetWindow( GW_CHILD ), IsChild() etc. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
Hey all My question is how to find a child window! well, I know that I can use
FindWindow("hwndclass", NULL);
but how to find a child window of a program? I tried usingFindWindow()
but it couldn't recognize the child window... is there any way? thanks in advanceAfter Using the
FindWindow()
,For enumerating Child Window useFindWindowEx()
. if you need,I will Provide you code for Enumerting the Desktop Windows.
"I Think this Will Help"
visit me at http://www.thisisalok.tk
-
Hey all My question is how to find a child window! well, I know that I can use
FindWindow("hwndclass", NULL);
but how to find a child window of a program? I tried usingFindWindow()
but it couldn't recognize the child window... is there any way? thanks in advanceFindWindowEx allows you to specify a parent handle, and will search only for children of that parent window. So you find the parent window, then call FindWindowEx using the parent window handle as the starting search point. There is one VERY important caveat: FindWindowEx will ONLY find FIRST generation children. Suppose for example, your top level window is a dialog box. The Dialog has a frame control. The window you want to find is a child of the frame. Calling FindWindowEx using the parent will find the frame. But it will not find your desired window, because it only searches direct children. So your strategy in this case would be: 1) Get dialog handle. 2) Use dialog handle as parent and find handle to the frame. 3) Then use the frame handle, NOT the dialog handle, as the new parent and continue the search. This will now find your target because it is a direct child of the frame, not the dialog. Because windows hierarchies can be complex, you need to use a tool like Spy which can show the relationships of a window. Then base you search strategy based on how Spy shows you the windows are related. Hope this helps, Robert
-
FindWindowEx allows you to specify a parent handle, and will search only for children of that parent window. So you find the parent window, then call FindWindowEx using the parent window handle as the starting search point. There is one VERY important caveat: FindWindowEx will ONLY find FIRST generation children. Suppose for example, your top level window is a dialog box. The Dialog has a frame control. The window you want to find is a child of the frame. Calling FindWindowEx using the parent will find the frame. But it will not find your desired window, because it only searches direct children. So your strategy in this case would be: 1) Get dialog handle. 2) Use dialog handle as parent and find handle to the frame. 3) Then use the frame handle, NOT the dialog handle, as the new parent and continue the search. This will now find your target because it is a direct child of the frame, not the dialog. Because windows hierarchies can be complex, you need to use a tool like Spy which can show the relationships of a window. Then base you search strategy based on how Spy shows you the windows are related. Hope this helps, Robert
Thanks alot for your replaies.... but does this also work with a popup window? I mean, many programs have option window... let's take Yahoo for example, if I click on option from the menu then a popup window will come and disable the main yahoo list, so can I also use FindWindowEx to find this popup window? thanks alot
-
Thanks alot for your replaies.... but does this also work with a popup window? I mean, many programs have option window... let's take Yahoo for example, if I click on option from the menu then a popup window will come and disable the main yahoo list, so can I also use FindWindowEx to find this popup window? thanks alot
Well, usually the use of FindWindowEx implies that you are finding and possibly manipulating windows in a program external to your own program, because you should already inherently know how to find all windows your own program creates. So, assuming you are doing what I think you are doing, the answer is yes, because the popup is modal to the browser window that spawned it, but it is not modal to your own program. So yes, you can still execute code and should be able to find it. Again, use Spy to help you design the strategy to find the popup. I have a program that creates a browser window and then navigates to a site page that displays a popup modal dialog. I have no problems finding the login dialog, and entering the login automatically. So I think the answer to your question is yes, unless you are doing something really weird. :-) Robert
-
Well, usually the use of FindWindowEx implies that you are finding and possibly manipulating windows in a program external to your own program, because you should already inherently know how to find all windows your own program creates. So, assuming you are doing what I think you are doing, the answer is yes, because the popup is modal to the browser window that spawned it, but it is not modal to your own program. So yes, you can still execute code and should be able to find it. Again, use Spy to help you design the strategy to find the popup. I have a program that creates a browser window and then navigates to a site page that displays a popup modal dialog. I have no problems finding the login dialog, and entering the login automatically. So I think the answer to your question is yes, unless you are doing something really weird. :-) Robert
well... when I try using spy++ then I found that the class of the windows is #32770 (Dialog) and the window caption is option, and when I use
FindWindow()
and useSendMessage()
to close it, nothing happen!HWND optionwindow =::FindWindow(NULL, "option");
orHWND optionwindow =::FindWindow("#32770", NULL);
or evenHWND optionwindow =::FindWindow("#32770", "option");
and::SendMessage(optionwindow, WM_CLOSE, 0, 0);
but not working! any help thanks?