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. How to find Child window?

How to find Child window?

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

    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 using FindWindow() but it couldn't recognize the child window... is there any way? thanks in advance

    L T R 3 Replies Last reply
    0
    • D Dody_DK

      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 using FindWindow() but it couldn't recognize the child window... is there any way? thanks in advance

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      EnumChildWindows()? Artificial intelligence is no match for natural stupidity.

      N 1 Reply Last reply
      0
      • L Lost User

        EnumChildWindows()? Artificial intelligence is no match for natural stupidity.

        N Offline
        N Offline
        Neville Franks
        wrote on last edited by
        #3

        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"

        1 Reply Last reply
        0
        • D Dody_DK

          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 using FindWindow() but it couldn't recognize the child window... is there any way? thanks in advance

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          After Using the FindWindow() ,For enumerating Child Window use FindWindowEx(). 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
          1 Reply Last reply
          0
          • D Dody_DK

            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 using FindWindow() but it couldn't recognize the child window... is there any way? thanks in advance

            R Offline
            R Offline
            rwestgraham
            wrote on last edited by
            #5

            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

            D 1 Reply Last reply
            0
            • R rwestgraham

              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

              D Offline
              D Offline
              Dody_DK
              wrote on last edited by
              #6

              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

              R 1 Reply Last reply
              0
              • D Dody_DK

                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

                R Offline
                R Offline
                rwestgraham
                wrote on last edited by
                #7

                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

                D 1 Reply Last reply
                0
                • R rwestgraham

                  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

                  D Offline
                  D Offline
                  Dody_DK
                  wrote on last edited by
                  #8

                  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 use SendMessage() to close it, nothing happen! HWND optionwindow =::FindWindow(NULL, "option"); or HWND optionwindow =::FindWindow("#32770", NULL); or even HWND optionwindow =::FindWindow("#32770", "option"); and ::SendMessage(optionwindow, WM_CLOSE, 0, 0); but not working! any help thanks?

                  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