屏蔽skyline的TEInformationWindow自定义菜单

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013779141/article/details/52668027
using System.Windows.Forms;
using TerraExplorerX;

namespace Skyline.app.Globe
{
    public partial class FMContralTree : Form, IMessageFilter
    {
        bool IsInfoWindActive = false;
        public FMContralTree()
        {
            InitializeComponent();
            Application.AddMessageFilter(this);//添加消息过滤器
        }

        private void 定位ToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            MessageBox.Show("Test");
        }

        public bool PreFilterMessage(ref Message message)
        {
            const int WM_RBUTTONDBCLICK = 0X206;
            const int WM_RBUTTONDOWN = 0x204;
            const int WM_RBUTTONUP=0x205;

            switch(message.Msg)
            {
                case WM_RBUTTONDBCLICK:
                case WM_RBUTTONDOWN:
                case WM_RBUTTONUP:
                    if(IsInfoWindActive)//防止在别的窗体上右键操作时,弹出本窗体的右键菜单
                    {
                        message.HWnd = this.Handle;
                        contextMenuStrip1.Show(Control.MousePosition);//弹出自定义右键菜单
                        return true;
                    }
                    return false;
            }
            return false;
        }

        private void axTEInformationWindow1_Enter(object sender, System.EventArgs e)
        {
            IsInfoWindActive = true;
        }

        private void axTEInformationWindow1_Leave(object sender, System.EventArgs e)
        {
            IsInfoWindActive = false;
        }
    }
}

说明:skylineExplorer屏蔽目录树的右键菜单只能通过拦截系统消息的方式,skyline本身不提供屏蔽接口。(目前版本6.6;以后版本不知道是否开放该接口。)

猜你喜欢

转载自blog.csdn.net/u013779141/article/details/52668027
今日推荐