Solved

Changing default event problem

Posted on 2006-07-23
3
153 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:
2266180 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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