using FindWindow with multiple root windows

2019-04-30 03:05发布

问题:

So I'm building an app that uses win32's SendMessage as IPC.

I'm using FindWindow to get the hWnd based on className and windowName. This has all being going fine and dandy until I want to talk to a root (as in child of the desktop) Window that has the same name / class name as other root Windows.

Is there an alternative to FindWindow I can use to select the hWnd I want?

回答1:

Can you locate a child window of the window you want? If so, you can use FindWindowEx to walk up to the root window. If not, then you need to use EnumWindows and determine what attributes set the root window you are looking for apart from the other root windows with the same caption and class.