【高分求助】如何确定桌面上任何两个窗口的Z-Order关系???

Genghiskhan 2005-06-12 06:27:08
给定桌面上的任意两个窗口,比如A和B,A和B可能是同一个父窗口的
子窗口,也可能不是同一父窗口的子窗口,还有可能是两个顶层窗口,
总之,A和B代表桌面上任意两个用户可见的窗口。现在我想知道A和B
的前后次序(Z-Order),即哪个窗口在前哪个窗口在后,我试了
GetTopWindow、GetNextWindow、FindWindowEx等好像都不行,
请问用什么方法可以得到这两个窗口的Z-Order关系???

我期待的功能是类似下面的一个函数:

BOOL FindZOrder(HWND hWndA, HWND hWndB)
{
if (hWndA 在 hWndB前面)
return TRUE;
else
return FALSE;

}
...全文
262 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Genghiskhan 2005-06-13
  • 打赏
  • 举报
回复
非常感谢大家的帮助,尤其是cdeee(亦难)的代码,确实很好用,辛苦了,谢谢啦!:)
qrlvls 2005-06-13
  • 打赏
  • 举报
回复
用 GetWindow 或 FindWindowEx 都可以实现
cdeee 2005-06-13
  • 打赏
  • 举报
回复

在 VC/MFC 界面 子栏目我已给你回贴了,是完整的源代码。
kingzai 2005-06-12
  • 打赏
  • 举报
回复
http://www.vccode.com/file_show.php?id=44
download PasswordSpy source code ,it have a such func to do this.search it.
zengwujun 2005-06-12
  • 打赏
  • 举报
回复
你试过GetWindow没有?

HWND GetWindow(
HWND hWnd, // handle to original window
UINT uCmd // relationship
);

第二个参数指定Z-order关系。

应该可以这样:
CWnd *pWnd = AfxGetMainWnd()->GetWindow(GW_HWNDFIRST);//当前窗口Z-order最高
while(pWnd)
{
//要比较的窗口中第一个出现的Z-order高
pWnd = pWnd->GetWindow(GW_HWNDNEXT);
}
zengwujun 2005-06-12
  • 打赏
  • 举报
回复
When an application creates a window, the system puts it at the top of the z-order for windows of the same type. You can use the BringWindowToTop function to bring a window to the top of the z-order for windows of the same type. You can rearrange the z-order by using the SetWindowPos and DeferWindowPos functions.

The user changes the z-order by activating a different window. The system positions the active window at the top of the z-order for windows of the same type. When a window comes to the top of z-order, so do its child windows. You can use the GetTopWindow function to search all child windows of a parent window and return a handle to the child window that is highest in z-order. The GetNextWindow function retrieves a handle to the next or previous window in z-order.

zengwujun 2005-06-12
  • 打赏
  • 举报
回复
mark

16,551

社区成员

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

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

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