...use your own popup menu in a TWebBrowser component?
Author: Dev4u.ch
{
based on: http://www.swissdelphicenter.ch/de/showcode.php?id=571
basierend auf: http://www.swissdelphicenter.ch/de/showcode.php?id=571
}
var
Form1: TForm1;
HookID: THandle;
implementation
{$R *.DFM}
function MouseProc(nCode: Integer; wParam, lParam: Longint): Longint; stdcall;
var
szClassName: array[0..255] of Char;
MausPos: TPoint;
X, Y: Integer;
const
ie_name = 'Internet Explorer_Server';
begin
GetCursorPos(MausPos);
x := MausPos.x;
y := MausPos.y;
if (nCode < 0) then
Result := CallNextHookEx(HookID, nCode, wParam, lParam)
else if ((wParam = WM_RBUTTONDOWN) or (wParam = WM_RBUTTONUP)) then
begin
GetClassName(PMOUSEHOOKSTRUCT(lParam)^.HWND, szClassName,
SizeOf(szClassName));
if lstrcmp(@szClassName[0], @ie_name[1]) = 0 then
begin
Result := HC_SKIP;
Form1.popupmenu1.popup(X, Y);
end
else
Result := CallNextHookEx(HookID, nCode, wParam, lParam);
end
else
Result := CallNextHookEx(HookID, nCode, wParam, lParam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HookID := SetWindowsHookEx(WH_MOUSE, MouseProc, 0, GetCurrentThreadId());
Webbrowser1.Navigate('http://www.google.com');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if HookID <> 0 then
UnHookWindowsHookEx(HookID);
end;
printed from
www.swissdelphicenter.ch
developers knowledge base