1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| unit frmMiniBrowser;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, ExtCtrls, SHDocVw;
type
TForm26 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{$R *.DFM}
var
HookID: THandle;
DisableRButton: boolean;
Form1: TForm;
implementation
//------------------------------------------------------------------------------
function MouseProc(nCode: integer; wParam, lParam: longint): longint; stdcall;
function GetClassNameEnh(Handle: Hwnd): string;
var
ClassName: PChar;
Buffer: integer;
begin
Buffer := 40;
getmem(ClassName, Buffer);
windows.GetClassName(Handle, ClassName, Buffer);
Result := ClassName;
Freemem(ClassName);
end;
var P: TPoint;
begin
if (nCode < 0) then
Result := CallNextHookEx(HookID, nCode, wParam, lParam)
else
if DisableRButton and ((wParam = WM_RBUTTONDOWN) or (wParam = WM_RBUTTONUP)) then
begin
GetCursorPos(P);
if Pos('Internet Explorer_', GetClassNameEnh(WindowFromPoint(P))) <> 0 then
Result := HC_SKIP
else
Result := CallNextHookEx(HookID, nCode, wParam, lParam);
end
else
Result := CallNextHookEx(HookID, nCode, wParam, lParam);
end;
//------------------------------------------------------------------------------
procedure TForm26.FormCreate(Sender: TObject);
begin
DisableRButton := True;
HookID := SetWindowsHookEx(WH_MOUSE, MouseProc, 0, GetCurrentThreadId());
end;
//------------------------------------------------------------------------------
procedure TForm26.FormDestroy(Sender: TObject);
begin
if HookID <> 0 then UnHookWindowsHookEx(HookID);
end;
//------------------------------------------------------------------------------
end. |
Partager