?
Solved

Changing default event problem

Posted on 2006-07-23
3
Medium Priority
?
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 580 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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