添加监听 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); } }