1 / 15

Mouse And Keyboard, Timer event

Week 3 C For Win Lecture :. Mouse And Keyboard, Timer event. Mouse Message Keyboard Message. Contents. Windows uses a number of different messages involving the mouse. These message fall into two categories : Client-area mouse messages Nonclient -area mouse messages

tolla
Download Presentation

Mouse And Keyboard, Timer event

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week 3 C For Win Lecture : Mouse And Keyboard, Timer event

  2. Mouse Message Keyboard Message Contents

  3. Windows uses a number of different messages involving the mouse. • These message fall into two categories : • Client-area mouse messages • Nonclient-area mouse messages • Mouse Events will be learned : • The press and release of a mouse button • The double click of a mouse button • The movement of a mouse Mouse message

  4. Client-Area Mouse Messages Mouse message

  5. Nonclient-Area Mouse Messages Mouse message

  6. The press and release of a mouse button: • Mouse-Down Messages: User locate a position and press a left or right or middle mouse button. The message will be sent • Mouse-Up Messages: After pressing a mouse button, user release it. A mouse-up message is sent Example : WM_LBUTTONDOWN  WM_LBUTTONUP WM_RBUTTONDOWN  WM_RBUTTONUP Mouse message

  7. The syntax of mouse-down(up)messages is : • afx_msg void OnxButtonDown(UINT nFlags, CPoint point); • afx_msg void OnxButtonUp(UINT nFlags, CPoint point); Meanings : • x : replaced with L(left), R(Right), or M(Middle) • point : identify the location of the cursor • nFlags : state of mouse button Mouse message

  8. Example : Mouse message

  9. The double click of a mouse button • When two clicks of the same button occur within a very short period of time. • The second button-down message will be replaced by a WM_xBUTTONDBLCLK message Mouse message the window's WNDCLASS includes the class style CS_DBLCLKS

  10. The movement of a mouse: • After pressing one of mouse buttons, depending on the requirement, the user may not need to immediately release button. User can drag and move mouse to a new position. At that time the message WM_MOUSEMOVE is sent continuously • nFlags Indicates whether various virtual keys are down Mouse message

  11. Example : BOOL m_bTracking ; CPoint m_ptTo; CPoint m_ptFrom; OnInitDialog : m_bTracking = FALSE; Mouse message

  12. Each key in our keyboard has a code that OS can regconize KeyBOARD MESSAGE

  13. The Key-Down Effect : • When user press a key, the message WM_KEYDOWN is sent • The syntax : void OnKeyDown(UINT nChar, UINT nRepCnt,UINT nFlags ); nChar : specify the virtual code of the key that was pressed nRepCnt : specify the number of times counted repeatedly as the key was held down. nFlags : specify the scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. KeyBOARD MESSAGE

  14. If user need to use keyboard message. Do two steps : • Step 1: Add details to function PreTranslateMessage • Step 2: Check nChar in OnKeyDown function to do something OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) if (nChar == ‘{kýtự}') {do yourself } (Ex: ‘A’,’B’,’1’,…) if (nChar == {Mãkýtựảo}) {do yourseft } KeyBOARD MESSAGE

  15. Example: int NumofLetter[30]; OnInitDialog : for(int i = 0; i < 30 ; i++) NumofLetter[i] = 0; KeyBOARD MESSAGE

More Related