你们用EnumWindows有漏掉窗口现象吗

zhtoad 2016-12-13 09:25:45
我用EnumWindows 查找我自己写的程序的一个窗口,用句柄查看器找到这个窗口句柄。
然后用EnumWindows 遍历所有窗口,发现句柄等于这个特定的就提示。
结果发现不是每次都成功。
如果发现不成功后,再人为点一下这个窗体。下次Enum,又能找到。但是几次后,又找不到了,这个窗体始终没有关呢。
真是奇怪
...全文
243 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2016-12-15
  • 打赏
  • 举报
回复
FindWindowEx The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the given child window. This function does not perform a case-sensitive search. 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 Handle to 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. Windows NT 5.0 and later: If hwndParent is HWND_MESSAGE, the function searches all message-only windows. hwndChildAfter Handle to a child window. The search begins with the next child window in the Z order. The child window must be a direct child window of hwndParent, not just a descendant window. If hwndChildAfter is NULL, the search begins with the first child window of hwndParent. Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level and message-only windows. lpszClass Pointer to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to theGlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpszClass; the high-order word must be zero. lpszWindow Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match. Return Values If the function succeeds, the return value is a handle to the window that has the specified class and window names. If the function fails, the return value is NULL. To get extended error information, callGetLastError. QuickInfo Windows NT: Requires version 4.0 or later. Windows: Requires Windows 95 or later. Windows CE: Unsupported. Header: Declared in winuser.h. Import Library: Use user32.lib. Unicode: Implemented as Unicode and ANSI versions on Windows NT. See Also Windows Overview, Window Functions, EnumWindows, FindWindow, GetClassName,GlobalAddAtom
schlafenhamster 2016-12-14
  • 打赏
  • 举报
回复
EnumWindows The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE. BOOL EnumWindows( WNDENUMPROC lpEnumFunc, // pointer to callback function LPARAM lParam // application-defined value ); Parameters lpEnumFunc Pointer to an application-defined callback function. For more information, see EnumWindowsProc. lParam Specifies an application-defined value to be passed to the callback function. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, callGetLastError. Remarks The EnumWindows function does not enumerate child windows. This function is more reliable than calling the GetWindow function in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.
oyljerry 2016-12-13
  • 打赏
  • 举报
回复
直接对比两次找到的所有窗口,看有哪些差别

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧