Article ID: 138830
Article Last Modified on 10/17/2003
CWinApp derived class' PreTranslateMessage:
BOOL CMyApp::PreTranslateMessage(MSG* pMsg)
{
CSplashWnd::PreTranslateAppMessage(pMsg);
return CWinApp::PreTranslateMessage(pMsg);
}
The CSplashWnd::PreTranslateAppMessage() looks like this:
void CSplashWnd::PreTranslateAppMessage()
{
if (c_pSplashWnd == NULL)
return;
if (pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_SYSKEYDOWN ||
pMsg->message == WM_LBUTTONDOWN ||
pMsg->message == WM_RBUTTONDOWN ||
pMsg->message == WM_MBUTTONDOWN ||
pMsg->message == WM_NCLBUTTONDOWN ||
pMsg->message == WM_NCRBUTTONDOWN ||
pMsg->message == WM_NCMBUTTONDOWN)
{
c_pSplashWnd->HideSplashScreen();
}
}
void CSplashWnd::HideSplashScreen()
{
DestroyWindow();
AfxGetMainWnd()->UpdateWindow();
}
If a key is pressed while the splash screen is displayed,
HideSplashScreen() is called, which destroys the window. When the
PreTranslateAppMessage() function returns, CWinApp::PreTranslateMessage()
is called for the message when its window has been destroyed already.
BOOL CMyApp::PreTranslateMessage(MSG* pMsg)
{
if (CSplashWnd::PreTranslateAppMessage(pMsg))
return TRUE;
return CWinApp::PreTranslateMessage(pMsg);
}
BOOL PreTranslateAppMessage(MSG* pMsg);
BOOL CSplashWnd::PreTranslateAppMessage(MSG* pMsg)
{
if (c_pSplashWnd == NULL)
return FALSE;
if (pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_SYSKEYDOWN ||
pMsg->message == WM_LBUTTONDOWN ||
pMsg->message == WM_RBUTTONDOWN ||
pMsg->message == WM_MBUTTONDOWN ||
pMsg->message == WM_NCLBUTTONDOWN ||
pMsg->message == WM_NCRBUTTONDOWN ||
pMsg->message == WM_NCMBUTTONDOWN)
{
c_pSplashWnd->HideSplashScreen(); // this destroys the window
return TRUE; // You don't want to call
// CWinApp::PreTranslateMessage
}
return FALSE;
}
Additional query words: kbVC400bug 4.00 4.10
Keywords: kbbug kbfix kbnoupdate kbuidesign kbvc410fix KB138830