프로그래밍/MFC
[MFC Dialog] OnKeyDown message
선제
2011. 10. 27. 16:20
afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
Specifies the virtual key code of the given key. For a list of of standard virtual key codes, see Winuser.h
Repeat count (the number of times the keystroke is repeated as a result of the user holding down the key).
Specifies the scan code, key-transition code, previous key state, and context code, as shown in the following list:
- nChar : 가상 키 코드 [MSDN link : virtual key codes ]
- nRepCnt : 반복 횟수
- nFlags : 각종 정보들..(당장은 몰라도 된다)
가상 키 코드는 키보드에 있는 각 키들의 정보를 가지고 있다.
눌려진 키를 알고싶으면 CString temp = "";temp.Format("%c", nChar);
어떤 경우에 쓰나?
→ 원하는 View 나 Dialog에서 특정 키 입력에 대한 처리를 해야하는경우ex) 로그인 창에 enter키 입력, 게임화면에 특수키 설정( 스타에 F10같은 키 처리) 등등..
이걸로 다양한 키입력 처리를 해보자!! :D