private void run_CheckedChanged(object sender, EventArgs e) { if (run.Checked) { WinApi.AddClipboardFormatListener(this.Handle); } else { WinApi.RemoveClipboardFormatListener(this.Handle); } }
private async Task InitWithRetry() { // AddClipboardFormatListener may fail when // another app clipboard operation is in progress const int retryDelay = 500; int retryAttempts = 10; while (true) { if (WinApi.AddClipboardFormatListener(this.Handle)) { return; } if (--retryAttempts <= 0) { break; } await Task.Delay(retryDelay); } throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); }
public NotificationForm() { WinApi.SetParent(Handle, WinApi.HWND_MESSAGE); WinApi.AddClipboardFormatListener(Handle); }
private void RegisterClipboard() { WinApi.AddClipboardFormatListener(Handle); }