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



通过引用传递的 Message,表示要处理的消息。A Message, passed by reference, that represents the message to process. 可能的值有 WM_KEYDOWN、WM_SYSKEYDOWN、WM_CHAR 和 WM_SYSCHAR。The possible values are WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, and WM_SYSCHAR.



如果消息已由控件处理,则为 true;否则为 falsetrue if the message was processed by the control; otherwise, false.


在调度输入消息之前,应用程序的消息循环会调用 PreProcessMessage 来对输入消息进行预处理。PreProcessMessage is called by the application's message loop to preprocess input messages before they are dispatched. msg 参数的可能值包括 WM_KEYDOWN、WM_SYSKEYDOWN、WM_CHAR 和 WM_SYSCHAR。Possible values for the msg parameter are WM_KEYDOWN, WM_SYSKEYDOWN, WM_CHAR, and WM_SYSCHAR.

重写 PreProcessMessage时,控件应返回 true,以指示它已处理消息。When overriding PreProcessMessage, a control should return true to indicate that it has processed the message. 对于不是由控件处理的消息,应返回 base.PreProcessMessage 的结果。For messages that are not processed by the control, the result of base.PreProcessMessage should be returned. 控件通常将重写更专用的方法之一,例如 IsInputCharIsInputKeyProcessCmdKeyProcessDialogCharProcessDialogKey,而不是重写 PreProcessMessageControls will typically override one of the more specialized methods such as IsInputChar, IsInputKey, ProcessCmdKey, ProcessDialogChar, or ProcessDialogKey instead of overriding PreProcessMessage.

Applies to