Pre Process Message Event
If you ever need to override the shortcuts (like Ctrl+O) of the editor, then using this event, you can achieve this goal.
You can override the following shortcuts:
Ctrl+Y | Redo |
Ctrl+U | Underline |
Ctrl+I | Italic |
Ctrl+O | Open web page |
Ctrl+P | |
Ctrl+A | Select all |
Ctrl+F | Search |
Ctrl+K | Hyperlink |
Ctrl+L | Open web page |
Ctrl+Z | Cancel |
Ctrl+X | Cut |
Ctrl+C | Copy |
Ctrl+V | Paste |
Ctrl+B | Bold |
Ctrl+N | New tab |
Ctrl+M | New paragraph |
The event PreProcessMessageEvent allows you to override low level messages of the editor web browser. You can't override the shortcuts using the KeyDown event or other events, because the web browser handles them on lower level.
The event raises in WYSYWYG mode before the editor browser starts preprocess messages.
The event signature (C#):
public event EventHandler<EditorPreProcessMessageEventArgs> PreProcessMessageEvent;
Class EditorPreProcessMessageEventArgs contains the following properties:
public Message Message {get;} public bool Cancel { get; set; }
The message property is a System.Windows.Forms.Message structure.
HWnd | Gets or sets the window handle of the message. |
LParam | Specifies the LParam field of the message. |
Msg | Gets or sets the ID number for the message. |
Result | Specifies the value that is returned to Windows in response to handling the message. |
WParam | Gets or sets the WParam field of the message. |
More info about the System.Windows.Forms.Message is here: https://msdn.microsoft.com/en-us/library/system.windows.forms.message (v=vs.110).aspx.
The Cancel property allows you to cancel futher processing of current message.
The following sample snippet shows how you can override behavior of Ctrl+O shortcut:
private void winFormHtmlEditor1_PreProcessMessageEvent (object sender, SpiceLogic.HtmlEditorControl.Domain.BOs.EditorEventArgs.EditorPreProcessMessageEventArgs e) { if (e.Message.Msg == 0x100 /* WM_KEYDOWN */ && e.Message.WParam.ToInt32() == (int)Keys.O && ModifierKeys == Keys.Control) { //some custom code MessageBox.Show("Custom Ctrl+O shortcut handler here"); //prevent default behavior of the editor for this shortcut e.Cancel = true; } }