2014-04-21 140 views
1

我有用于我的VB6应用程序的.CHM帮助文件。我需要在运行时从项目属性中指定的帮助文件位置更改位置。我不想使用某种形式的HTML帮助。我只需要知道如何更改程序查找.CHM帮助文件的位置。如何在运行时更改.chm文件的位置

有人遇到这个问题?

我想在服务器上用数据文件存储帮助文件,而不是在运行应用程序的单个机器上。

+0

设置在应用程序对象中。 –

回答

3

设置应用程序对象的帮助文件属性如下:

App.HelpFile = g_Path_to_Your_CHM & "\YourHelpFile.chm" 
0

请注意,有一个服务器上的一些安全问题,CHM!

除了碎布回答上面你可能要调用的帮助文件是这样的:

Public Function HFile(ByVal i_HFile As Integer) As String 
'----- Set the string variable to include the application path of helpfile 
Select Case i_HFile 
Case 1 
HFile = App.Path & "\help\CHM-example.chm" 
Case 2 
'----- Place other Help file paths in successive case statements 
HFile = App.Path & "\help\CHM-other-language.chm" 
End Select 
End Function 

所有这一切都通过一个模块添加:

Public Sub ShowContents(ByVal intHelpFile As Integer) 
HtmlHelp hwnd, HFile(intHelpFile), HH_DISPLAY_TOC, 0 
End Sub 

它是由被称为

 
'****************************************************************************** 
'----- Modul - definition for HTMLHelp - (c) Ulrich Kulle, www.help-info.de 
'----- 2002-08-26 Version 1.0 first release 
'----- 2005-07-17 Version 1.1 updated for Pop-Up help 
'****************************************************************************** 
'----- Portions of this code courtesy of David Liske. 
'----- Thanks to David Liske, Don Lammers, Matthew Brown and Thomas Schulz 
'------------------------------------------------------------------------------ 
Type HH_IDPAIR 
    dwControlId As Long 
    dwTopicId As Long 
End Type 

'This array should contain the number of controls that have 
'context-sensitive help, plus one more for a zero-terminating 
'pair. 

Public ids(2) As HH_IDPAIR 

Declare Function GetDlgCtrlID Lib "user32" _ 
    (ByVal hwnd As Long) As Long 

Public Declare 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 

Declare Function HTMLHelpTopic Lib "hhctrl.ocx" Alias "HtmlHelpA" _ 
       (ByVal hwndCaller As Long, ByVal pszFile As String, _ 
       ByVal uCommand As Long, ByVal dwData As String) As Long 

Private Declare Function HtmlHelpSearch Lib "hhctrl.ocx" Alias "HtmlHelpA" _ 
       (ByVal hwndCaller As Long, ByVal pszFile As String, _ 
       ByVal uCommand As Long, dwData As HH_FTS_QUERY) As Long 


Public Const HH_DISPLAY_TOPIC = &H0   ' select last opened tab, [display a specified topic] 
Public Const HH_DISPLAY_TOC = &H1   ' select contents tab, [display a specified topic] 
Public Const HH_DISPLAY_INDEX = &H2   ' select index tab and searches for a keyword 
Public Const HH_DISPLAY_SEARCH = &H3  ' select search tab and perform a search 

Private Const HH_SET_WIN_TYPE = &H4 
Private Const HH_GET_WIN_TYPE = &H5 
Private Const HH_GET_WIN_HANDLE = &H6 
Private Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or 

Public Const HH_HELP_CONTEXT = &HF   ' display mapped numeric value in dwData 

Private Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to WinHelp's HELP_CONTEXTMENU. 
Private Const HH_TP_HELP_WM_HELP = &H11  ' text pop-up help, similar to WinHelp's HELP_WM_HELP. 


Public Type HH_FTS_QUERY    ' UDT for accessing the Search tab 
    cbStruct   As Long    ' Sizeof structure in bytes. 
    fUniCodeStrings As Long    ' TRUE if all strings are unicode. 
    pszSearchQuery As String   ' String containing the search query. 
    iProximity  As Long    ' Word proximity. 
    fStemmedSearch As Long    ' TRUE for StemmedSearch only. 
    fTitleOnly  As Long    ' TRUE for Title search only. 
    fExecute   As Long    ' TRUE to initiate the search. 
    pszWindow   As String   ' Window to display in 
End Type 

Public Function HFile(ByVal i_HFile As Integer) As String 
'----- Set the string variable to include the application path of helpfile 
    Select Case i_HFile 
    Case 1 
    HFile = App.Path & "\help\CHM-example.chm" 
    Case 2 
'----- Place other Help file paths in successive case statements 
    HFile = App.Path & "\help\CHM-other-language.chm" 
    End Select 
End Function 

Public Sub ShowContents(ByVal intHelpFile As Integer) 
    HtmlHelp hwnd, HFile(intHelpFile), HH_DISPLAY_TOC, 0 
End Sub 

Public Sub ShowIndex(ByVal intHelpFile As Integer) 
    HtmlHelp hwnd, HFile(intHelpFile), HH_DISPLAY_INDEX, 0 
End Sub 

Public Sub ShowTopic(ByVal intHelpFile As Integer, strTopic As String) 
    HTMLHelpTopic hwnd, HFile(intHelpFile), HH_DISPLAY_TOPIC, strTopic 
End Sub 

Public Sub ShowTopicID(ByVal intHelpFile As Integer, IdTopic As Long) 
    HtmlHelp hwnd, HFile(intHelpFile), HH_HELP_CONTEXT, IdTopic 
End Sub 
'------------------------------------------------------------------------------ 
'----- display the search tab 
'----- bug: start searching with a string dosn't work 
'------------------------------------------------------------------------------ 
Public Sub ShowSearch(ByVal intHelpFile As Integer) 
Dim searchIt As HH_FTS_QUERY 
    With searchIt 
    .cbStruct = Len(searchIt) 
    .fUniCodeStrings = 1& 
    .pszSearchQuery = "foobar" 
    .iProximity = 0& 
    .fStemmedSearch = 0& 
    .fTitleOnly = 1& 
    .fExecute = 1& 
    .pszWindow = "" 
    End With 
    Call HtmlHelpSearch(0&, HFile(intHelpFile), HH_DISPLAY_SEARCH, searchIt) 
End Sub