Share via

Control.PreProcessMessage(Message) Method


Preprocesses keyboard or input messages within the message loop before they are dispatched.

 virtual bool PreProcessMessage(System::Windows::Forms::Message % msg);
public virtual bool PreProcessMessage (ref System.Windows.Forms.Message msg);
abstract member PreProcessMessage : Message -> bool
override this.PreProcessMessage : Message -> bool
Public Overridable Function PreProcessMessage (ByRef msg As Message) As Boolean



A Message, passed by reference, that represents the message to process. The possible values are WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, and WM_SYSCHAR.


true if the message was processed by the control; otherwise, false.


PreProcessMessage is called by the application's message loop to preprocess input messages before they are dispatched. Possible values for the msg parameter are WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, and WM_SYSCHAR.

When overriding PreProcessMessage, a control should return true to indicate that it has processed the message. For messages that are not processed by the control, the result of base.PreProcessMessage should be returned. Controls will typically override one of the more specialized methods such as IsInputChar, IsInputKey, ProcessCmdKey, ProcessDialogChar, or ProcessDialogKey instead of overriding PreProcessMessage.

Applies to