Control.ProcessKeyMessage(Message) Method

Definition

处理键盘消息。Processes a keyboard message.

protected public:
 virtual bool ProcessKeyMessage(System::Windows::Forms::Message % m);
protected internal virtual bool ProcessKeyMessage (ref System.Windows.Forms.Message m);
abstract member ProcessKeyMessage : Message -> bool
override this.ProcessKeyMessage : Message -> bool
Protected Friend Overridable Function ProcessKeyMessage (ByRef m As Message) As Boolean

Parameters

m
Message

通过引用传递的 Message,表示要处理的窗口消息。A Message, passed by reference, that represents the window message to process.

Returns

Boolean

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

Remarks

当控件收到键盘消息时,将调用此方法。This method is called when a control receives a keyboard message. 方法首先确定控件是否有父级;如果是,它将调用父级的 ProcessKeyPreview 方法。The method first determines whether the control has a parent; if so, it calls the parent's ProcessKeyPreview method. 如果父级的 ProcessKeyPreview 方法不处理消息,则调用 ProcessKeyEventArgs 方法以生成相应的键盘事件。If the parent's ProcessKeyPreview method does not process the message then the ProcessKeyEventArgs method is called to generate the appropriate keyboard events. m 参数包含必须处理的窗口消息。The m parameter contains the window message that must be processed. Message.Msg 属性的可能值为 WM_CHAR、WM_KEYDOWN、WM_SYSKEYDOWN、WM_KEYUP 和 WM_SYSKEYUP。Possible values for the Message.Msg property are WM_CHAR, WM_KEYDOWN, WM_SYSKEYDOWN, WM_KEYUP, and WM_SYSKEYUP.

Notes to Inheritors

重写 ProcessKeyMessage(Message) 方法时,控件应返回 true,以指示它已处理该键。When overriding the ProcessKeyMessage(Message) method, a control should return true to indicate that it has processed the key. 对于不是由控件处理的键,应返回基类的 ProcessKeyEventArgs(Message) 的结果。For keys that are not processed by the control, the result of the base class's ProcessKeyEventArgs(Message) should be returned. 控件很少需要重写此方法(如果需要)。Controls will seldom, if ever, need to override this method.

Applies to

See also