whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

19 Visitors Online


 
...use your own popup menu in a TWebBrowser component?
Autor: Dev4u.ch
Homepage: http://www.dev4u.ch
[ Print tip ]  

Tip Rating (9):  
     


{
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;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners