if( nChar == L'C' && GetKeyState(VK_CONTROL) < 0 ) 没反应呢
nChar用67测试也没反应!!
BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd) ON_WM_CHAR()END_MESSAGE_MAP()void CMainWindow::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags ){ if( nChar == L'C' && GetKeyState(VK_CONTROL) < 0 ) MessageBox(L"复制");}BOOL CXXEdit::PreTranslateMessage(MSG* pMsg) { if(WM_KEYDOWN == pMsg->message) { if(::GetFocus() == m_hWnd && (GetKeyState( VK_CONTROL) & 0xFF00 ) == 0xFF00) { // 全选 if( pMsg->wParam == 'A' || pMsg->wParam == 'a') { this->SetSel(0, -1); return true; } // 拷贝 if( pMsg->wParam == 'C' || pMsg->wParam == 'c') { this->Copy(); return true; } // 剪切 if( pMsg->wParam == 'X' || pMsg->wParam == 'x') { this->Cut(); return true; } // 粘贴 if( pMsg->wParam == 'V' || pMsg->wParam == 'v') { this->Paste(); return true; } // 粘贴 if( pMsg->wParam == 'Z' || pMsg->wParam == 'z') { this->Undo(); return true; } } } return CEdit::PreTranslateMessage(pMsg); }