Ben Jain
July 20th, 1998, 12:44 PM
In MFC programming, how can I use the accelerator in a dialog with a menu?
| // JP opened flex table
Click to See Complete Forum and Search --> : About accelerator? Ben Jain July 20th, 1998, 12:44 PM In MFC programming, how can I use the accelerator in a dialog with a menu? Elango Ganesan July 20th, 1998, 03:45 PM If you are using menu in a dialog, you have to load the accelerator and translate the accelerator keys in PreTranslateMessage to use the accelerator. For example, to load the accelerator include the following code in InitInstance() of your app class. m_hAccelTable = ::LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR)); To translate the accelerator keys override the PreTranslateMessage() function in your app class. BOOL CMyApp:::PreTranslateMessage(MSG* pMsg) { //m_pMainDlg is your main dialog which contains the menu if (TranslateAccelerator(m_pMainDlg->m_hWnd, m_hAccelTable, pMsg)) { return FALSE; } return CWinApp::PreTranslateMessage(pMsg); } This will take care of accelerator keys Beau B May 30th, 2000, 10:38 PM This worked out great - just one issue - I am getting the "Default sound" played on each accelerator key press. How can I stop this from playing? codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved. |