Solved

WebBrowser popupmenu

Posted on 2004-03-23
2
459 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now