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