Delphi截获webbrowser中关闭及右键消息处理一例
来源:互联网 发布:个人理财产品 知乎 编辑:程序博客网 时间:2024/06/04 19:07
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
var
setINI: Tinifile;
oldPoint, newPoint: TPOINT;
begin
if Msg.message = WM_CLOSE then {//判断是否关闭消息} begin
if Msg.HWND = Form1.handle then Form1.Close;
if Msg.HWND = Form1.WebBrowser2.handle then begin //验证消息是否WebBrowser发来的
Form1.WebBrowser2.Navigate('about:blank');
Form1.HomePage.ActivePageIndex := 0;
end;
Handled := true;
end;
//如果是Webbrowser,则不许使用右键菜单
if IsChild(Form1.WebBrowser2.handle, Msg.HWND) and ((Msg.message = WM_RBUTTONDOWN) or (Msg.message = WM_RBUTTONUP)) then begin
GetCursorPos(oldPoint); //保存当前鼠标位置。
Form1.edtx.Text := IntToStr(oldPoint.X);
Form1.edty.Text := IntToStr(oldPoint.Y);
//鼠标位置写到配置文件
setINI := Tinifile.Create(GetCurDir + 'renyuansoft.ini');
setINI.WriteInteger('SET', 'x1', strtoint(Form1.edtx.Text));
setINI.WriteInteger('SET', 'y1', strtoint(Form1.edty.Text));
x1 := strtoint(Form1.edtx.Text);
y1 := strtoint(Form1.edty.Text);
setINI.Free;
Handled := true;
end;
end;
var
setINI: Tinifile;
oldPoint, newPoint: TPOINT;
begin
if Msg.message = WM_CLOSE then {//判断是否关闭消息} begin
if Msg.HWND = Form1.handle then Form1.Close;
if Msg.HWND = Form1.WebBrowser2.handle then begin //验证消息是否WebBrowser发来的
Form1.WebBrowser2.Navigate('about:blank');
Form1.HomePage.ActivePageIndex := 0;
end;
Handled := true;
end;
//如果是Webbrowser,则不许使用右键菜单
if IsChild(Form1.WebBrowser2.handle, Msg.HWND) and ((Msg.message = WM_RBUTTONDOWN) or (Msg.message = WM_RBUTTONUP)) then begin
GetCursorPos(oldPoint); //保存当前鼠标位置。
Form1.edtx.Text := IntToStr(oldPoint.X);
Form1.edty.Text := IntToStr(oldPoint.Y);
//鼠标位置写到配置文件
setINI := Tinifile.Create(GetCurDir + 'renyuansoft.ini');
setINI.WriteInteger('SET', 'x1', strtoint(Form1.edtx.Text));
setINI.WriteInteger('SET', 'y1', strtoint(Form1.edty.Text));
x1 := strtoint(Form1.edtx.Text);
y1 := strtoint(Form1.edty.Text);
setINI.Free;
Handled := true;
end;
end;
0 0
- Delphi截获webbrowser中关闭及右键消息处理一例
- Delphi中禁止WebBrowser右键的方法
- Delphi中禁止WebBrowser右键的方法
- Delphi消息截获
- Delphi中window消息截获的实现方式
- Delphi WebBrowser右键的方法
- Delphi : 使用ApplicationEvents来拦截窗体消息,阻止WebBrowser右键菜单
- delphi 中listview的右键菜单处理
- Delphi中WebBrowser拦截网页Alert对话框消息
- MFC截获消息并处理
- ◇[DELPHI]截获WM_QUERYENDSESSION关机消息
- delphi中Webbrowser
- delphi中Webbrowser
- Delphi中WebBrowser判断页面及JS是否加载完成
- Delphi中WebBrowser判断页面及JS是否加载完成
- Delphi中WebBrowser控件的3个bug及解决方案
- delphi的WebBrowser应用一
- Delphi中对消息的处理
- Ubuntu
- Active-HDL的信号列表保存问题
- 快速排序
- 《ViewPager 详解(一)---基本入门》
- Gradle学习理解
- Delphi截获webbrowser中关闭及右键消息处理一例
- 高德地图图片图层瓦片的实现(不是用一张大图,那样容易导致移动设备死机)
- 调整Android手机的默认亮度
- oninput,onpropertychange,onchange的用法和区别
- C#设计模式—桥接模式
- 《ViewPager 详解(二)---详解四大函数》
- 十五.增加一个项目协作留言板功能(一)----- 建立留言板的model
- Android Studio无法使用Apache的HttpClient
- gearman:从安装到python API测试