How to find a child of a parent unmanaged win32 app

a 夏天 提交于 2019-11-28 06:17:08

问题


Basically I am looking for a win32 method to invoke in C# to set the focus to a children of an unmanaged application.

But first I need to find the child control's handle which is the problem. Any useful win32 functions to solve this?


回答1:


There is a library which supports enumerating and searching window handles, which is available at http://mwinapi.sourceforge.net/

Just so that you do not have to reinvent the wheel every time ;)

Start with

SystemWindow.AllToplevelWindows

and then just dig your way down (looking at class names, process names, titles, dialog IDs, whatever).




回答2:


Use FindWindowEx to find the Handle of the Window you're looking for. Once you have that handle, use EnumChildWindows to find the correct child you need. There's too much code involved for me to quickly write up a sample, but there's enough on the web to help.

From Pinvoke.net: http://www.pinvoke.net/default.aspx/user32/EnumChildWindows.html




回答3:


Have you tried to use FindWindowEx?



来源:https://stackoverflow.com/questions/1019790/how-to-find-a-child-of-a-parent-unmanaged-win32-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!