FindWindow只能找顶层窗口(top-level)

来源:互联网 发布:php视频百度云 编辑:程序博客网 时间:2024/05/05 05:58

如果你的窗口不是在最顶层,就要先找到该窗口的顶层窗口,再用FindWindowEx一级一级往下找,找到你要的窗口为止。

注意FindWindowEx的第一个参数必须要设,否则windows就把桌面当作父窗口了,此时FindWindowEx的作用和FindWindow是一样的。

 

附FindWindowEx API的第一个参数的说明:

HWND FindWindowEx(

    HWND hwndParent, // handle to parent window
    HWND hwndChildAfter, // handle to a child window
    LPCTSTR lpszClass, // pointer to class name
    LPCTSTR lpszWindow // pointer to window name
   ); 
 

Parameters

hwndParent

Identifies the parent window whose child windows are to be searched.
If hwndParent is NULL, the function uses the desktop window as the parent window. The function searches among windows that are child windows of the desktop.