c++ - 如何从子窗口句柄获取主窗口句柄
问题描述
我想从前景窗口处理主窗口。
hWnd = GetForegroundWindow();
hwndOwner = GetWindow(hWnd, GW_OWNER);
hwndParent = GetParent(hWnd);
hwndOwner
并且hwndParent
只是前景窗口上方的一层。如何在不递归调用上述函数的情况下获得主窗口句柄?
解决方案
使用带有 GA_ROOT 标志的 GetAncestor:GetAncestor(hwndChild, GA_ROOT);
请注意,我不确定 GA_ROOT 和 GA_ROOTOWNER 之间的区别。
推荐阅读
- sql - 清洁日期栏
- machine-learning - caffe net 从 hdf5 层获取下一批
- javascript - 为什么我的代码不起作用,向 SQL 数据库添加记录
- r - 唯一.default(x)中的R Plotly错误:唯一()仅适用于向量
- unity3d - 迷你地图相机显示黑色图像而不是渲染相机视图
- android - 由 Camera2 字节巨大的位图
- python - NeuralNetwork 类无法访问其属性
- angular - 由于这个奇怪的问题,无法运行 ionic 3 build
- google-classroom - 授权 API 访问所有课程和所有课程作业需要哪些帐户权限
- javascript - 以编程方式设置输入值将在其中包含“\”