|
This event occurs when a new window is to be created for
displaying a resource.
Some actions that can cause this include the user shift-clicking on
a link, the user right-clicking on a link and choosing "open in
new window," or a targeted navigation to a frame name that does
not yet exist.
Your browser application can also trigger this event by calling the
Navigate or Navigate2 method with the navOpenInNewWindow
flag.
The TEmbeddedWB control has an opportunity to handle the new window creation itself.
If it does not, a top-level Internet Explorer
window is created as a separate (nonhosted) process.
The TEmbeddedWB can manipulate this event to prevent the window from open or, open it in the application itself. This includes every kind of delphi application (SDI, MDI, and tabbed browsing)
- Command Arguments:
procedure
TForm1.EmbeddedWB1NewWindow2(Sender: TObject;
var ppDisp: IDispatch; var Cancel: WordBool);
Sender
ppDisp
- Optional - can use to provide a new WebBrowser object to use
for the new window. If left unchanged then a new Internet Explorer
window will be created.
Cancel
- Set true to cancel the new window, False to allow the new window to open.
The TWebBrowser component for which the event is being generated. Usage: (Sender as TWebBrowser)
- ppDisp
- An object expression that, optionally, receives
a new, hidden Webbrowser or Internet Explorer object with no URL
loaded.
- Cancel
- A Boolean value that, when set to TRUE, is used
to cancel the navigation.
Set Value of Cancel=TRUE to disable displaying of a
new window.
Set ppDisp to EmbeddedWb.Application of the
webbrowser you want the url to be displayed in:
Example of new window simple Vcl form:
procedure TForm1.EmbeddedWB1NewWindow2(ASender: TObject; var ppDisp: IDispatch;
var Cancel: WordBool);
var
NewApp: TForm1;
begin
NewApp := TForm1.Create(Owner);
NewApp.Visible := true;
ppdisp := NewApp.EmbeddedWB1.Application;
end;
Example of new window on MDI application:
procedure TChildFrm.EmbeddedWB1NewWindow2(ASender: TObject;
var ppDisp: IDispatch; var Cancel: WordBool);
var
NewApp: TChildFrm;
begin
NewApp := TChildFrm.Create(Owner);
NewApp.Visible := true;
ppdisp := NewApp.EmbeddedWB1.Application;
end;
Note:
In our package you can find demos for SDI, MDI, and tabbed browser that demonstrate all the above.
|