TAILIEUCHUNG - Week 3 C For Win Lecture: Mouse And Keyboard, Timer event

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;

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.