Control.ProcessKeyPreview(Message) 方法

定義

預覽鍵盤訊息。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,代表要處理的視窗訊息。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 方法只會將字元傳送至父系的 ProcessKeyPreview 方法,如果控制項沒有父系,則會傳回 falseThe 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. 相關聯的列舉: UIPermissionWindowAllWindows 值。Associated enumeration: AllWindows value of UIPermissionWindow.

SecurityPermission
,讓呼叫端立即呼叫非受控碼。for the immediate caller to call unmanaged code. 相關聯的列舉: UnmanagedCodeAssociated enumeration: UnmanagedCode

適用於

另請參閱