### Simple Help Class using WebView

The best way to load a HTML file, located in the DirApp folder is by using LoadUrl.
wvwHelp.LoadUrl("file:///" & File.Combine(File.DirApp, "myhelp.html"))
Example
Show the content of a HTML File in a Webview of a Form defined in a Class.
The form is called from the MainForm.
Class Module HelpView.bas
'Purpose: Show the content of a htmlfile, located in the dirapp folder in a webview
`Private Sub Class_Globals
Private fx As JFX
Private frm As Form
Private wvwHelp As WebView
End Sub`
'Initializes the object. You can add parameters to this method if needed.
`Public Sub Initialize(w As Double, h As Double)
'Init the form with eventname frm, width 300 and height 200
frm.Initialize("frm", w, h)
'Load the layout
frm.RootPane.LoadLayout("HelpView")
'Set the form style as utility and non resizable. Close the form by using [X] at top right
frm.Resizable = False
frm.SetFormStyle("UTILITY")
End Sub`
'Show the content of the helpfile located in the dirapp folder
'Parameter: Title of the helpwindow, helpfile located in the dirapp folder, anchor to jump to optional)
`Public Sub Show(title As String, helpfile As String, anchor As String)
frm.Title = title
frm.Show
Try
If anchor.Length = 0 Then
wvwHelp.LoadUrl("file:///" & File.Combine(File.DirApp, helpfile))
Else
wvwHelp.LoadUrl("file:///" & File.Combine(File.DirApp, helpfile) & "#" & anchor)
End If
Catch
wvwHelp.LoadHtml("

## Error

Can not read the Help file:

" & CRLF & LastException.Message & "

")
End Try
End Sub`
Layout Nodes
WebView wvwHelp
Main App
#Region Project Attributes
#MainFormWidth: 400
#MainFormHeight: 300
#End Region
`Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Public Help As HelpView
Private btnShowHelp As Button
Private btnShowHelpTopic1 As Button
Private btnShowHelpTopic2 As Button
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
Help.Initialize(300, 100)
MainForm = Form1
MainForm.RootPane.LoadLayout("Main")
MainForm.Show
End Sub`
`Sub btnShowHelp_Action
Help.Show("Gimmi some Help", "help.html", "")
End Sub`
`Sub btnShowHelpTopic1_Action
Help.Show("Gimmi some Help", "help.html", "helptopic1")
End Sub`
`Sub btnShowHelpTopic2_Action
Help.Show("Gimmi some Help", "help.html", "helptopic2")
End Sub`
Layout Nodes
Label lblHelloWorld
Button btnShowHelp
Button btnShowHelpTopic1
Button btnShowHelpTopic2
Helpfile Help.html
<H1>YES, here is Help</H1>
<HR>
<P>Some text to help...</P>
<P><A HREF="#helptopic1">Help Topic 1</A></P>
<P><A HREF="#helptopic2">Help Topic 2</A></P>
<a id="helptopic1"/>
<H2>Help Topic 1</H2>
<P>This is Help Topic 1.</P>
<P>Help Text</P>
<HR>
<a id="helptopic2"/>
<H2>Help Topic 2</H2>
<P>This is Help Topic 2.</P>
<P>Help Text</P>
<HR>

Changed: , Category: WebView, File: T6C284M2138.htm, ID: 2138