PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if((UINT(pMsg->wParam)==VK_SPACE)||(UINT(pMsg->wParam)==VK_EXECUTE))
{
return 0;
}
在对话框的PreTranslateMessage中去处理,例如
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_CHAR)
{
if (pMsg->wParam == VK_SPACE)
{
// Do you own thing
}
}
}
Add an Accelerator key to the table by associating some key to the resource ID "IDC_BUTTON1".
Add the member variable, m_hAccelTable, to the class CAboutBox:
HACCEL m_hAccelTable;
Initialize m_hAccelTable in CAboutBox::CAboutBox:
m_hAccelTable = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR1));
Use Class Wizard to add an override of the PreTranslateMessage for the CAboutDlg.
In the CAboutBox::PreTranslateMessage() method, add the following lines of code:
BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg) {
if (m_hAccelTable) {
if (::TranslateAccelerator(m_hWnd, m_hAccelTable, pMsg)) {
return(TRUE);
}
}
return CDialog::PreTranslateMessage(pMsg);