When the page is displayed as a new window, the following Code Demonstrate how to load the page in the new form and the Web Control of the current form to load the form
1. Create a new form, which should be known to most people. You can use newwindow2, but the vs2005 web control is encapsulated by Ms. Pay attention to it.
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. reflection;
Namespace windowsapplication24
Public partial class form1: Form
{< br>
Public form1 ()
{< br> initializecomponent ();
This. webbrowser1.navigate ("about: blank");
(this. webbrowser1.activexinstance as shdocvw. webbrowser ). newwindow2 + = new shdocvw. dwebbrowserevents2_newwindow2eventhandler (form1_newwindow2);
}
Private void button#click (Object sender, eventargs E)
{
This. webbrowser1.navigate ("www.google.cn ");
}
Void form1_newwindow2 (ref object ppdisp, ref bool cancel)
{
Form1 FRM = new form1 ();
Ppdisp = FRM. webbrowser1.activexinstance;
FRM. Show ();
}
}
}
2. Load directly in the Web Control of the current form. This requires the newwindow3 event.
using system;
using system. collections. generic;
using system. componentmodel;
using system. data;
using system. drawing;
using system. text;
using system. windows. forms;
using system. reflection;
namespace windowsapplication24
{< br> Public partial class form1: Form
{< br>
Public form1 ()
{< br> initializecomponent ();
This. webbrowser1.navigate ("about: blank");
(this. webbrowser1.activexinstance as shdocvw. webbrowser ). newwindow3 + = new shdocvw. dwebbrowserevents2_newwindow3eventhandler (form1_newwindow3);
}
Void form1_newwindow3 (ref object ppdisp, ref bool cancel, uint dwflags, string bstrurlcontext, string bstrurl)
{
Cancel = true;
This. webbrowser1.navigate (bstrurl );
}
Private void button#click (Object sender, eventargs E)
{
This. webbrowser1.navigate ("www.google.cn ");
}
}< BR >}