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+YRedo
Ctrl+UUnderline
Ctrl+IItalic
Ctrl+OOpen web page
Ctrl+PPrint
Ctrl+ASelect all
Ctrl+FSearch
Ctrl+KHyperlink
Ctrl+LOpen web page
Ctrl+ZCancel
Ctrl+XCut
Ctrl+CCopy
Ctrl+VPaste
Ctrl+BBold
Ctrl+NNew tab
Ctrl+MNew 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.

HWndGets or sets the window handle of the message.
LParamSpecifies the LParam field of the message.
MsgGets or sets the ID number for the message.
ResultSpecifies the value that is returned to Windows in response to handling the message.
WParamGets 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;
    }
}
Last updated on Apr 22, 2015