- 作者:xiaoxiao
- 发表时间:2020-12-23 10:52
- 来源:未知
BOOL CCsdn9View::PreTranslateMessage(MSG* pMsg) { // if(WM_RBUTTONDOWN == pMsg->message) // return true; /* if(WM_KEYDOWN == pMsg->message) { int nState = GetKeyState(VK_CONTROL); if(nState < 0) { int ch = (int) pMsg->wParam ; if('x' == ch || 'X' == ch) ::SendMessage(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),WM_CUT,ID_EDIT_CUT,0); if('C' == ch || 'c' == ch) ::SendMessage(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),WM_COPY,ID_EDIT_CUT,0); if('v' == ch || 'V' == ch) ::SendMessage(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),WM_PASTE,ID_EDIT_CUT,0); } } return CFormView::PreTranslateMessage(pMsg);*/ UINT nKeyCode = pMsg->wParam; // virtual key code of the key pressed if (pMsg->message == WM_KEYDOWN) { if ( (nKeyCode == _T('C') || nKeyCode == _T('X') || nKeyCode == _T('V')) && (::GetKeyState(VK_CONTROL) & 0x8000) ) { ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return(TRUE); } } return CFormView::PreTranslateMessage(pMsg); } 注释掉的代码是别一种实现方法 没有下面的一种简洁