RAD Studio VCL Reference
|
Occurs when the application receives a Windows message.
property OnMessage: TMessageEvent;
__property TMessageEvent OnMessage;
Use OnMessage to trap any or all Windows messages posted to all windows in the application. OnMessage occurs when an application receives a Windows message. OnMessage only receives messages that are posted to the message queue, not those sent directly with the Windows API SendMessage function.
An OnMessage event handler allows an application to respond to messages other than those declared in the events for TApplication. If the application doesn't have a specific handler for an incoming message, the message is dispatched to the window for which it was intended, and Windows handles the message.
C++ Examples:
/* This example requires a TApplicationEvents and a TListBox in the form. Select the TApplicationEvents, double click on the OnMessage event and add the following code to the handler. OnMessage is triggered when the application receives a Windows message. */ void __fastcall TAppEventForm::ApplicationEventsMessage(tagMSG &Msg, bool &Handled) { lbOnMessage->Items->Add("X:=" + IntToStr(int(Msg.pt.x)) + "|Y:=" + IntToStr(int(Msg.pt.y))); }
Delphi Examples:
{ This example requires a TApplicationEvents and a TListBox in the form. Select the TApplicationEvents, double click on the OnMessage event and add the following code to the handler. OnMessage is triggered when the application receives a Windows message. } procedure TMainForm.ApplicationEventsMessage(var Msg: tagMSG; var Handled: Boolean); begin lbOnMessage.Items.Add('X:=' + IntToStr(Msg.pt.x) + '|Y:=' + IntToStr(Msg.pt.y)); end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|