Control.ProcessKeyPreview(Message) Control.ProcessKeyPreview(Message) Control.ProcessKeyPreview(Message) Control.ProcessKeyPreview(Message) Method

定义

预览键盘消息。Previews a keyboard message.

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

参数

m
Message Message Message Message

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

返回

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

注解

子控件收到键盘消息时,子控件调用此方法。This method is called by a child control when the child control receives a keyboard message. 子控件在为消息生成任何键盘事件之前调用此方法。The child control calls this method before generating any keyboard events for the message. 如果此方法返回true,子控件将认为消息已处理并且不会生成任何键盘事件。If this method returns true, the child control considers the message processed and does not generate any keyboard events. m参数包含要预览的窗口消息。The m parameter contains the window message to preview. 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. 方法只是将字符发送到父级的ProcessKeyPreview方法,如果控件没有父级,则返回。 false ProcessKeyPreviewThe ProcessKeyPreview method simply sends the character to the parent's ProcessKeyPreview method, or returns false if the control has no parent. Form类将重写此方法以执行对话框键的实际处理。The Form class overrides this method to perform actual processing of dialog keys.

继承者说明

当在派生ProcessKeyPreview(Message)类中重写方法时, 控件应返回true以指示它已处理该键。When overriding the ProcessKeyPreview(Message) method in a derived class, a control should return true to indicate that it has processed the key. 对于不是由控件处理的键, 应返回调用基类的ProcessKeyPreview(Message)方法的结果。For keys that are not processed by the control, the result of calling the base class's ProcessKeyPreview(Message) method should be returned.

安全性

UIPermission
用于继承类的所有窗口以调用此方法。for all windows for inheriting classes to call this method. 关联的AllWindows UIPermissionWindow枚举: 值。Associated enumeration: AllWindows value of UIPermissionWindow.

SecurityPermission
供直接调用方调用非托管代码。for the immediate caller to call unmanaged code. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode

适用于

另请参阅