|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Neville Franks
|
May 27, 2009 - 3:31 AM
|
I have a CExtResizableDialog inside CExtPageNavigatorWnd inside a CExtResizableDialog and Keyboard accelerators aren’t being processed. ex. VK_F5, ID_TreeShowAllFolders, VIRTKEY BEGIN_MESSAGE_MAP(CKnowledgeTreePageDLG, CExtResizableDialog)
//{{AFX_MSG_MAP(CKnowledgeTreePageDLG)
ON_WM_SIZE()
ON_COMMAND_EX( ID_TreeShowAllFolders, OnDespatchCommand )
.....
//}}AFX_MSG_MAP
END_MESSAGE_MAP() When F5 is pressed CKnowledgeTreePageDLG::OnDespatchCommand() isn’t called. Originally there was only a CExtResizableDialog and this code worked correctly, but since putting it inside CExtPageNavigatorWnd which is inside a CExtResizableDialog it doesn’t. I have a Toolbar button which does ID_TreeShowAllFolders and it does call CKnowledgeTreePageDLG::OnDespatchCommand(). So it appears to be just a keyboard problem. Cwnd::OnWndMsg() for the CKnowledgeTreePageDLG never gets a WM_COMMAND message when F5 is pressed.
|
|
Neville Franks
|
May 28, 2009 - 1:09 AM
|
Thanks, I added the following code to my xxx::::PreTranslateMessage() function and which resolved this issue. HACCEL m_hAccelTable = pMainFrame()->MenuInfoGetDefault()->AccelTableGet( false );
if ( m_hAccelTable )
{ // Note pMainFrame()->m_hWnd not this->m_hWnd so it handles the commands..
if ( ::TranslateAccelerator( pMainFrame()->m_hWnd, m_hAccelTable, pMsg ) )
{
return TRUE;
}
}
|
|
Technical Support
|
May 28, 2009 - 11:42 AM
|
Your code snippet is absolutely OK.
|
|
Technical Support
|
May 27, 2009 - 12:52 PM
|
The CDialog class pre-translates keyboard messages differently, not like the CFrameWnd class does. You created a page navigator inside a frame window and then created a dialog inside a page navigator. The frame window pre-translates the keyboard messages using its accelerator table. Most of other windows are pre-translating keyboard messages via their parent windows and, as a result, the frame window makes accelerators working. But not the dialog windows. The CDialog class implements the VK_TAB key based focus changing via message pre-translation. Dialogs are not friendly to their parent windows. So, you should implement the PreTranslateMessage() virtual method in your dialog class and use the mail frame’s accelerator table for pre-translating keyboard messages. You can also keep a stand-alone HACCEL accelerator table in your dialog class and use it instead if this is needed.
|
|