Http://www.cnblogs.com/del/archive/2008/10/25/1319318.html
The second parameter of the Tapplicationevents.onmessage Handled if True, indicates that the message has been processed, and ends there.
UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, appevnts, Stdctrls;typeTForm1 =class(Tform) Memo1:tmemo; applicationevents1:tapplicationevents;procedureApplicationevents1message (varmsg:tagmsg;varHandled:boolean);procedureFormmousedown (Sender:tobject; Button:tmousebutton; Shift:tshiftstate; X, Y:integer);End;varForm1:tform1;Implementation{$R *.DFM}procedureTform1.applicationevents1message (varmsg:tagmsg;varHandled:boolean);beginifMSG.message= Wm_lbuttondown ThenbeginMEMO1.LINES.ADD (' OnMessage '); Handled: = False;{Handled default is False, this sentence can be omitted}//Handled: = True; {If so, the following OnMouseDown event will not be executed} End;End;procedureTform1.formmousedown (Sender:tobject; Button:tmousebutton; Shift:tshiftstate; X, Y:integer);beginMEMO1.LINES.ADD (' OnMouseDown ');End;End.
We can use this feature to block some of the messages, such as the Twebbrowser screen right-click menu:
UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Olectrls, SHDocVw, appevnts;typeTForm1 =class(Tform) Webbrowser1:twebbrowser; applicationevents1:tapplicationevents;procedureFormcreate (Sender:tobject);procedureApplicationevents1message (varmsg:tagmsg;varHandled:boolean);End;varForm1:tform1;Implementation{$R *.DFM}procedureTform1.applicationevents1message (varmsg:tagmsg;varHandled:boolean);beginifIsChild (Webbrowser1.handle, Msg.hwnd) and(MSG.message= Wm_rbuttondown) ThenbeginHandled: = True;End;End;procedureTform1.formcreate (Sender:tobject);beginWindowState: = wsmaximized; Webbrowser1.align: = Altop; WebBrowser1.Navigate (' http://www.cnblogs.com/del/');End;End.
Learn Message (5): The second parameter about Tapplicationevents.onmessage can be masked twebbrowser right-click menu: