CAD二次开发之鼠标事件捕捉绑定

1、对象初始化时绑定处理事件

1 Application.PreTranslateMessage += new PreTranslateMessageEventHandler(Application_PreTranslateMessage);

2、事件处理

 1         /// <summary>
 2         /// 鼠标事件处理
 3         /// </summary>
 4         /// <param name="sender"></param>
 5         /// <param name="e"></param>
 6         private void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e)
 7         {
 8             if (e.Message.message == (int)MouseMsg.WM_MBUTTONDOWN) 
 9             {
10                 MidButton = true;
11             }
12             if (e.Message.message == (int)MouseMsg.WM_MBUTTONUP)
13             {
14                 MidButton = false;
15             }
16             if (e.Message.message == (int)MouseMsg.WM_MOUSEMOVE) {
17                 if (MidButton) {
18                    ListCurve = GetCurveFromView();
19                 }
20             }
21 
22         }

3、鼠标事件枚举,具体可参考MSDN帮助文档

1     public enum MouseMsg
2     {
3         WM_MOUSEMOVE = 512,
4         WM_LBUTTONDOWN = 513,
5         WM_RBUTTONDOWN = 516,
6         WM_MBUTTONDOWN = 519,
7         WM_MBUTTONUP = 520
8     }

 

上一篇:vector -1


下一篇:[LeetCode] 824. Goat Latin