Got a webBrowser control on a form displaying ads from a server, trying to load page in the default browser when user clicks on a banner within webBrowser control, by default the control always load pages within IE Browser which is not really what one wants.

This is about as far as I can get to load into default browser, the problem is its loads the banner into new page within default browser not the actual site from clicking the banner:( then you have to click that banner to navigate to site.

private: System::Void webBrowser1_NewWindow(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {

			  e->Cancel = true;

Any one have any ideas how to do this, any help would be greatly appreciated. Yer just a point I am aware I am using webBrowser1->Url which would load banner but don't know what else to use.

Just an update regarding the above problem of launching a default browser when clicking a link within the webBrowser control [VC++ 2010]. It would seem that from what I've read MicroSoft hard code the control to use IE by default [to be expected].

Did find some comments about using NewWindow2/3 to launch default browser but then read it was not backward compatable:(

However did come up with a so called work around solution, I thought I'd post it if any one want to have a tinker, any comments or improvements welcomed.

Add webBrowser1 control on a form & set url to http://validator.w3.org/checklink

//TODO: Add the constructor code here
static int NavFlag = 0;

then add this code to Navigated & Navigating events...

private: System::Void webBrowser1_Navigated(System::Object^  sender, System::Windows::Forms::WebBrowserNavigatedEventArgs^  e) {
			 //Get url from control
		     String ^ URL = webBrowser1->Url->ToString();
			 //Is page from our adserver or whatever? if not must be some other url
			 if(URL != "http://validator.w3.org/checklink" && NavFlag == 1)
				Hide browser control whilst we load page in control to get navigated url
				So user don't see loaded page, looks better.
				this->webBrowser1->Visible = false;
				//Open default browser with new url
				//Reload/Reset original url/page
				this->webBrowser1->Url = (gcnew System::Uri(L"http://validator.w3.org/checklink", System::UriKind::Absolute));
				//Show webBrowser control
				this->webBrowser1->Visible = true;

private: System::Void webBrowser1_Navigating(System::Object^  sender, System::Windows::Forms::WebBrowserNavigatingEventArgs^  e) {

			  //Get URL from browser control
			 String ^ URL = webBrowser1->Url->ToString();

			 //Is page from our adserver or whatever? if not must be some other url
			 if(URL == L"http://validator.w3.org/checklink")
				 NOTE::We have to use flag values to get round reload/refresh stuff
				 when html pages are loading, otherwise we can end up getting multiple
				 instances of default browser opening at once.
				 //Set flag to 1
				 NavFlag = 1;

				 //Set flag to 0
				 NavFlag = 0;



Compile and run, you should if lucky get webBrowser1 control loaded with W3C link checker web page.

Next enter a url google or whatever then click Check, it should open your default browser with results and then webBrowser1 control resets & waits for new url to be entered.

Have a nice day