Tag Archives: WM_CHAR

How VC6 makes dialog respond to WM_ Char message

How VC6 makes dialog respond to WM_ Char message

The solution is to override the function PreTranslateMessage, which does the processing and sets the focus on the main window.
The specific code is as follows.

BOOLCMfcDlgMainDlg::PreTranslateMessage(MSG*pMsg)
{
if(WM_KEYDOWN==pMsg->message||WM_CHAR==pMsg->message)
{
pMsg->hwnd=m_hWnd;
returnFALSE;
}
returnCDialog::PreTranslateMessage(pMsg);
}