Solved

Changing default event problem

Posted on 2006-07-23
3
149 Views
Last Modified: 2010-04-05
Hi,

I want to change a default event WindowProc of TWebBrowser.

I do like this :

// Pass any key press to the main form onKeyDown event
procedure TMainForm.BrowserWndProc(var Message: TMessage);
begin
  case Message.Msg - CN_BASE of
    WM_KEYFIRST..WM_KEYLAST: // redirect all keyboard messages to self
      Perform(Message.Msg - CN_BASE, Message.WParam, Message.LParam);
    else // pass all other messages back to webbrowser
      FOldWndProc(Message);
  end;
end;

{    
    FOldWndProc: TWndMethod;
    procedure BrowserWndProc(var Message: TMessage);
}

procedure TMainForm.CreateBrowser(URL: string; InPanel: TPanel);
var
  AWeb: TWebBrowser;
begin
    AWeb := TWebBrowser.Create(InPanel);      // attach it to Panel1
    TWinControl(AWeb).Name := 'NewWeb';
    TWinControl(AWeb).Parent := InPanel;
    AWeb.Align := alClient;
    AWeb.Navigate(URL);
    FOldWndProc := AWeb.WindowProc;
    AWeb.WindowProc := BrowserWndProc;
end;

As you can see, I use the FOldWndProc to save the default event handler.

This works fine, however ...
My problem is, how to make this work for "multiple TWebBrowsers" object?
Because the application will have multiple panel and each panel will have a TWebBrowser.

In my understanding each TWebBrowser object should have its own FOldWndProc, but how to do this ?

Thanks for any help.
0
Comment
Question by:dudup
3 Comments
 
LVL 28

Accepted Solution

by:
ciuly earned 145 total points
ID: 17165444
best way would proably be to extend TPanel. implement everything in the panel and not the form.
so you will have a TMyPanel which will create a twebbrowser upon create and destroy upon destroy, get the event handler and process the messages instead of the form.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

13 Experts available now in Live!

Get 1:1 Help Now