Bugster
Bugster

Reputation: 1594

Fix browser dependencies with webBrowser component in Visual Studio C++ 2008 Windows Forms Application?

I'm working on a basic program and I've tried adding a working webBrowser component to, in order to give the user more flexibility and be able to browse certain web-sites from within the program, however I've run into a problem I can't get ahead of.

Most modern websites have some dependencies with the new browsers, for example if you visit youtube from within a webBrowser component it tells you to upgrade to a more modern browser. There are other website issues as well such as transparency issues, bitmap problems, missing or missplaced layout, and whatnot. For example visitting StackOverflow with a webBrowser component makes the website rather odd looking, and the logo is not tansparent.

I used this code to bring up a web browser in a window:

                    this->webBrowser1->Dock = System::Windows::Forms::DockStyle::Fill;
            this->webBrowser1->Location = System::Drawing::Point(0, 0);
            this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20);
            this->webBrowser1->Name = L"webBrowser1";
            this->webBrowser1->Size = System::Drawing::Size(823, 587);
            this->webBrowser1->TabIndex = 0;
            this->webBrowser1->Url = (gcnew System::Uri(L"http://www.google.com", System::UriKind::Absolute));

And this code to navigate to a certain website upon button click after a website was entered in a text field:

private: System::Void toolStripButton1_Click(System::Object^  sender, System::EventArgs^  e) {
                 webBrowser1->Navigate(toolStripTextBox1->Text);
             }

My question is, how do you fix these dependencies? Is there a problem with the Visual Studio itself? (Since I'm using the 2008 version) Or does it use the IE7 options by default? If so, how can you fix it so websites load properly and work as intended?

Upvotes: 0

Views: 577

Answers (1)

warhead
warhead

Reputation: 446

As far as I know the WebBrowser control renders pages in the default mode, which is normally IE7, however, from your description it sounds like your control is actually rendering in IE6 mode. Which would suggest you only have IE6 installed on your development machine.

As it seems the only solution to this problem is to either add a meta tag to the webpage or change the default mode in the registry. For further information, have a look at this post. It might help.

Personally, I'd suggest using a different browser control as you will probably never actually have control over what the users of your tool will be seeing with IE. Webkit and Gecko are both free and easy to use, up to date and offer a lot more functionality, if you can live with the additional dependencies.

Upvotes: 1

Related Questions