Description : We can know about the browsers IE,Firefox..etc. We can also create our own browser. It is very easy one.
We need the add following reference
AxInterop.SHDocVw
The name space used for creating your own browser
using AxSHDocVw;
The following is the sample code for creating the browser
public partial class Form1 : Form { private AxWebBrowser Mybrowser; private Button MygoButton; private TextBox SearhaddressBox; private Panel Mypanel1; private Panel Mypanel2;
public Form1() { InitializeComponent(); Mypanel1 = new Panel(); Mypanel2 = new Panel(); Mybrowser = new AxWebBrowser(); Mybrowser.BeginInit();
this.SuspendLayout(); Mypanel1.SuspendLayout(); Mypanel2.SuspendLayout();
this.Text = "My own Web Browser"; Mypanel1.Size = new Size(300, 30); Mypanel1.Dock = DockStyle.Top;
Mypanel2.Size = new Size(285, 240); Mypanel2.Location = new Point(5, 31); Mypanel2.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
Mybrowser.Dock = DockStyle.Fill;
SearhaddressBox = new TextBox(); SearhaddressBox.Size = new Size(260, 20); SearhaddressBox.Location = new Point(5, 5); SearhaddressBox.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
MygoButton = new Button(); MygoButton.Location = new Point(270, 5); MygoButton.Size = new Size(20, 20); MygoButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
Mypanel1.Controls.AddRange(new Control[] { SearhaddressBox, MygoButton }); Mypanel2.Controls.Add(Mybrowser); this.Controls.AddRange(new Control[] { Mypanel1, Mypanel2 });
Mybrowser.EndInit(); Mypanel1.ResumeLayout(); Mypanel2.ResumeLayout(); this.ResumeLayout();
MygoButton.Click += new EventHandler(goButton_Click); Mybrowser.GoHome(); } private void goButton_Click(object sender, EventArgs e) { object o = null; Mybrowser.Navigate(SearhaddressBox.Text, ref o, ref o, ref o, ref o); }
Code Explanation 1. Create instance of AxWebBrowser. 2. Assign the controls in it. 3. On the button click navicate the browser.
By Nathan
|
| Author: Neeraj Kumar SIngh 09 Aug 2009 | Member Level: Silver Points : 1 |
hello sir, nice code,but one thing i can't understand i.e. from where we add this reference "AxInterop.SHDocVw".
please give me the complete running application of this code.
thanks & regards, Neeraj Singh.
|
| Author: Shunmuganathan M 10 Aug 2009 | Member Level: Diamond Points : 1 |
It is nothing.. you just right click the project and add reference in the tab .net you can add "AxInterop.SHDocVw" as reference.
Now you are ready to use the name space "using AxSHDocVw"
add the form.. and copy and past the code.. you will get...
|
| Author: Neeraj Kumar SIngh 10 Aug 2009 | Member Level: Silver Points : 1 |
hello sir, i am not getting any reference named like "Axlnterop.SHDocVw" under .net tab or com tab. also not in .net 2005 or .net 2008. please send me a running application as attachment.
thanks & regards, Neeraj Singh.
|
| Author: Abhay 13 Aug 2009 | Member Level: Diamond Points : 1 |
Hi Shunmuganathan m,
good one .
keep it up.
contribute more.
Thanks and Regards Abhay
|