I've found a solution that works. When showing the c# WinForm, use the overload
Form.Show(IWin32Window owner)
and pass the MFC mainframe Hwnd as the owner. Now everything is working as expected.
Domanda
I have a MFC MDI app which defines Ctrl-F as a keyboard accelerator. This app hosts a WinForm dialog. My problem is I want to catch Ctrl-F from this child WinForm dialog but the MFC mainframe seems to be swallowing it.
Do you think there is a way to receive those key press in the WinForm child?
Soluzione 2
I've found a solution that works. When showing the c# WinForm, use the overload
Form.Show(IWin32Window owner)
and pass the MFC mainframe Hwnd as the owner. Now everything is working as expected.
Altri suggerimenti
I think defining your own message loop in WinForm child might work. e.g.
while(true) {
Message m;
GetMessage(out m);
if (m.Msg == WM_QUIT)
break;
DispatchMessage(m);
}
I guess when you type CTRL + F on WinForm then the message is retrieved by the main message loop i.e. your MFC mainframe app and since the focus is on WinForm it doesn't do anything. If you have your own message loop and accelerator key for WinForm then it might work.