c++ - 获取子窗口句柄\C++

标签 c++ c winapi parent-child handle

我尝试在这里和谷歌上搜索,最终得到了“GetDlgItem”方法,但它不起作用。

这是我的代码:

HWND hwnd_Parent;
HWND hwnd_Child;

hwnd_Parent = FindWindow(NULL,"MyTitle");
hwnd_Child = GetDlgItem(hwnd, 0x00030756);

hwnd_Parent 没问题(我什至做了一些帖子消息测试),但 hwnd_Child 为空。 所以,你看到的十六进制数字是通过WinSpy++找到的。

我的系统是Windows 7 64位,我的IDE是Code Blocks。

提前致谢。

最佳答案

您需要知道窗口的 ID 才能使用 GetDlgItem()。我怀疑您正在传递从 Spy++ 获得的 HWND。

看起来您正在另一个应用程序中闲逛,因为如果它是您自己的应用程序,那么您就不需要调用 FindWindow,并且您会知道控件 ID。

从 FindWindow 获得顶级窗口后,找到此窗口的最简单方法可能是调用 EnumChildWindows() .

关于c++ - 获取子窗口句柄\C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5423600/

相关文章:

c - 指针数组的不同声明

函数可以返回一个限制指针的参数吗?

windows - 获取 Windows 版本?

python - Windows 7 : how to bring a window to the front no matter what other window has focus?

c++ - 将 OpenMP 与 clang 一起使用

c++ - 将 char[] 转换为 char*

带有指向自身指针的 C 结构 - 访问值

c++ - DeviceIoControl GetLastError 87 (ERROR_INVALID_PARAMETER)

c++ - 什么Alloc API可以在内部调用VirtualAlloc/保留内存?

c++ - 未使用 MinGW 的 g++ 编译器在此范围内声明 GetCurrentHwProfile