Search code examples
wpfwinapikeyboardmousehwndhost

Pass all keyboard and mouse input from wpf-host application to hosted out of process win32 client. (using HwndHost)


I have an old application (game) that starts at location 0, 0 and is dialog styled. Cant move it the regular way, cant resize, very annoying. I have no access to the source code, just the compiled application.

I am hosting this application in a wpf form using HwndHost, which is working great. Very smooth resizing and moving the window around.

Trouble is that I need all the keyboard and mouse input, while my wpf form has focus, to just be passed on to the hosted application.

I dont need to filter any message or any other fancy stuff, just need my wpf form to be dumb and ignore everything, while the hosted process gets all the input.

What would be the best approach for this?

Since it is out of process, I know this can cause some problems, but I am hoping there is an easy solution out there.

Funny thing is, I do see the mouse move (special in application cursor) in the hosted application, but clicks and/or keyboard input seems to be missed by it.

Thanks!

Huron.


Solution

  • Due to all the problems this has been causing me, I have decided to use another approach. I am now hosting the out of process app inside a winform, instead of the wpf form with hwndhost.

    This causes the hosted app to automatically receive all the input of keyboard and mouse.

    Making my job a whole lot easier.

    Only downside is that resizing is hardly comparable with the resizing I had in the wpf hwndhost. But I can live with that, moving the app around was my top priority anyway.