1. 程式人生 > >CLR自定義.NET控制元件製作(4)——滑鼠訊息的響應

CLR自定義.NET控制元件製作(4)——滑鼠訊息的響應

 1 #include "stdafx.h" 2 #ifdef _DEBUG
3 #define new DEBUG_NEW 4 #endif 5 #include "myview.h" 6 7 IMPLEMENT_DYNCREATE(CMyView, CView)
8 9 BEGIN_MESSAGE_MAP(CMyView, CView)
10 ON_WM_LBUTTONDOWN()
11 ON_WM_LBUTTONUP()
12 ON_WM_RBUTTONDOWN()
13 ON_WM_RBUTTONUP()
14 ON_WM_MOUSEMOVE()
15 ON_WM_CONTEXTMENU()
16 ON_WM_MBUTTONDOWN()
17 18 END_MESSAGE_MAP()
19 20 CMyView:: CMyView ()
21 {
22 // TODO: 在此處新增構造程式碼23 m_ParentHwnd = NULL;
24 m_pCallBack = NULL;
25 }
26 27 CMyView::~CMyView()
28 {
29 }
30 31 void CMyView::OnLButtonUp(UINT nFlags, CPoint point)
32 {
33 CMyView::OnLButtonUp(nFlags, point);
34 // TODO: 在此新增訊息處理程式程式碼和/或呼叫預設值
35 LONG x = point.x;
36 LONG y = point.y;
37 LPARAM lparam = MAKELPARAM(x,y);
38 ::SendMessage(m_ParentHwnd, WM_LBUTTONUP, 0, lparam);
39 }
40 //其他的滑鼠響應函式省略
41 //……