MFC

PreTranslateMessage - Key

곰돌이짱 2013. 11. 25. 14:00


BOOL CChildView::PreTranslateMessage(MSG* pMsg)
{
    if (pMsg->hwnd == GetDlgItem(IDC_EDIT_1)->GetSafeHwnd())
    {
        if (pMsg->message == WM_KEYDOWN)
        {
            if (pMsg->wParam == VK_ESCAPE)
            {
            }
            else if (pMsg->wParam == VK_RETURN)
            {
            }
            else if (pMsg->wParam == VK_TAB)
            {
            }
        }


     BOOL bShift = ((GetKeyState(VK_SHIFT) & 0x8000) != 0); // Shift 키가 눌렸는지의 여부 저장
     BOOL bControl = ((GetKeyState(VK_CONTROL) & 0x8000) != 0); // Control 키가 눌렸는지의 여부 저장
     BOOL bAlt = ((GetKeyState(VK_MENU) & 0x8000) != 0);   


     if (bControl && !bShift && !bAlt) --> ctrl 키만을 걸러냄..
      {
           if(pMsg->wParam == 'v' || pMsg->wParam == 'V')
           {
              // Paste 함수 구현
           }

           if(pMsg->wParam == 'c' || pMsg->wParam == 'C')
           {
                // Copy 함수 구현...
           }
     }
 
    return CWnd::PreTranslateMessage(pMsg);
}