Search

'vk_escape'에 해당되는 글 1건

  1. 2016.07.21 How to prevent MFC dialog closing on Enter and Escape keys?
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

How to prevent MFC dialog closing on Enter and Escape keys?


There is an alternative to the previous answer, which is useful if you wish to still have an OK / Close button. If you override the PreTranslateMessage function, you can catch the use of VK_ESCAPE / VK_RETURN like so:



BOOL CMainDialog::PreTranslateMessage(MSG* pMsg)

{


if (pMsg->message == WM_KEYDOWN)

{

if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)

{

return TRUE;                // Do not process further

}

}


return CDialogEx::PreTranslateMessage(pMsg);

}




이렇게 수정하여야 한다.




PreTranslateMessage 함수를 생성하는 방법은


1. Enter, ESC 키를 차단할 DialogClass 를 우클릭


2. [클래스 마법사] 를 켠다.


3. [가상 함수]


4. 가상 함수 탭에서 PreTranslateMessage 를 선택


5. [함수 추가]


6. 추가된 함수에


if (pMsg->message == WM_KEYDOWN)

{

if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)

{

return TRUE;                // Do not process further

}

}


추가 작성