Control.PreProcessMessage(Message) 方法

定义

在调度键盘或输入消息之前,在消息循环内对它们进行预处理。Preprocesses keyboard or input messages within the message loop before they are dispatched.

public:
 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

参数

msg
Message

通过引用传递的 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.

安全性

UIPermission
对于所有窗口,如果直接调用方调用此方法,则为。for all windows for the immediate caller to call this method. 关联枚举: UIPermissionWindowAllWindows 值。Associated enumeration: AllWindows value of UIPermissionWindow.

适用于