Hello everyone, I am trying to make a simple web browser for my own benefit (not a school project). I have been looking through multiple videos on how to do so, and could only find 'simple' web browsers on almost every video for visual c++.

Anyway, the videos work, but I would like to make the browser set me up with a home page, so when you start it it brings you to google(or any other site) automatically.

Any help/tutorial would be helpful.

Here is the video I used: http://www.youtube.com/watch?v=kEkLBAq82xY&feature=related

Sorry to double post, but I really would like to have this done in a relatively small amount of time, and it has already been over 5 hours, and I am going to bed. =P

Anyway, if this is not possible, please let me know. :)

Post the code You wrote. Nobody here is clairvoyant. My guess is to put the code you need in the form initialization function.

BTY: That looks like a very good youtube tutorial :)

Post the code You wrote. Nobody here is clairvoyant.

Ah, okay -- I didn't actually write it. Most of it came pre-existent. But, anyway:

#pragma once


namespace sherwood2 {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::WebBrowser^  webBrowser1;
	protected: 
	private: System::Windows::Forms::TextBox^  textBox1;
	private: System::Windows::Forms::Button^  button1;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->webBrowser1 = (gcnew System::Windows::Forms::WebBrowser());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// webBrowser1
			// 
			this->webBrowser1->Location = System::Drawing::Point(12, 39);
			this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20);
			this->webBrowser1->Name = L"webBrowser1";
			this->webBrowser1->Size = System::Drawing::Size(829, 277);
			this->webBrowser1->TabIndex = 0;
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(12, 12);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(730, 20);
			this->textBox1->TabIndex = 1;
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(748, 10);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(93, 23);
			this->button1->TabIndex = 2;
			this->button1->Text = L"Go";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(853, 328);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->webBrowser1);
			this->Name = L"Sherwood Browser";
			this->Text = L"Sherwood Browser";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 this->webBrowser1->Navigate(this->textBox1->Text);
			 }
	};
}

All I really need to know is how to get the page to go to google from when you first start it.

Go to the designer in your application and click on the Form1 window (or whatever you named it). Go to the properties menu on the right (if it's not there go to View/Other Windows/Properties Window. Click on the lightening bolt to get to the events. Go to load. Double click the empty cell next to it. An event handler will be inserted into your code. Within that type webBrowser1->Navigate("http://www.google.com"); (specify the name of your Web Browser object) Now when your form loads you will get google (or change it to something else -- or as a special exercise let your user specify it as an option ;))

EDIT: I'm not clairvoyant lol -- I've been through a similar tut in C# eons ago. But AD is right and you posted your code anyway, I just lagged behind everyone.

Go to the designer in your application and click on the Form1 window (or whatever you named it). Go to the properties menu on the right (if it's not there go to View/Other Windows/Properties Window. Click on the lightening bolt to get to the events. Go to load. Double click the empty cell next to it. An event handler will be inserted into your code. Within that type webBrowser1->Navigate("http://www.google.com"); (specify the name of your Web Browser object) Now when your form loads you will get google (or change it to something else -- or as a special exercise let your user specify it as an option ;))

Hmm, I went to the event's option, and there is no 'load' option sadly. =[
I am using 2008 express, so maybe that is the reason?

Select the whole Form1 window in the designer (not the webbrowser bit) so on the properties window at the top it should say Form1 (or whatever you called it)

commented: Thanks for the help! +1

Thanks! It worked. =]

I had never noticed that but yes, it certainly works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.