【发布时间】:2020-10-08 05:47:45
【问题描述】:
我使用了EnumChildWindows,我可以得到所有子窗口的Handle、ClassName和WindowText。但我也想得到所有子窗口的Rectangle。有可能吗?
这是我的代码:
#include <iostream>
#include <windows.h>
using namespace std;
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char class_name[100];
char title[100];
GetClassNameA(hwnd,class_name, sizeof(class_name));
GetWindowTextA(hwnd,title,sizeof(title));
cout <<"Window name : "<<title<<endl;
cout <<"Class name : "<<class_name<<endl;
cout <<"hwnd : "<<hwnd<<endl<<endl;
return TRUE;
}
int main()
{
POINT pt;
Sleep(3000);
GetCursorPos(&pt);
HWND hwnd = WindowFromPoint(pt);
HWND hwndParent = GetParent(hwnd);
EnumChildWindows(hwndParent,EnumWindowsProc,0);
system("PAUSE");
return 0;
}
另外,如何存储每个子窗口的所有数据(句柄、类名、窗口文本、矩形)?也许在向量列表中?
【问题讨论】:
标签: c++ vector rectangles enumerate childwindow