Delphi中禁止WebBrowser右键的方法
生活随笔
收集整理的這篇文章主要介紹了
Delphi中禁止WebBrowser右键的方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
uses MSHtml;
//在控件標簽additional中找到TApplicationEvents控件,拖到窗體上.在TApplicationEvents的OnMessage事件中加入以下代碼:
//替換右鍵菜單
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
var
mPoint: TPoint;
begin
if IsChild(WebBrowser.Handle, Msg.Hwnd) and
((Msg.Message = WM_RBUTTONDOWN) or (Msg.Message = WM_RBUTTONUP)) then
begin
GetCursorPos(mPoint); //得到光標位置
pm5.Popup(mPoint.X, mPoint.Y); //彈出popupmenu1的菜單
Handled := True;
end;
end;
或者
//屏蔽右鍵菜單
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
begin
with Msg do
begin
if not IsChild(WebBrowser1.Handle, hWnd) Exit;
Handled := (message = WM_RBUTTONDOWN) or (message = WM_RBUTTONUP) or (message = WM_CONTEXTMENU);
end;
end;
//在控件標簽additional中找到TApplicationEvents控件,拖到窗體上.在TApplicationEvents的OnMessage事件中加入以下代碼:
//替換右鍵菜單
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
var
mPoint: TPoint;
begin
if IsChild(WebBrowser.Handle, Msg.Hwnd) and
((Msg.Message = WM_RBUTTONDOWN) or (Msg.Message = WM_RBUTTONUP)) then
begin
GetCursorPos(mPoint); //得到光標位置
pm5.Popup(mPoint.X, mPoint.Y); //彈出popupmenu1的菜單
Handled := True;
end;
end;
或者
//屏蔽右鍵菜單
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
begin
with Msg do
begin
if not IsChild(WebBrowser1.Handle, hWnd) Exit;
Handled := (message = WM_RBUTTONDOWN) or (message = WM_RBUTTONUP) or (message = WM_CONTEXTMENU);
end;
end;
?
轉載于:https://www.cnblogs.com/swlove/archive/2010/06/26/1765700.html
總結
以上是生活随笔為你收集整理的Delphi中禁止WebBrowser右键的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [探索][管理]《现在,发现你的优势》
- 下一篇: WINCE知识点滴