Get a pointer to a 3rd level child window

This is a discussion on Get a pointer to a 3rd level child window within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I am trying to get a pointer to a child window that is down 3 level from the main ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    205

    Get a pointer to a 3rd level child window

    Hi,
    I am trying to get a pointer to a child window that is down 3 level from the main window.
    The only thing I can start with is AfxGetApp()->m_pMainWnd. This gets me a Cwnd * to the main window. From there on, I have to find a way to get to a certain child window. Can anybody let me know if they are aware of a way to do such a thing. I am using MFC dialogs. Thanks
    Amish

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You can get the third generation child window (assuming that by down 3 level you're referring to a child window) handle (HWND) with EnumChildWindows and then possibly use it to return a CWnd* with CWnd::FromHandle.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    Quote Originally Posted by Ken Fitlike
    You can get the third generation child window (assuming that by down 3 level you're referring to a child window) handle (HWND) with EnumChildWindows and then possibly use it to return a CWnd* with CWnd::FromHandle.
    Neat function. Do you know if there is an order in which it goes through the windows and if there is a way that I could pinpoint one child window in particular. Thanks
    Amish

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Don't know if there's a particular order but you could always test it to find out. Pinpointing one child window in particular would require at least one other unique piece of information about that child. For example, if you know the id you could retrieve it with CWnd::GetDlgCtrlID (or ::GetDlgCtrlID) based on the child window handle sent to your EnumChildProc and look for a match.

    The questions and answers you're asking and receiving in this thread seem very similar to what you asked and the answers you got here. Given that similarity, I think you should try some of this out and see whether the information meets your needs.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    Quote Originally Posted by Ken Fitlike
    Don't know if there's a particular order but you could always test it to find out. Pinpointing one child window in particular would require at least one other unique piece of information about that child. For example, if you know the id you could retrieve it with CWnd::GetDlgCtrlID (or ::GetDlgCtrlID) based on the child window handle sent to your EnumChildProc and look for a match.

    The questions and answers you're asking and receiving in this thread seem very similar to what you asked and the answers you got here. Given that similarity, I think you should try some of this out and see whether the information meets your needs.
    Thanks for the answer. Yes the answers are similar. I'll try it out.
    Amish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a child window in a parent window
    By vopo in forum Windows Programming
    Replies: 8
    Last Post: 10-06-2007, 05:15 PM
  2. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 11:50 AM
  3. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Child window with active (highlighted) title bar: Possible?
    By JasonD in forum Windows Programming
    Replies: 7
    Last Post: 10-16-2003, 07:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21