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.

傳回

Boolean

如果控制項已處理訊息,則為 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.

適用於