如何判断用户当前使用的窗口是不是我程序的主窗口或我程序的主窗口的某个子窗口?
解决方案 »
- 问个问题,急
- OPenGl 虚拟漫游问题 急,谢谢!!
- MFC操作WORD,如何去掉段落的首行悬进功能?
- 高分求类似visio或者office中的填充选项?
- 求助:为何列表的内容没有显示?(附代码)
- “找不到映像文件中指定的资源类型。”是怎么回事?请帮忙,谢谢!!!
- Norton Antivirus 是不是用了hook? (实时监控)
- 硬件控制的菜鸟级问题
- 为什么说COM是平台、语言无关的?
- 关于SAFEARRAY的问题。请帮我看一下以下的代码??
- VirualStudio进来
- 高手快进(在线等待,急)关于Unhandled exception in test.exe(ADO.DLL) 0xc0000005:Access Violation的错误
The GetParent function retrieves a handle to the specified window's parent or owner. To retrieve a handle to a specified ancestor, use the GetAncestor function. HWND GetParent(
HWND hWnd // handle to child window
);
Parameters
hWnd
[in] Handle to the window whose parent window handle is to be retrieved.
Return Values
If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window, the return value is a handle to the owner window. If the window is a top-level unowned window or if the function fails, the return value is NULL. To get extended error information, call GetLastError. Res
Note that, despite its name, this function can return an owner window instead of a parent window. To obtain the parent window and not the owner, use GetAncestor with the GA_PARENT flag.Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.
HWND GetTopParent(HWND hWnd)
{
HWND hwnd;
if(hWnd ==NULL) return FALSE;
hwnd =hWnd;
while(hwnd !=NULL)
{
hWnd =hwnd;
hwnd =GetParent(hWnd);
}
return hWnd;
}
then you can compare both hwnd.or you can get some property in this window.such as GetClassName,GetWindowText,GetWindowLong API...
HWND GetTopParent(HWND hWnd)
{
HWND hwnd;
if(hWnd ==NULL) return FALSE;
hwnd =hWnd;
while(hwnd !=NULL)
{
hWnd =hwnd;
hwnd =GetParent(hWnd);
}
return hWnd;
}
then you can compare both hwnd.or you can get some property in this window.such as GetClassName,GetWindowText,GetWindowLong API...