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. Accessing all child windows from the main window

Accessing all child windows from the main window

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebugginglearning
3 Posts 3 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.
  • M Offline
    M Offline
    Member 534357
    wrote on last edited by
    #1

    I have to get all the child windows from my main window. Once I have the hwnd How do I find out which window it is, I know I can call GetClassName on the hwnd but that's not good enough for me because most of my windows don't have names, I tried calling GetDlgCtrlID on the hwnd but it crashes because my hwnd is just enumerated. So what can I call to get either the resource ID of the window or some other information that will tell me which window it is. The following is the code I wrote to get the windows: if(!EnumChildWindows ( AfxGetMainWnd()->m_hWnd, EnumChildProc, NULL)) { TRACE("Unable to get child windows???\n"); return; } BOOL CALLBACK CMyDlg::EnumChildProc(HWND hwnd,LPARAM lParam) { TRACE ("Enumerated Child Window : %x\n", hwnd); } Is there some other function besides EnumChildWindows that can be used & will give me more useful data? Thanks in advance

    B S 2 Replies Last reply
    0
    • M Member 534357

      I have to get all the child windows from my main window. Once I have the hwnd How do I find out which window it is, I know I can call GetClassName on the hwnd but that's not good enough for me because most of my windows don't have names, I tried calling GetDlgCtrlID on the hwnd but it crashes because my hwnd is just enumerated. So what can I call to get either the resource ID of the window or some other information that will tell me which window it is. The following is the code I wrote to get the windows: if(!EnumChildWindows ( AfxGetMainWnd()->m_hWnd, EnumChildProc, NULL)) { TRACE("Unable to get child windows???\n"); return; } BOOL CALLBACK CMyDlg::EnumChildProc(HWND hwnd,LPARAM lParam) { TRACE ("Enumerated Child Window : %x\n", hwnd); } Is there some other function besides EnumChildWindows that can be used & will give me more useful data? Thanks in advance

      B Offline
      B Offline
      Brian Shifrin
      wrote on last edited by
      #2

      There are plenty of ways to accomplish this... You can iterate with GetWindowTop, GetNextWindow; To get class name: GetClassName If you are the one creating them make all windows support some protocol: make them all respond to some message like "WM_APP+100" with some value, or use existing message such as WM_GETTEXT. If not, install some hook via InitCommonControlSex.... Anyway... good luck

      1 Reply Last reply
      0
      • M Member 534357

        I have to get all the child windows from my main window. Once I have the hwnd How do I find out which window it is, I know I can call GetClassName on the hwnd but that's not good enough for me because most of my windows don't have names, I tried calling GetDlgCtrlID on the hwnd but it crashes because my hwnd is just enumerated. So what can I call to get either the resource ID of the window or some other information that will tell me which window it is. The following is the code I wrote to get the windows: if(!EnumChildWindows ( AfxGetMainWnd()->m_hWnd, EnumChildProc, NULL)) { TRACE("Unable to get child windows???\n"); return; } BOOL CALLBACK CMyDlg::EnumChildProc(HWND hwnd,LPARAM lParam) { TRACE ("Enumerated Child Window : %x\n", hwnd); } Is there some other function besides EnumChildWindows that can be used & will give me more useful data? Thanks in advance

        S Offline
        S Offline
        SiddharthAtw
        wrote on last edited by
        #3

        Hi Rgarf! I am also exploring same area in which U are dwelling. Hope we both us have something for each other. Just be in touch. The solution to Ur problem is Use FindWindow and FindWindowEx. What my problem is if there are two edit controls in the same window how to uniquely identify them. Please, reply me if U knw. U can mail me in to_siddharth@indiatimes.com. Cheers!!!!!! Siddharth

        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