用Visual C++设计窗体探测器
来源:互联网 发布:安卓 adb mac 编辑:程序博客网 时间:2024/05/12 00:05
HWND BrotherWindowFromPoint(HWND hWndPoint,const POINT Point)
{
//检测兄弟窗口
RECT rcPoint;
RECT rcNow;
HWND hWndBrother=hWndPoint;//GetWindow(hWndPoint,GW_HWNDFIRST);
hWndPoint=NULL;
do
{
if(GetWindowstyle(hWndBrother)&WS_VISIBLE)//可见
{
GetWindowRect(hWndBrother,&rcNow);
if(PtInRect(&rcNow,Point))
{
//检验矩形嵌套情况
if(hWndPoint==NULL)
{
hWndPoint=hWndBrother;
rcPoint=rcNow;
}
else if(
((rcNow.bottom<rcPoint.bottom)&&(rcNow.bottom>rcPoint.top)&&
(rcNow.left>rcPoint.left)&&(rcNow.left<rcPoint.right))//左下角
||((rcNow.bottom<rcPoint.bottom)&&(rcNow.bottom>rcPoint.top)&&
(rcNow.right>rcPoint.left)&&(rcNow.right<rcPoint.right))//右下角
||((rcNow.top>rcPoint.top)&&(rcNow.top<rcPoint.bottom)&&
(rcNow.left> ;rcPoint.left)&&(rcNow.left<rcPoint.right))//左上角
||((rcNow.top>rcPoint.top)&&(rcNow.top<rcPoint.bottom)
&&(rcNow.right>rcPoint.left)&&(rcNow.right<rcPoint.right))//右上角
)
{
hWndPoint=hWndBrother;
rcPoint=rcNow;
}
}
}
}while(hWndBrother=GetWindow(hWndBrother,GW_HWNDNEXT));
return hWndPoint;
}
该函数检测同层窗口,获得指定点内,嵌套最深的窗口,由此我们便可以生成我们自己的WindowFromPoint
HWND MyWindowFromPoint(const POINT Point)
{
HWND hWndPoint=WindowFromPoint(Point);
if(hWndPoint)
{
//宽度搜索兄弟窗口
HWND hWndChild;
if(!(GetWindowLong(hWndPoint,GWL_STYLE)&WS_CHILD))//顶层窗口
return hWndPoint;
//非顶层窗口,要进行兄弟查找.
hWndPoint=MyBrotherWindowFromPoint(hWndPoint,Point);
assert(hWndPoint);
//深度搜索子窗口
while(hWndChild=GetTopWindow(hWndPoint))
{
//宽度搜索兄弟子窗口
if(NULL==(hWndChild=MyBrotherWindowFromPoint(hWndChild,Point)))
break;
hWndPoint=hWndChild;
} //*/
}
return hWndPoint;
}
该函数首先判断是否是顶层窗体,如果不是,首先进行宽度搜索,虽然麻烦了些,然而却不得不如此。顺便说一下,VC资源编辑器中正在设计的对话框拥有disable属性,spyxx你的窗体探测器也不能得到其内的所有控件句柄,而该函数所向无敌,如果去掉BrotherWindowFromPoint函数内的可见性判断,隐藏窗体也无处藏身。有兴趣的朋友可以亲自设计一下,如果你是懒惰者,可到华军软件园下在该程序红色间谍.
文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/3_program/vc/vc_js/20100630/266066.html
- 用Visual C 设计窗体探测器
- 用Visual C++设计窗体探测器
- 用VC 设计窗体探测器(句柄)
- 用Visual C#设计屏幕保护程序
- 用Visual Studio.NET设计窗体真累
- 间谍行动——窗体探测器
- 间谍行动——窗体探测器
- Visual C++窗体设计技巧集
- [转帖] Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C++窗体设计技巧集
- Visual C#(创建窗体控件)
- 纷飞
- native2ascii
- Extjs中图片显示混乱的解决方法
- 写给未来的信
- Objective-C中const常量是外连接的
- 用Visual C++设计窗体探测器
- JSmooth的使用:JAR包弄成EXE
- 如何:为泛型列表创建迭代器块(C# 编程指南)
- 早期版本的traps.c
- Understanding Linux Network Internals-1. OverAll
- gnome-terminal用的是配置文件是哪一个?改了default,结果现在无法启动了
- Customer getting the high quality products
- 主题班会:怎样缓解学习压力
- Understanding Linux Network Internals-2. Table of Contents