Here's the "hack" I came up with.
1. created a simple text file named "MakeNewWindow.txt" ... it's content doesn't matter here. I put it on the Desktop of my machine.
2. created a simple HTML test file named "MakeNewWindow.html" :
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<a href="C:\Users\Ur\Desktop\MakeNewWindow.txt">Click here</a>
</body>
</html>
Put that on the Desktop of my machine.
Created a simple WinForm test bed project:
1. main form, 'form1 :
a. put a WebBrowser control on it 'webBrowser1
b. put a TextBox control on it 'textBox1
c. created a Form_Load EventHandler for 'form1
d. created a webBrowser1_Navigating EventHandler for 'webBrowser1
2. second form 'form2 : just a blank form
Here's the code for 'form1:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string HTMLPath=@"C:\Users\Ur\Desktop\MakeNewWindow.html";
private string URLPath=@"C:\Users\Ur\Desktop\MakeNewWindow.txt";
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (e.Url.IsFile)
{
if (e.Url.LocalPath.Contains(URLPath))
{
Form2 newForm2 = new Form2();
newForm2.Show();
newForm2.BringToFront();
e.Cancel = true;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(HTMLPath);
}
}
So when the application is launched:
1. The Form Load EventHandler of 'form 1 executes
a. 'webBrowser1 navigates to the html file specified, and displays it
2. When the user of the running application clicks on the one link in the displayed HTML file:
a. the webBrowser1_Navigating EventHandler is called: see the comments in the code for an explanation of exactly what happens there: which determines whether a new instance of Form2 is created, or not.
Feels like kind of a "hack," and I sincerely hope someone will come along with a better answer !