protected override void WndProc(ref Message m) { // Listen for operating system message if (m.Msg == NativeMethods.WM_CLIPBOARDUPDATE) { try { if (Clipboard.ContainsText()) { var args = new ClipboardEventArgs(Clipboard.GetText()); OnClipboardUpdate(args); } } catch (ExternalException) { // ignored } } // Called for any unhandled messages base.WndProc(ref m); }
/// <summary> /// Raises the <see cref="ClipboardUpdate"/> event. /// </summary> /// <param name="e">Event arguments for the event.</param> private static void OnClipboardUpdate(ClipboardEventArgs e) { ClipboardUpdate?.Invoke(null, e); }