本文整理汇总了C++中CWinApp::PreTranslateMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp::PreTranslateMessage方法的具体用法?C++ CWinApp::PreTranslateMessage怎么用?C++ CWinApp::PreTranslateMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWinApp
的用法示例。
在下文中一共展示了CWinApp::PreTranslateMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnContextHelp
void CFrameWnd::OnContextHelp()
/*****************************/
{
if( !m_bHelpMode && CanEnterHelpMode() ) {
m_bHelpMode = TRUE;
::SetCursor( _HelpCursor );
UINT nIDOld = (UINT)::SendMessage( m_hWnd, WM_SETMESSAGESTRING,
AFX_IDS_HELPMODEMESSAGE, 0L );
if( nIDOld == 0 ) {
nIDOld = AFX_IDS_IDLEMESSAGE;
}
CWinApp *pApp = AfxGetApp();
ASSERT( pApp != NULL );
MSG msg;
LONG lCount = 0L;
DWORD_PTR dwHelpId = 0L;
for( ;; ) {
while( !::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) {
if( pApp->OnIdle( lCount ) ) {
lCount++;
} else {
::WaitMessage();
}
}
::GetMessage( &msg, NULL, 0, 0 );
if( msg.message == WM_EXITHELPMODE ) {
break;
} else if( msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE ) {
break;
} else if( (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) ||
msg.message == WM_SYSCOMMAND ) {
if( !pApp->PreTranslateMessage( &msg ) ) {
::TranslateMessage( &msg );
if( msg.message != WM_SYSKEYDOWN && msg.message != WM_SYSKEYUP &&
msg.message != WM_SYSCHAR && msg.message != WM_SYSDEADCHAR &&
msg.message != WM_SYSCOMMAND ) {
continue;
}
}
} else if( msg.message == WM_LBUTTONDOWN ||
msg.message == WM_NCLBUTTONDOWN ) {
int nHitTest = (int)::SendMessage( msg.hwnd, WM_NCHITTEST, 0,
MAKELPARAM( msg.pt.x, msg.pt.y ) );
if( nHitTest == HTCLIENT ) {
HWND hWnd = msg.hwnd;
while( hWnd != NULL && dwHelpId == 0L ) {
CPoint point( msg.pt );
::ScreenToClient( hWnd, &point );
dwHelpId = (DWORD_PTR)::SendMessage( hWnd, WM_HELPHITTEST, 0,
MAKELPARAM( point.x,
point.y ) );
hWnd = ::GetParent( hWnd );
}
break;
} else if( nHitTest >= 0 && nHitTest != HTMENU &&
nHitTest != HTSYSMENU ) {
dwHelpId = HID_BASE_NCAREAS + nHitTest;
break;
}
}
::DispatchMessage( &msg );
}
m_bHelpMode = FALSE;
::SendMessage( m_hWnd, WM_SETMESSAGESTRING, nIDOld, 0L );
POINT point;
::GetCursorPos( &point );
HWND hWndCursor = ::WindowFromPoint( point );
if( hWndCursor != NULL ) {
int nHitTest = (int)::SendMessage( hWndCursor, WM_NCHITTEST, 0,
MAKELPARAM( point.x, point.y ) );
::SendMessage( hWndCursor, WM_SETCURSOR, (WPARAM)hWndCursor,
MAKELPARAM( nHitTest, WM_MOUSEMOVE ) );
} else {
HCURSOR hCursor = ::LoadCursor( NULL, IDC_ARROW );
::SetCursor( hCursor );
}
if( dwHelpId != 0L ) {
pApp->WinHelpInternal( dwHelpId );
}
}
}