I have a problem with keyboard navigation using winforms and an MFC based
host application. Do you see any problems calling PreProcessMessage as a
work around?
Here is the solution I came up with:
// override CWinApp::PreTranslateMessage
bool HandleMessage(MSG* pMsg);
BOOL CMfcHostDialogApp::PreTranslateMessage(MSG* pMsg)
{
if (HandleMessage(pMsg))
return TRUE;
return CWinApp::PreTranslateMessage(pMsg);
}
// attempt to handle messages for managed controls
using namespace System;
using namespace System::Windows::Forms;
bool HandleMessage(MSG* pMsg)
{
if (pMsg != NULL && pMsg->hwnd != NULL)
{
Control^ control = Control::FromHandle(IntPtr(pMsg->hwnd));
if (control != nullptr)
return control->PreProcessMessage(Message::Create(IntPtr(pMsg->hwnd),
pMsg->message, IntPtr((void*)pMsg->wParam), IntPtr(pMsg->lParam)));
}
return false;
}
// end sample code
I can send a full sample solution if necessary.
Bryan Phillips - 17 Mar 2007 06:08 GMT
What problem are you trying to work around?
--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
> I have a problem with keyboard navigation using winforms and an MFC based
> host application. Do you see any problems calling PreProcessMessage as a
[quoted text clipped - 30 lines]
>
> I can send a full sample solution if necessary.
Josh Cooley - 17 Mar 2007 19:37 GMT
I need to be able to tab between controls on winforms based dialogs. I also
need to use keyboard accelerators on winforms based dialogs. Keyboard
navigation is broken when the dialogs are created modeless in an MFC app.
> What problem are you trying to work around?
>
[quoted text clipped - 37 lines]
> >
> > I can send a full sample solution if necessary.