GetFirstChild in win32?

I am using EnumChildWindows to get all child windows from the main HWND window, but I would only like to get the first child of a given HWND window.

BOOL CALLBACK EnumChildProc ( HWND hwndChild, LPARAM lParam)
{
  // logic to call only once 
}

      

Is it correct? or in any other simple way?

~ UK

+2


a source to share


3 answers


BOOL CALLBACK EnumChildProc ( HWND hwndChild, LPARAM lParam)
{
  // process first child window
  return FALSE;
}

      



As an alternative HWND top_child = GetWindow(thisWindow, GW_CHILD);

+3


a source


Sure:

BOOL CALLBACK EnumChildProc ( HWND hwndChild, LPARAM lParam)
{
    /* do what you want with the first HWND */

    return FALSE; // stops enumeration.
}

      



See MSDN for more details , but the relevant line is this:

Return value

Bool

To continue enumerating, the callback function must return TRUE ; stop enumeration, it should return FALSE .

+2


a source


GetWindow (..., GW_CHILD) will give you a window at the top of the z-order, which I assume is what you are after

+2


a source







All Articles