win32-使用EnumWindows比较两个窗口的Z轴
通过使用EnumWindows()和枚举窗口来手动确定EnumChildWindows()来直接确定哪个窗口在z轴上比另一个窗口高。
struct myEnumInfo
{
HWND hwnd1;
HWND hwnd2;
HWND hwndOnTop;
}; BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
myEnumInfo *info = (myEnumInfo*) lParam; // is one of the HWNDs found? If so, return it...
if ((hwnd == info->hwnd1) || (hwnd == info->hwnd2))
{
info->hwndOnTop = hwnd;
return FALSE; // stop enumerating
} return TRUE; // continue enumerating
} BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
myEnumInfo *info = (myEnumInfo*) lParam; // is one of the HWNDs found? If so, return it...
if ((hwnd == info->hwnd1) || (hwnd == info->hwnd2))
{
info->hwndOnTop = hwnd;
return FALSE;
} // enumerate this window's children...
EnumChildWindows(hwnd, &EnumChildProc, lParam); // is one of the HWNDs found? If so, return it...
if (info->hwndOnTop)
return FALSE; // stop enumerating return TRUE; // continue enumerating
} HWND WhichOneIsOnTop(HWND hwnd1, HWND hwnd2)
{
// is one of the HWNDs null? If so, return the other HWND...
if (!hwnd1) return hwnd2;
if (!hwnd2) return hwnd1; // is one of the HWNDs in the actual foreground? If so, return it...
HWND fgWnd = GetForegroundWindow();
if ((fgWnd) && ((fgWnd == hwnd1) || (fgWnd == hwnd2)))
return fgWnd; myEnumInfo info;
info.hwnd1 = hwnd1;
info.hwnd1 = hwnd2;
info.hwndOnTop = NULL; // are the HWNDs both children of the same parent?
// If so, enumerate just that parent...
HWND parent = GetAncestor(hwnd1, GA_PARENT);
if ((parent) && (GetAncestor(hwnd2, GA_PARENT) == parent))
{
EnumChildWindows(parent, &EnumChildProc, (LPARAM)&info);
}
else
{
// last resort!! Enumerate all top-level windows and their children,
// looking for the HWNDs wherever they are...
EnumWindows(&EnumWindowsProc, (LPARAM)&info);
} return info.hwndOnTop;
}
win32-使用EnumWindows比较两个窗口的Z轴的更多相关文章
- 在C#中调用Win32函数EnumWindows枚举所有窗口。
原文 http://www.cnblogs.com/mfm11111/archive/2009/06/30/1514322.html 开发旺旺群发软件,难点及重要技术点分析(一) 一. ...
- WPF中两个窗口的互斥
这里所讲的互斥是两个窗口不同时存在,打开一,只显示一:点一相关按钮显示二,关闭一:关闭二,显示一. 窗口一: history winResult winChoice = new winResult() ...
- [Mac]如何让两个窗口各占半个屏幕
OS X中的拆分视图El Capitan或更高版本允许您使用两个应用程序填充Mac屏幕,而无需手动移动和调整窗口大小. 进入拆分视图 按住 窗口左上角的全屏按钮 . 当您按住按钮时,窗口会缩小,您可 ...
- (亲测解决)每次打开excel文件都会出现两个窗口,一个是空白的sheet1,另一个是自己的文档
版权声明:本文为博主原创文章,转载请注明出处! https://blog.csdn.net/sinat_34104446/article/details/80210424 一.问题描述每次打开Exce ...
- 实现两个窗口通信方法-postMessage
此方案可解决跨域而且跨Iframe,而且http和https之间的交互 首先来看一下基本的语法 otherWindow.postMessage(message, targetOrigin, [tran ...
- GetParent、SetParent、MoveWindow - 获取、指定父窗口和移动窗口,IsChild - 判断两个窗口是不是父子关系
提示: SetParent 应该 Windows.SetParent, 因为 TForm 的父类有同名方法. //声明: {获取父窗口句柄} GetParent(hWnd: HWND): HWND; ...
- py+selenium IE 用driver.close()却把两个窗口都关了【已解决】
环境:py3 selenium unittest 测试浏览器:IE10 目标:在单个文件中,有多个用例,执行完A用例,由于打开了新的窗口,必须关闭新的窗口,才不会影响下一条用例的执行. 问题:按例 ...
- QT两个窗口相互切换
信号(signals)与槽(slots)是QT重要机制,例子使用了C++11 lambda表达式进行了信号与槽的连接. 实现两个窗口通过点击按钮完成互相切换,注意子窗口只能发送信号,不能处理,所有信号 ...
- 关于Qt5(1)-- 两个窗口互相切换的例子
<QT Creator快速入门>这本书有一章介绍model和modeless的概念时,用到了两个窗口互相切换的例子.但是原文对该例子的说明非常模糊不清,现整理如下. 1,要求:登陆界面.主 ...
- WIN32 API ------ 最简单的Windows窗口封装类
1 开发语言抉择 1.1 关于开发Win32 程序的语言选择 C还是C++ 在决定抛弃MFC,而使用纯Win32 API 开发Window桌面程序之后,还存在一个语言的选择,这就是是否使用C++.C+ ...
随机推荐
- [转帖]028.PGSQL-用户创建、表空间创建、数据库创建、schema创建、表创建、生成测试数据、指定搜索路径、
https://www.cnblogs.com/star521/p/15054341.html 登录数据库 su postgres #注意这里postgers 前后都有空格 psql -U post ...
- 【转帖】linux环境下使用route指令设置多个网络连接的优先级(通过修改路由表的默认网关条目)
1. 背景 在生活中的会经常遇见一台PC同时连接多个网络的场景.最典型的,一台笔记本可以同时连接一个无线网(手机热点)和一个有线网(以太网).linux和window操作系统在默认情况都会使用最早连接 ...
- [转帖]SpecCPU2017 测试cpu性能
https://www.bbsmax.com/A/GBJrxP1Ed0/ SpecCPU介绍见: https://blog.csdn.net/qq_36287943/article/details/1 ...
- [转帖]linux 调优各项监控指标小记
https://z.itpub.net/article/detail/8A4E4E96522BD59D45AB5A4CA442EDB3 自开始负责生产环境部署,中间遇到了若干线上环境内存以及CPU的问 ...
- 2024了,我不想再用AOP收集业务操作日志了 | 京东云技术团队
0.背景 在近期的项目中,系统涉及到针对系统的业务操作日志统计功能,由于本系统位于业务链路的中心环节,负责接收上游系统的数据,并将基于用户操作产生的数据传递至下游系统,鉴于业务链路的复杂性和操作场景的 ...
- void的讲解 、any的讲解 、联合类型的讲解
1. void的使用 空值一般采用 void 来表示,同时void也可以表示变量 也可以表示函数没有返回值哈 使用了 void 就不能够使用 return 哈 let sum = function() ...
- el-popover 点击取消按钮,弹窗仍然无法关闭
<el-popover placement="bottom" width="200" :ref="aa" :visible.sync= ...
- spring boot设置日志打印为控制台输出和文件输出
日志打印 sources里建logback-spring.xml <?xml version="1.0" encoding="UTF-8"?> &l ...
- hadoop实践01---hdfs分布式集群搭建与启动
一.hdfs集群组成结构
- 【springboot整合druid】java.sql.SQLException: url not set
问题描述 未使用自动装配的机制,实现springboot整合druid时(就是使用druid的jar包,而不是druid-spring-boot-starter)报错 <dependency&g ...