Search code examples
c++mfchwnd

mfc c++ set HWND address of another application through edit control


I know how to get and set the handle of another applications window in the code, but I don't know how to set the applications handle at runtime through an edit control. the problem is is that I have to keep compiling my application every time I want to use it, because the handle of the window in application 2 is dynamic.

does anyone have any ideas?


Solution

  • To find current HWND of application window you are interested in, you can enumareate windows using EnumWindows:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497%28v=vs.85%29.aspx

    or maybe easier is to use FindWindow, if you know its name/class:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx

    you can also use GetWindow to iterate windows:

    http://msdn.microsoft.com/en-us/library/windows/desktop/ms633515%28v=vs.85%29.aspx

    ...lots of possibilities