Lecture Two Event Handling Keyboard and Mouse Input
Contents Debug Technique Message Mapping in MFC Keyboard Msg Mouse Msg Other MSGs MessageBox
Debug Technique BreakPoint afxDump TRACE Debug Window
Message Mapping in MFC Detects event Determines which window get that event OS calls WndProc WndProc determines type of event/message Function in turn takes care of the event
Keyboard Msg Handle all Keyboard event Method to add event handler for a window OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
Mouse Msg Mouse Event Mouse click, movement Mouse wheel SetCapture, ReleaseCapture
Other MSGs WM_PAINT WM_TIMER WM_SIZE WM_CREATE WM_DESTROY
MessageBox Small Dialog Box notify user simple message AfxMessageBox( LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0 ); int CWnd::MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK );