| Hi !
I read about host a web browser in C# window application using Microsoft Web Browser (http://support.microsoft.com/kb/313068). Is it possible to use Microsoft Web Browser COM components in a pc that doesn't have Internet Explorer installed on it? For instance, the user only has firefox or Safari installed on his or her machine. And, can Microsoft Web Browser COM component works in IMac? Can I just include the dll on my setup file ? If not, Is it possible to use System.Diagnostics.Process.Start or System.Windows.Forms.WebBrowser ? Is it possible to post data using System.Diagnostics.Process.Start or System.Windows.Forms.WebBrowser? Thanks |
|
Loading
Scott LyslePosted Jun 28, 2008, 5:40 AM
I don't about the web browser control on a mac but you can use the System.Diagnostic.Process.Start call to load up a specific link in the default web browser. If the target site uses a query string that is an easy way to load values at the start; here is an example that uses Google Maps to display an address (at the bottom you can see the link sent to both the web browser control as well as to the default browser):
private void btnMapIt_Click(object sender, EventArgs e)
{
try
{
string street = string.Empty;
string city = string.Empty;
string state = string.Empty;
string zip = string.Empty;
StringBuilder queryAddress = new StringBuilder();
queryAddress.Append("http://maps.google.com/maps?q=");
if (txtStreet.Text != string.Empty)
{
street = txtStreet.Text.Replace(' ', '+');
queryAddress.Append(street + ',' + '+');
}
if (txtCity.Text != string.Empty)
{
city = txtCity.Text.Replace(' ', '+');
queryAddress.Append(city + ',' + '+');
}
if (txtState.Text != string.Empty)
{
state = txtState.Text.Replace(' ', '+');
queryAddress.Append(state + ',' + '+');
}
if (txtZipCode.Text != string.Empty)
{
zip = txtZipCode.Text.ToString();
queryAddress.Append(zip);
}
// loaded into browser control
webBrowser1.Navigate(queryAddress.ToString());
// open the link into the default browser
System.Diagnostics.Process.Start(queryAddress.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Unable to Retrieve Map");
}
}