Article ID: 100770
Article Last Modified on 11/21/2006
PostMessage(WM_COMMAND, IDOK, 0L);This produces the same effect as clicking OK when the user clicks Exit on the File menu. Clicking OK closes your dialog box application.
extern HWND ghDlg; // Handle to main dialog box. extern HACCEL ghAccelTable; // Handle to accelerator table.
HWND ghDlg = 0; // Handle to main dialog box. HACCEL ghAccelTable = 0; // Handle to accelerator table.
ghDlg = m_hWnd;
ghAccelTable = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR1));NOTE: The resource ID that is used here (IDR_ACCELERATOR1) is the ID of the accelerator table resource that is added in step 10.
BOOL CMyProjectApp::ProcessMessageFilter(int code, LPMSG lpMsg)
{
if (code < 0)
CWinApp::ProcessMessageFilter(code, lpMsg);
if (ghDlg && ghAccelTable)
{
if (::TranslateAccelerator(ghDlg, ghAccelTable, lpMsg))
return(TRUE);
}
return CWinApp::ProcessMessageFilter(code, lpMsg);
}
Keywords: kbacceleratorkey kbhowto kbkeyaccel kbmenu kbui KB100770