protected virtual void OnCancelPreview(CancelPreviewEventArgs e) { if (CancelPreview != null) { CancelPreview(this, e); } }
protected override bool ProcessDialogKey(Keys keyData) { // // Overrides the default handling of the Escape key. When a cancel // button is present, the Escape key is not published through // KeyPreview. Because of this, no alternative handling is possible. // This override catches the Escape key before it is processed by // the framework and cancels default handling when the CancelPreview // event signals it has handled the Escape key. // if ((keyData & (Keys.Alt | Keys.Control)) == Keys.None) { Keys keyCode = (Keys)keyData & Keys.KeyCode; if (keyCode == Keys.Escape) { var e = new CancelPreviewEventArgs(); OnCancelPreview(e); if (e.Handled) { return(true); } } } return(base.ProcessDialogKey(keyData)); }
protected override bool ProcessDialogKey(Keys keyData) { // // Overrides the default handling of the Escape key. When a cancel // button is present, the Escape key is not published through // KeyPreview. Because of this, no alternative handling is possible. // This override catches the Escape key before it is processed by // the framework and cancels default handling when the CancelPreview // event signals it has handled the Escape key. // if ((keyData & (Keys.Alt | Keys.Control)) == Keys.None) { Keys keyCode = (Keys)keyData & Keys.KeyCode; if (keyCode == Keys.Escape) { var e = new CancelPreviewEventArgs(); OnCancelPreview(e); if (e.Handled) { return true; } } } return base.ProcessDialogKey(keyData); }