C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Application windows, menus & toolbars »

Create your own Web Browser


Posted Date: 03 Aug 2009    Resource Type: Code Snippets    Category: Application windows, menus & toolbars
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 10



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



Responses

Author: Neeraj Kumar SIngh    09 Aug 2009Member 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 2009Member 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 2009Member 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 2009Member Level: Diamond   Points : 1
Hi Shunmuganathan m,

good one .

keep it up.

contribute more.

Thanks and Regards
Abhay


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Web Browser  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Graphics - Bouncing,Shrinking and Rotating Balls
Previous Resource: Creating winforms AutoComplete TextBox using C# in Windows application
Return to Discussion Resource Index
Post New Resource
Category: Application windows, menus & toolbars


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use