MFC mouse events and mfc mouse events

Source: Internet
Author: User

MFC mouse events and mfc mouse events

1. Create a project named MFCBaseMessage

2. Select the basic dialog box mode and click Finish.

3. Final

4. Right-click the Add Class Wizard

 

5. Add mouse events

 

6. Add the following code in ON_LButtonDown:

Void CMFCBaseMessageDlg: OnLButtonDown (UINT nFlags, CPoint point) {// TODO: add the message processing program code and/or call the default CString str; // ZeroMemory (& str, sizeof (CString); str. format (_ T ("x = % d, y = % d"), point. x, point. y); if (MK_CONTROL & nFlags) {str + = L "you press ctrl";} if (MK_SHIFT & nFlags) {str + = L "you pressed the shift key";} AfxMessageBox (str); CDialogEx: OnLButtonDown (nFlags, point );}

7. View results

 

8. Simulate sending events

1 void CMFCBaseMessageDlg: OnBnClickedButton2 () 2 {3 // TODO: add control notification handler code 4 5 // 0x00010002 forks to 0x0001 and 0x00026 7 SendMessage (WM_LBUTTONDOWN, WM_LBUTTONDOWN, 0x00010002); 8}

9. view results

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.