有的控件不具备事件的属性功能,比如WEBBROSER控件不具备鼠标的操作功能,那就需要手动的截获这些消息,可以按照以下步骤进行:
1、在窗体上放置一个TApplicationEvents控件,编写OnMessage事件;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if Msg.message = WM_CLOSE then //判断是否关闭消息
begin
if WebBrowser1.Handle = Msg.hwnd then //验证消息是否WebBrowser发来的
Form1.Close; //关闭窗体本身
Handled := true;
end;
end;
2、在捕获的事件中,添加功能,比如:在鼠标右键按下时打开某个功能:
{-----准备截获鼠标双击事件-----}
procedure TFrameMap.AppEventMessage(var Msg: tagMSG; var Handled: Boolean);
begin
if Msg.message = wm_rbuttondown then
begin
if ischild(WebBrowser.handle,msg.hwn