![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
添加监听 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); } }