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 :  -> bool
override this.ProcessKeyPreview :  -> 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

適用於

另請參閱