I am docking another application's window inside of my WPF window using HwndHost. To do this, I have to set the WS_CHILD style attribute of the window I am docking and I lose the system menu of that window which is not acceptable. Using HwndHost there is no way around this since it will throw exceptions if that attribute is not set.
My question is;
Since my application doesn't use a system menu, is there any way to directly copy the system menu of the docked application to my app's window? The WinAPI menu functions I'm aware of would all require me to build up the menus from scratch and I don't know how I could hook those menu into the hosted application.
I'm not sure if it matters, but the two windows are within the same process. My application is a plugin of the application window I am docking.
Use
GetSystemMenu
to get anHMENU
for the system menu for the given window. You should be able to cross-reference your own window's system menu with the docked application's system menu, copy across any that your own window doesn't have, and forward them on by handling and forwarding the relevantWM_SYSCOMMAND
messages. Or maybe just copy the whole system menu and forward all of them on.This will probably require a bit of trial and error to make it all work (especially if the docked application isn't expecting to be used this way...) but the above might help get things started.