Learn Message (5): The second parameter about Tapplicationevents.onmessage can be masked twebbrowser right-click menu:

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.