我没有显示它创建一个窗口:
int main()
{
CreateWindow("SysListView32","Geek",0, 0, 0, 0, 0,NULL, NULL, (HINSTANCE)GetCurrentProcess(), NULL);
getch();
}
Run Code Online (Sandbox Code Playgroud)
...并在另一个进程中用于FindWindow()查找其句柄:
int main()
{
HWND H = FindWindow("SysListView32", "Geek");
std::cout<< "The handle of created window is : " <<H;
getch();
}
Run Code Online (Sandbox Code Playgroud)
怎么FindWindow找到它的手柄?我以为它不会找到它,因为process1没有显示窗口.
我怎样才能找到可见的窗户?
即使窗口不可见,它当然也在FindWindow枚举的所有现有窗口的列表中(例如,您可以使用Spy ++显示此列表).如果您不想搜索隐藏的窗口,则必须检查其标志:
HWND H = FindWindow("SysListView32", "Geek");
if (H) {
LONG style = GetWindowLong(H, GWL_STYLE);
if (style & WS_VISIBLE)
std::cout << "The handle of created visible window is : " << H << std::endl;
else
std::cout << "The handle of created hidden window is : " << H << std::endl;
} else {
std::cout << "No such window found" << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1497 次 |
| 最近记录: |