本文整理自网络,侵删。
TWebBrowser 屏蔽右键菜单
//Here's the code to disable the context menu (the one a user gets when it right-clicks inside a TWebBrowser) for TWebBrowser in a Delphi application:
function MouseProc(nCode: Integer; wParam, lParam: Longint): LongInt; stdcall;var classbuf: array[0..255] of Char;const ie = 'Internet Explorer_Server';begin case nCode < 0 of True: Result := CallNextHookEx(MouseHook, nCode, wParam, lParam) ; False: case wParam of WM_RBUTTONDOWN, WM_RBUTTONUP: begin GetClassName(PMOUSEHOOKSTRUCT(lParam)^.HWND, classbuf, SizeOf(classbuf)) ; if lstrcmp(@classbuf[0], @ie[1]) = 0 then Result := HC_SKIP else Result := CallNextHookEx(MouseHook, nCode, wParam, lParam) ; end else begin Result := CallNextHookEx(MouseHook, nCode, wParam, lParam) ; end; end; //case wParam end; //case nCodeend; (*MouseProc*)
//Form OnCreateprocedure TWebBrowserForm.FormCreate(Sender: TObject) ;begin MouseHook := SetWindowsHookEx(WH_MOUSE, MouseProc, 0, GetCurrentThreadId()) ;end;
//Form OnDestroyprocedure TWebBrowserForm.FormDestroy(Sender: TObject) ;begin if MouseHook <> 0 then UnHookWindowsHookEx(MouseHook) ;end;
If you want to find more about Windows hooks, read the :An introduction to hook procedures
相关阅读 >>
Delphi createmutex建立互斥对象,并且给互斥对象起一个唯一的名字
Delphi 测试字符串写入类: tstringwriter
Delphi int64:是Delphi中最大的整数,64位有符号整数
Delphi 在unicodestring中使用utf-8字符串
Delphi 2010 复制整个文件夹(当然包括嵌套文件夹)
Delphi android实例-退出程序(xe8+小米2)
更多相关阅读请进入《Delphi》频道 >>