WTL child window tabbing order
-
I have been tasked to update a WTL program. The program creates many modeless windows, the windows are created with style pop-up and the parent for the window is set to NULL in the create call. The main problem is the tabbing order on the modeless windows is not working. I have verified the VK_TAB message arrives in the main dialog(pretranslate message function) that created the modeless dialogs. How do I go about forwarding the message to the appropriate dialog, or is there a simpler solution to make the tabbing work? I have never had to work with the tabbing msgs before and it all seems a bit mysterious what is really going on. TIA
-
I have been tasked to update a WTL program. The program creates many modeless windows, the windows are created with style pop-up and the parent for the window is set to NULL in the create call. The main problem is the tabbing order on the modeless windows is not working. I have verified the VK_TAB message arrives in the main dialog(pretranslate message function) that created the modeless dialogs. How do I go about forwarding the message to the appropriate dialog, or is there a simpler solution to make the tabbing work? I have never had to work with the tabbing msgs before and it all seems a bit mysterious what is really going on. TIA
Try something like this:
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
// If it's a 'Tab' key then the child dialog should handle it
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB)
return m_dlgChild.PreTranslateMessage(pMsg);
}Then in your child dialog message handler you handle it. Igor.
-
I have been tasked to update a WTL program. The program creates many modeless windows, the windows are created with style pop-up and the parent for the window is set to NULL in the create call. The main problem is the tabbing order on the modeless windows is not working. I have verified the VK_TAB message arrives in the main dialog(pretranslate message function) that created the modeless dialogs. How do I go about forwarding the message to the appropriate dialog, or is there a simpler solution to make the tabbing work? I have never had to work with the tabbing msgs before and it all seems a bit mysterious what is really going on. TIA
Each modeless window (I assume they're all dialogs?) should derive from
CMessageFilter
and override thePreTranslateMessage()
method. ThePreTranslateMessage()
would do:BOOL CYourWindow::PreTranslateMessage ( MSG* pMsg )
{
return IsDialogMessage ( pMsg );
}In each window's
OnInitDialog()
, register for pre-translate calls with:CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter ( this );Look at the wizard-generated
CMainFrame::OnCreate()
if this part is still unclear. -- I'm Michael Dunn and I approve this post. Vote Trogdor in oh-four! -
Each modeless window (I assume they're all dialogs?) should derive from
CMessageFilter
and override thePreTranslateMessage()
method. ThePreTranslateMessage()
would do:BOOL CYourWindow::PreTranslateMessage ( MSG* pMsg )
{
return IsDialogMessage ( pMsg );
}In each window's
OnInitDialog()
, register for pre-translate calls with:CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter ( this );Look at the wizard-generated
CMainFrame::OnCreate()
if this part is still unclear. -- I'm Michael Dunn and I approve this post. Vote Trogdor in oh-four!