TAILIEUCHUNG - Teach Yourself Visual C++ 6 in21 Days phần 2

Vâng, bạn đã thực hiện nó thông qua tuần đầu tiên. Vào thời điểm này, bạn đã nhận được một hương vị tốt cho những gì có thể khi xây dựng các ứng dụng với Visual C + +. Bây giờ là thời gian để nhìn lại những gì đã được bảo hiểm và những gì bạn đã học được đến thời điểm này. | Integrating the Mouse and Keyboard in Your Application 6U 9 when the application s main window is not a dialog 10 Setlcon m_hlcon TRUE Set big icon 11 Setlcon m_hlcon FALSE Set small icon 12 13 TODO Add extra initialization here 14 15 16 MY CODE STARTS HERE 17 18 19 Initialize the cursor to the arrow 20 m_bCursor FALSE 21 22 23 MY CODE ENDS HERE 24 25 26 return TRUE return TRUE unless you set the focus to a control 27 3 3. Alter the OnKeyDown function to set the m_bCursor flag to TRUE when you change the cursor as in Listing . Listing . The OnKeyDown FUNCTION. 1 void CMouseDlg OnKeyDown UINT nChar UINT nRepCnt UINT nFlags 2 3 TODO Add your message handler code here and or call default 4 5 6 MY CODE STARTS HERE 7 8 9 char lsChar The current character being pressed 10 HCURSOR lhCursor The handle to the cursor to be displayed 11 12 Convert the key pressed to a character 13 lsChar char nChar 14 15 Is the character A 16 if lsChar A 17 Load the arrow cursor 18 lhCursor AfxGetApp - LoadStandardCursor IDC_ARROW 19 20 Is the character B 21 if lsChar B continues I 62 Day 3 Listing . CONTINUED 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 Load the I beam cursor IhCursor AfxGetApp - LoadStandardCursor IDC_IBEAM Is the character C if IsChar C Load the hourglass cursor IhCursor AfxGetApp - LoadStandardCursor IDC_WAIT Is the character X if IsChar X Load the arrow cursor IhCursor AfxGetApp - LoadStandardCursor IDC_ARROW Set the cursor flag m_bCursor TRUE Set the screen cursor SetCursor lhCursor Exit the application OnOK else Set the cursor flag m_bCursor TRUE Set the screen cursor SetCursor lhCursor MY CODE ENDS HERE CDialog OnKeyDown nChar nRepCnt nFlags 4. Using the Class Wizard add a function for the WM_SETCURSOR message on the dialog object. 5. Edit the OnSetCursor function that you just created adding the code in Listing . Listing . The OnSetCursor FUNCTION. 1 BOOL CMouseDlg OnSetCursor CWnd pWnd UINT .

TỪ KHÓA LIÊN QUAN
Đã 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.