C++ WebBrowser Control.
The C++ Windows.Forms.WebBrowser control can be used within applications to allow the user to surf the internet and open web enabled documents like html help files, word documents etc.
The control is a basic webbrowser control and is by no means perfect. When using the control for surfing the internet, you will notice that it does not respond to Flash objects correctly. With the Flash objects, the control will only rspond once (click) on the Flash object.
The control includes several navigation methods or functions as: Url ,Navigate ,GoBack ,GoForward ,GoHome, GoSearch.
Namespace: System::Windows::Forms
System.Windows.Forms (in system.windows.forms.dll)
Creating an new C++ Windows forms WebBrowser.
WebBrowser^ webbrowser = gcnew WebBrowser;
Setting the DockStyle for the WebBrowser.
webbrowser->Dock = System::Windows::Forms::DockStyle::Fill;
Navigating Home with the WebBrowser Control.
webbrowser->GoHome();
Navigating to a specific web site.
webbrowser->Navigate("http://www.speakcomputers.com");
Adding a C++ WebBrowser control to the form.
this->Controls->Add(webbrowser);
Creating a DocumentCompleted Event for the C++ WebBrowser control.
webbrowser->DocumentCompleted += gcnew System::Windows::Forms::WebBrowserDocumentCompletedEventHandler(this, &Form1::webbrowser_DocumentCompleted);
Responding to the C++ DocumentCompleted event.
private: System::Void webbrowser_DocumentCompleted(System::Object^ sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^ e)
{
this->BackButton->Enabled = webbrowser->CanGoBack;
this->ForwardButton->Enabled = webbrowser->CanGoForward;
this->textBox1->Text = webbrowser->Url->ToString();
}
To display the Print Dialog Box.
this->webbrowser->ShowPrintDialog();
To display the Print Preview Dialog Box.
this->webbrowser->ShowPrintPreviewDialog();
To display the Properties Dialog Box.
this->webbrowser->ShowPropertiesDialog();
|
|