HTML interface in a winforms application

S

Steve

I'm developing a Add-On based WinForms app. The "Host" application is a
basic shell of an application that loads modules that implement the actual
functionality. OK, so that is out of the way. :)

When the host app starts, I wanted to have an HTML "start" page displaying
the different processes that can be used. I have never done this in a
WinForms app and don't know where to start. Does anyone know of a good
tutorial covering the basics involved in something like this? I would need
the links in the HTML to fire an event when clicked, etc, etc.

Thanks for any help,
Steve
 
M

Mike Hofer

Steve said:
I'm developing a Add-On based WinForms app. The "Host" application is a
basic shell of an application that loads modules that implement the actual
functionality. OK, so that is out of the way. :)

When the host app starts, I wanted to have an HTML "start" page displaying
the different processes that can be used. I have never done this in a
WinForms app and don't know where to start. Does anyone know of a good
tutorial covering the basics involved in something like this? I would need
the links in the HTML to fire an event when clicked, etc, etc.

Thanks for any help,
Steve

Actually, you should be able to use the WebBrowser control to do this
quite easily.

I'm assuming that you're going to design a custom web page to represent
available modules. In that case, you can customize the href attribute
of the <A> tags to include a prefix that you recognize (something like
"MYAPP:MyModule").

Once you load the start page into the browser, you can detect
navigation attempts via the WebBrowser's Navigating event, which fires
BEFORE the navigation has been completed and provides you with an
opportunity to cancel the navigation.

For instance, assume the start page looks like this:

<HTML>
<BODY>
<A href="MYAPP:SpellCheck">Spell Check</A>
</BODY>
</HTML>

Now, your Windows form contains a WebBrowser instance (named Browser)
with this document loaded into it. You would handle the Navigating
event as follows:

Private Sub Browser_Navigating(ByVal sender As System.Object, ByVal e
As WebBrowserNavigatingEventArgs) Handles Browser.Navigating

If e.Url.StartsWith("MYAPP:") Then

' Prevent the browser from continuing to browse to an invalid
' url
e.Cancel = True

' Parse the url to extract the component and launch it as
' appropriate
Dim module As String = e.Url.SubString(5).Trim().ToLower()
Select Case module
Case "spellcheck"
' Load the spell checker module into your application
End Select

End If

End Sub

That should at least point you in the right direction.

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top