码迷,mamicode.com
首页 > 其他好文 > 详细

AutoCAD中获取鼠标右键点击事件(根据明经论坛ahlzl文章改写)

时间:2014-07-27 22:02:39      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

 
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;



[assembly:CommandClass(typeof(TestRunCommand.Class1))]

namespace TestRunCommand
{
    public class Class1
    {
        const int WM_RBUTTONDOWN = 516;
        [CommandMethod("TestRunCommand")]
        public void TestRunCommand()
        {
            Application.PreTranslateMessage += new PreTranslateMessageEventHandler(Application_PreTranslateMessage);
        }

        private void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e)
        {
            if(e.Message.message==WM_RBUTTONDOWN)
            {
                System.Windows.Forms.MessageBox.Show("你点击了鼠标右键");
            }
        }
        [CommandMethod("TestOff")]
        public void TestOff()
        {
            Application.PreTranslateMessage -= new PreTranslateMessageEventHandler(Application_PreTranslateMessage);
        }
    }
}

 

 

下面给出一些鼠标事件的16进制值(程序里用到的是10进制),用的时候自己转一下10进制:

WM_MOUSEFIRST                   0x0200
WM_MOUSEMOVE                   0x0200
WM_LBUTTONDOWN               0x0201
WM_LBUTTONUP                     0x0202
WM_LBUTTONDBLCLK             0x0203
WM_RBUTTONDOWN               0x0204
WM_RBUTTONUP                     0x0205
WM_RBUTTONDBLCLK              0x0206
WM_MBUTTONDOWN                0x0207
WM_MBUTTONUP  bubuko.com,布布扣       0x0208
WM_MBUTTONDBLCLK              0x0209

 

(原文地址:http://bbs.mjtd.com/thread-79667-1-1.html

适用AutoCAD2009及以上版本,注意添加WindowsBase引用

AutoCAD中获取鼠标右键点击事件(根据明经论坛ahlzl文章改写)

标签:

原文地址:http://www.cnblogs.com/QandK/p/3871289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!