Delphi截获webbrowser中关闭及右键消息处理一例
2016-06-15 21:12
561 查看
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;
相关文章推荐
- Delphi对Excel的所有操作(一)
- Delphi对Excel的所有操作(二)
- 怎么在delphi中读取Excel数据(各种详细操作)
- Delphi 各版本新特性功能网址收集
- delphi GBK 以UTF-8的格式URLENCODE编码
- delphi Indy 实现天气预报功能
- DataSnap初步二
- delphi 截取某个字符之前的字段,,如 1234567-9,要分别得到 - 之前的字符串和 - 之后的字符串
- DELPHI加密字串(异或运算加密)
- delphi 文件夹权限设置(执行一个小脚本的笨办法)
- DataSnap初步之一
- [Delphi]检查URL是否有效的函数
- delphi 文件搜索,遍历所有子目录
- DbgridEh数据导出到Excel的方法(Delphi)--适用Ehlib7.0+D7
- delphi 浮点数float转换成十六进制字符串的方法(FloatToHex)
- delphi中exit,abort,break,continue 的区别
- delphi 浮点数转换成十六进制字符串的方法
- 计算器(delphi)
- 奖学金评分系统(系统分析与设计版与Delphi实现代码)
- 在Delphi中创建线程,请一定使用BeginThread()代替CreateThread()创建线程!