Jump to content

[Beginner question] Something about webBrowser and Form applications

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Doctor

Doctor

    Newbie

  • Members
  • PipPip
  • 23 posts
Hello all.

At first I know the basics of C++ but only on console applications. Now I'm trying to make form application with WebBrowser.

I'm using Microsoft Visual Studio 2008.
Here is my problem:

I create new project (windows forms application) and on design tab I add WebBrowser and Button. Now I know that if I double click on button it will take me on to the Form1.h and if I want to navigate WebBrowser I just type
this->webbrowser1->Navigate("www.google.com"); ..... and it works.

But what about if I want to navigate webbrowser from the main function or from other function? Whatever I do it says that webbrowser1 is not declared. So how can I declare this webbrowser1 in main function?

And where the main code of this forms application should be? In form1.h ???


Thanks for any help you can give.

#2
deskchecked

deskchecked

    Newbie

  • Members
  • PipPip
  • 29 posts
This probably belongs in the Managed C++ forum :)

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Moved.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
Sky

Sky

    Learning Programmer

  • Members
  • PipPipPip
  • 83 posts
Yes, you should be editing that in Form1.h. Just Double click on button "Go" or anything that you want.

Then you should see something like Private: Void Button1_Click(........){
//You can add your code here.
//whenever you click on Button1, this code is executed.
//so if you have textBox1 for putting address, you can do something like this
this->webBrowser1->Navigate(textBox1->text);
//i think it should work.
}

also, you shouldn't touch anything in Main.cpp, because it basically just calls Form1, so you can do what you want in Form1