CHM File in .Net project: can't reach the topic Id correctly

178 Views Asked by At

Context:

I made a chm file with the free version of Help'n'Doc to use it in a .Net Application. This help has to be call by clicking on a button and open on the proper help page.

Problem:

Instead of having this (the correct page in the Contents tab): enter image description here

I got this: enter image description here

Details:

Here's the code to call the help: Help.ShowHelp(Me.btnHashtagHelp, pathHelpFile, HelpNavigator.TopicId, "6")

Here's the page in Help'N'Doc: help'n'doc

What did i do wrong?

2

There are 2 best solutions below

0
8oris On BEST ANSWER

Found the reason of this strange behaviour: the chm files that i called was not local but stored on a professionnal private network. To fix the problem, i copy the file in a local Path that I create.

Here's my code to manage the chm file from "not local" to "local"

    Private Sub HelpFileManagement()
        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''                               Manage the Help File Storage                               '''
        '''  1) Check if the local folder FOLDER1 "C:\Users\USERNAME\Documents\MyAppName" exist. If not, the folder is created
        '''  2) Check if there is a MyAppName-help.chm in FOLDER1 . If not, the file is copied from the network folder to FOLDER1
        '''  3) If there is already a file, check last modification date between the local file and the network file
        '''  
        Dim strHelpFolder As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\MyAppName\"
        Dim dirHelpFolder As DirectoryInfo
        Dim strHelpFileName As String = "MyAppName-help.chm"
        Dim strHelpSourceFile As String = System.IO.Path.Combine(Application.StartupPath, "MyAppName-help.chm")
        Dim dateSourceHelpFile As DateTime
        Dim dateCurrentHelpFile As DateTime
        Dim strMsgException As String = "Problème dans la gestion du fichier d'aide." & vbCrLf & strMsgErrorTellYourAdmin

        Try
            '1)
            If Directory.Exists(strHelpFolder) = False Then
                dirHelpFolder = Directory.CreateDirectory(strHelpFolder)
            End If
            strPathHelp = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Dumbow\"
            strPathHelpFile = System.IO.Path.Combine(strPathHelp, "Dumbow2-help.chm")

            '2)
            If File.Exists(System.IO.Path.Combine(strHelpFolder, strHelpFileName)) = False Then
                File.Copy(strHelpSourceFile, System.IO.Path.Combine(strHelpFolder, strHelpFileName))
            Else
                '3)
                dateSourceHelpFile = File.GetLastWriteTime(strHelpSourceFile)
                dateCurrentHelpFile = File.GetLastWriteTime(System.IO.Path.Combine(strHelpFolder, strHelpFileName))
                If dateSourceHelpFile <> dateCurrentHelpFile Then
                    File.Copy(strHelpSourceFile, System.IO.Path.Combine(strHelpFolder, strHelpFileName), True)
                End If
            End If

        Catch ex As Exception
            MsgBox(strMsgException & vbCrLf & ex.Message, MsgBoxStyle.Information, strMsgBoxGeneralErrorTitle)
            Exit Try

        End Try

    End Sub
0
help-info.de On

I assume it is only the problem of the remaining tab in the navigation pane on the left.

I still tried some things like auto-sync on/off when compiling the help - but in the context of your question without success.

Now I only have the idea to open the help window additionally with the call for the table of contents and to synchronize to the context ID only afterwards (see code below).

The double operation will probably not be noticed by the user of the program.

I would not recommend switching to Microsoft Help2 for application help.

  Private Sub btnOpenHelpContextId02_Click(sender As Object, e As EventArgs) Handles btnOpenHelpContextId02.Click
    Dim strContextID As String
    strContextID = "20010"
    ' --- Open help file - Table of contents (next line inserted only to reset navigation pane to TOC (fix tab issue))
    Help.ShowHelp(Me.btnOpenHelpContextId02, HelpProvider1.HelpNamespace, HelpNavigator.TableOfContents)
    ''--- Show CHM contents tab and a special topic by TopicID -----
    Help.ShowHelp(Me.btnOpenHelpContextId02, HelpProvider1.HelpNamespace, HelpNavigator.TopicId, strContextID)
  End Sub