You are not logged in.

  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

1

Saturday, May 23rd 2009, 8:29am

How to create Windows help files and use it with Jabaco

Hello community,
in the Windows OS it is normal to get your information, about a program or an API, via a CHM file - CHM means compiled HTML. Beside the content it stores structured informations and indexes. It is not very complicated to create your own CHM files. You can use HelpMaker, it is a "RTF-based, page-layout Help Authoring tool. It generates WinHelp, HTML_Help, Website-Help and PDF. It is freeware for commercial and non-commercial usage." It is a great program.

To use your own help files with Jabaco you can use this class:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'-Begin------------------------------------------------------------

  '-External functions---------------------------------------------
    Private WinAPI Function !HtmlHelp Lib "hhctrl.ocx" _
      Alias "HtmlHelpA" (ByVal hwndCaller As Long, _
      ByVal pszFile As String, ByVal uCommand As Long, _
      ByVal dwData As Long) As Long

  '-Constants------------------------------------------------------
    Private Const HH_DISPLAY_TOPIC As Long =&H0
    Private Const HH_CLOSE_ALL As Long = &H12

  '-OpenHelp-------------------------------------------------------
    Public Function Open(FileName As String) AS Long
      Open = !HtmlHelp(0, FileName, HH_DISPLAY_TOPIC, 0)
    End Function    

  '-CloseHelp------------------------------------------------------
    Public Sub Close()
      !HtmlHelp 0, "", HH_CLOSE_ALL, 0
    End Sub    
'-End--------------------------------------------------------------


Look at the following example, to see how easy it works:

Jabaco Source

1
2
3
4
5
6
7
Dim Help As New Help()
  Public Sub HelpOpen_Click()
    Help.Open "c:\\windows\\help\\display.chm"
  End Sub
  Public Sub HelpClose_Click()
    Help.Close   
  End Sub


You can do a lot of things more, but these are the basic steps.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

2

Sunday, May 24th 2009, 10:06am

Hello community,
here is an extension of the class:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'-Begin------------------------------------------------------------

  '-External functions---------------------------------------------
    Private WinAPI Function !HtmlHelp Lib "hhctrl.ocx" _
      Alias "HtmlHelpA" (ByVal hwndCaller As Long, _
      ByVal pszFile As String, ByVal uCommand As Long, _
      ByVal dwData As Long) As Long
      
  '-Constants------------------------------------------------------
    Private Const HH_DISPLAY_TOPIC As Long =&H0
    Private Const HH_DISPLAY_TOC As Long = &H1
    Private Const HH_DISPLAY_INDEX As Long = &H2
    Private Const HH_DISPLAY_SEARCH As Long = &H3
    Private Const HH_CLOSE_ALL As Long = &H12
    
  '-Global variables-----------------------------------------------
    Private VarPtr As New VarPtr()

  '-OpenHelp-------------------------------------------------------
    Public Function Open(FileName As String) As Long
      VarPtr.Init
      Open = !HtmlHelp(0, FileName, HH_DISPLAY_TOPIC, 0)
    End Function
    
  '-ShowTOC--------------------------------------------------------
    Public Function ShowTOC(FileName As String) As Long
      Open = !HtmlHelp(0, FileName, HH_DISPLAY_TOC, 0)
    End Function      
    
  '-ShowTopic------------------------------------------------------
    Public Sub ShowTopic(FileName As String, Topic As String)
      Dim TopicAddr As Long
      TopicAddr = VarPtr.CreateVar("Topic", "String", Len(Topic))
      VarPtr.SetStringVar "Topic", Topic
      !HTMLHelp 0, FileName, HH_DISPLAY_TOPIC, TopicAddr
      VarPtr.DestroyVar "Topic"
    End Sub
    
  '-ShowIndex------------------------------------------------------
    Public Function ShowIndex(FileName As String) As Long
      Open = !HtmlHelp(0, FileName, HH_DISPLAY_INDEX, 0)
    End Function
    
  '-ShowSearch-----------------------------------------------------
    Public Function ShowSearch(FileName As String) As Long
      Dim HH_FTS_QUERY As Long
      HH_FTS_QUERY = VarPtr.CreateVar("HH_FTS_QUERY", "Array", 32)

      Dim pszSearchQeury As Long
      pszSearchQuery = VarPtr.CreateVar("pszSearchQuery", "String", 8)
      VarPtr.SetStringVar "pszSearchQuery", "foo"
   
      Dim pszWindow As Long
      pszWindow = VarPtr.CreateVar("pszWindow", "String", 4)
      VarPtr.SetStringVar "pszWindow", ""
   
      VarPtr.SetArrayLong "HH_FTS_QUERY",  0, 32  'cbStruct
      VarPtr.SetArrayLong "HH_FTS_QUERY",  4, 1   'fUniCodeStrings
      VarPtr.SetArrayLong "HH_FTS_QUERY",  8, pszSearchQuery
      VarPtr.SetArrayLong "HH_FTS_QUERY", 12, 0   'iProximity
      VarPtr.SetArrayLong "HH_FTS_QUERY", 16, 0   'fStemmedSearch
      VarPtr.SetArrayLong "HH_FTS_QUERY", 20, 1   'fTitleOnly
      VarPtr.SetArrayLong "HH_FTS_QUERY", 24, 1   'fExecute
      VarPtr.SetArrayLong "HH_FTS_QUERY", 28, pszWindow
      
      !HtmlHelp 0, FileName, HH_DISPLAY_SEARCH, HH_FTS_QUERY
      
      VarPtr.DestroyVar "pszWindow"
      VarPtr.DestroyVar "pszSearchQuery"
      VarPtr.DestroyVar "HH_FTS_QUERY"
    End Function

  '-CloseHelp------------------------------------------------------
    Public Sub Close()
      VarPtr.UnInit
      !HtmlHelp 0, "", HH_CLOSE_ALL, 0
    End Sub    

'-End--------------------------------------------------------------


And a small example:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'-Begin------------------------------------------------------------ 

  '-Global variables----------------------------------------------- 
    Dim Help As New Help() 
    Dim FileName As String = "c:\\windows\\help\\wmplayer.chm" 

  '-ButtonClick---------------------------------------------------- 
    Public Sub Command1_Click() 
      Help.Open FileName 
      Sleep 2500 
      Help.ShowTOC FileName 
      Sleep 2500 
      Help.ShowIndex FileName 
      Sleep 2500 
      Help.ShowSearch FileName 
      Sleep 2500 
      Help.ShowTopic FileName, "htm/toresizethevideowindow.htm" 
    End Sub 

  '-Button2Click--------------------------------------------------- 
    Public Sub Command2_Click() 
      Help.Close 
    End Sub 

'-End--------------------------------------------------------------


Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

Rate this thread
WoltLab Burning Board