Solved

Changing default event problem

Posted on 2006-07-23
3
150 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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