Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Week 3 C For Win Lecture: Mouse And Keyboard, Timer event presents about Mouse Message; Keyboard Message. This lesson helps people who professional in information technology and person like this. | Week 3 C For Win Lecture : Mouse Message Keyboard Message 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 Client-Area Mouse Messages Nonclient-Area Mouse Messages 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 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 Example : 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 the window's WNDCLASS includes the class style CS_DBLCLKS 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 Example : BOOL m_bTracking ; CPoint m_ptTo; CPoint m_ptFrom; OnInitDialog : m_bTracking = FALSE; Each key in our keyboard has a code that OS can regconize 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. 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 } Example: int NumofLetter[30]; OnInitDialog : for(int i = 0; i < 30 ; i++) NumofLetter[i] = 0; | Week 3 C For Win Lecture : Mouse Message Keyboard Message 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 Client-Area Mouse Messages Nonclient-Area Mouse Messages 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 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 : .