lecture two event handling keyboard and mouse input

8
Lecture Two Event Handling Keyboard and Mouse Input

Upload: maria-stafford

Post on 31-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture Two Event Handling Keyboard and Mouse Input

Lecture Two

Event Handling

Keyboard and Mouse Input

Page 2: Lecture Two Event Handling Keyboard and Mouse Input

Contents Debug Technique Message Mapping in MFC Keyboard Msg Mouse Msg Other MSGs MessageBox

Page 3: Lecture Two Event Handling Keyboard and Mouse Input

Debug Technique BreakPoint afxDump TRACE Debug Window

Page 4: Lecture Two Event Handling Keyboard and Mouse Input

Message Mapping in MFC Detects event Determines which window get that event OS calls WndProc WndProc determines type of event/mes

sage Function in turn takes care of the event

Page 5: Lecture Two Event Handling Keyboard and Mouse Input

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, U

INT nFlags) OnKeyUp(UINT nChar, UINT nRepCnt, UIN

T nFlags)

Page 6: Lecture Two Event Handling Keyboard and Mouse Input

Mouse Msg Mouse Event Mouse click, movement Mouse wheel SetCapture, ReleaseCapture

Page 7: Lecture Two Event Handling Keyboard and Mouse Input

Other MSGs WM_PAINT WM_TIMER WM_SIZE WM_CREATE WM_DESTROY

Page 8: Lecture Two Event Handling Keyboard and Mouse Input

MessageBox Small Dialog Box notify user simple messag

e AfxMessageBox( LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0 );

int CWnd::MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK );