c++windowswinapimessage-pump

Message loop (pump) when attaching a child window from an external application


I am about to attach a child window to an external application. The child window will be a modeless dialog. Since I do not own the source code of the external application (actually Microsoft FSX), I have no idea how I would hook into the message loop or the callback LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) of the parent window itself.

My attaching application runs in its own process, so will I need to write my own message loop, or will my callback be invoked by the parent's message pump?

What would be the correct way of getting ahead?

-- Edit as of Answer regarding SetWindowsHookEx function --

Noteworthy:

  1. How to hook external process with SetWindowsHookEx and WH_KEYBOARD
  2. SetWindowsHookEx in C#
  3. Maybe not working, another SetWindowsHookEx Example

Solution

  • SetWindowsHookEx is the API that will allow an external process to capture window messages (among other things).