大赵传奇

援引事类,扬搉古今,举要删芜,言辩而理切--QQ276605216

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
添加监听
AddClipboardFormatListener(this.Handle); 

移除
RemoveClipboardFormatListener(this.Handle);  

        #region 剪贴板监视器
        [DllImport("user32.dll")]
        public static extern bool AddClipboardFormatListener(IntPtr hwnd);
        [DllImport("user32.dll")]
        public static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
        private static int WM_CLIPBOARDUPDATE = 0x031D;  
        #endregion 
 
        protected override void DefWndProc(ref Message m)
        {
            if (m.Msg == WM_CLIPBOARDUPDATE)
            {
                if (Clipboard.ContainsText())
                {
                    //label1.Text = Clipboard.GetText();
                    this.pFramework.Application.CommandPool.EnableBarItem(typeof(YSC.PluginGIS.EditingPasteCommand).ToString(), true);
                }
                else if (Clipboard.ContainsImage())
                {
                    //pictureBox1.Image = Clipboard.GetImage();
                    //pictureBox1.Update();
                }
                else
                {
                    this.pFramework.Application.CommandPool.EnableBarItem(typeof(YSC.PluginGIS.EditingPasteCommand).ToString(), false);
                }
            }
            else
            {
                base.DefWndProc(ref m);
            }
        }  
View Code

 

posted on 2017-01-04 14:39  赵长青  阅读(197)  评论(0编辑  收藏  举报