dudup
asked on
Changing default event problem
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(v ar 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(UR L: 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.
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(v
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(UR
var
AWeb: TWebBrowser;
begin
AWeb := TWebBrowser.Create(InPanel
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.