Solved

WebBrowser popupmenu

Posted on 2004-03-23
2
464 Views
Last Modified: 2010-04-04
Hi

I set own Popupmenu to TWebbroswer, but i right click in browser, i get the standard browser popupmenu.
Why?

And how can i do?

Bobcsi
0
Comment
Question by:Bobcsi
2 Comments
 
LVL 2

Accepted Solution

by:
Ratje earned 125 total points
ID: 10656720
Here's a way to do it

var
 HMouseHook:THandle;

procedure TForm1.FormCreate(Sender: TObject);
begin
  HMouseHook   := SetWindowsHookEx(WH_MOUSE,@MouseProc,HInstance,GetCurrentThreadID);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  CloseHandle(HMouseHook);
end;

function MouseProc( nCode: Integer; WP: wParam; LP: lParam ):Integer;stdcall;
var
  MHS:TMOUSEHOOKSTRUCT;
  WC:TWinControl;
  P:TPoint;
begin
  Result:=CallNextHookEx(HMouseHook,nCode,WP,LP);
  if nCode=HC_ACTION then
   begin
     MHS:=PMOUSEHOOKSTRUCT(LP)^;
     if ((WP=WM_RBUTTONDOWN) or (WP=WM_RBUTTONUP)) then
      begin
        WC:=FindVCLWindow(MHS.pt);
        if (WC is TWebBrowser) then
        begin
          Result:=1;
          P:=WC.ScreenToClient(MHS.pt);
          if WP=WM_RBUTTONDOWN then
            PostMessage(MHS.hwnd,WM_LBUTTONDOWN,0,P.x + P.y shl 16);
          if WP=WM_RBUTTONUP then
            PostMessage(MHS.hwnd,WM_LBUTTONUP,0,P.x + P.y shl 16);
          if (TWebBrowser(WC).PopupMenu<>nil) and (WP=WM_RBUTTONUP) then
           begin
            TWebBrowser(WC).PopupMenu.PopupComponent := WC;
            TWebBrowser(WC).PopupMenu.Popup(MHS.pt.x,MHS.pt.y);
           end
          else
            Result := 0 ;
        end;
      end;
   end;
end;
0
 
LVL 2

Author Comment

by:Bobcsi
ID: 10656803
Ohh, nice man:)

It's works:)

Fast men:)
THx

Bobcsi
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question