win32中的GetFirstChild?

时间:2010-05-14 15:07:15

标签: c winapi enumeration

我使用EnumChildWindows从主HWND窗口获取所有子窗口,但我想只得到给定HWND窗口的第一个子窗口。

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

这是对的吗?或任何其他简单的方式?

〜UK

3 个答案:

答案 0 :(得分:3)

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

或者,HWND top_child = GetWindow(thisWindow, GW_CHILD);

答案 1 :(得分:2)

不确定

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

    return FALSE; // stops enumeration.
}

有关详细信息,请参阅MSDN,但相关的一行是:

  

返回值

     

<强> BOOL

     

继续枚举,回调   函数必须返回 TRUE ;停止   枚举,必须返回 FALSE

答案 2 :(得分:2)

GetWindow(...,GW_CHILD)将为您提供z顺序顶部的窗口,我假设您的目标是