PDA

View Full Version : [Q] Cách đưa file help vào MDIform của VB 6.0



My_Friends
29-06-2003, 20:40
Có ai biết cách đưa file help của Help Workshop vào trong menu của MDIForm chỉ giùm mình với

crazyman
30-06-2003, 09:38
' Class : CWinHelp
' Description : Code for working with Windows Help files
' Source : Total VB SourceBook 6

' Constants to define Help actions
Private Const HELP_CONTEXT = &H1
Private Const HELP_QUIT = &H2
Private Const HELP_INDEX = &H3
Private Const HELP_CONTENTS = &H3
Private Const HELP_HELPONHELP = &H4
Private Const HELP_SETINDEX = &H5
Private Const HELP_SETCONTENTS = &H5
Private Const HELP_CONTEXTPOPUP = &H8
Private Const HELP_FORCEFILE = &H9
Private Const HELP_KEY = &H101
Private Const HELP_COMMAND = &H102
Private Const HELP_PARTIALKEY = &H105
Private Const HELP_FINDER = &HB&

' API call to the help engine
Private Declare Function WinHelp _
Lib "USER32" _
Alias "WinHelpA" _
(ByVal intHWnd As Long, _
ByVal strHelp As String, _
ByVal hCommand As Long, _
ByVal dwData As Any) _
As Long

' Private variables to support properties
Private m_strHelpFile As String

Public Property Get HelpFile() As String
' Returns : The path/name of the currently set help file
' Source: Total VB SourceBook 6
'
HelpFile = m_strHelpFile

End Property

Public Property Let HelpFile(strValue As String)
' strValue - Name of the help file to use.
' Source: Total VB SourceBook 6
'
m_strHelpFile = strValue

End Property

Public Sub CloseFile()
' Comments : Marks the current help file as closed
' Parameters: None
' Returns : Nothing
' Source : Total VB SourceBook 6
'
Dim lngTemp As Long

On Error GoTo PROC_ERR

lngTemp = WinHelp(0, m_strHelpFile, HELP_QUIT, "")

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"CloseFile"
Resume PROC_EXIT

End Sub

Public Sub HelpOnHelp()
' Comments : Opens the Help on Help page
' Parameters: None
' Returns : Nothing
' Source : Total VB SourceBook 6
'
Dim lngTemp As Long

On Error GoTo PROC_ERR

lngTemp = WinHelp(0, "", HELP_HELPONHELP, 0&)

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"HelpOnHelp"
Resume PROC_EXIT

End Sub

Public Sub OpenContents()
' Comments : Opens the Contents page of the current help file
' Parameters: None
' Returns : Nothing
' Source : Total VB SourceBook 6
'
Dim lngTemp As Long

On Error GoTo PROC_ERR

lngTemp = WinHelp(0, m_strHelpFile, HELP_CONTENTS, 0&)

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"OpenContents"
Resume PROC_EXIT

End Sub

Public Sub OpenContext(lngContextID As Long)
' Comments : Opens the specified Help context in the current help file
' Parameters: Nothing
' Returns : None
' Source : Total VB SourceBook 6
'
Dim lngTemp As Long

On Error GoTo PROC_ERR

lngTemp = WinHelp(0, m_strHelpFile, HELP_CONTEXT, lngContextID)

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"OpenContext"
Resume PROC_EXIT

End Sub

Public Sub OpenFinder()
' Comments : Opens the Win95 Finder page of the current help file
' Parameters: None
' Returns : Nothing
' Source : Total VB SourceBook 6
'
Dim lngTemp As Long

On Error GoTo PROC_ERR

lngTemp = WinHelp(0, m_strHelpFile, HELP_FINDER, 0&)

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"OpenFinder"
Resume PROC_EXIT

End Sub

Public Sub RunMacro(strMacro As String)
' Comments : Runs the specified macro in the current help file
' Parameters: strMacro - Name of the macro to run
' Returns : Nothing
' Source : Total VB SourceBook 6
'
Dim lngTemp As Long

On Error GoTo PROC_ERR

lngTemp = WinHelp(0, m_strHelpFile, HELP_COMMAND, strMacro)

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"RunMacro"
Resume PROC_EXIT

End Sub

Public Sub SearchDialog()
' Comments : Opens the current help file with the Search dialog active
' Parameters: None
' Returns : Nothing
' Source : Total VB SourceBook 6
'
Dim lngTemp As Long

On Error GoTo PROC_ERR

lngTemp = WinHelp(0&, m_strHelpFile, HELP_PARTIALKEY, "")

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"SearchDialog"
Resume PROC_EXIT

End Sub

Public Sub SearchFor(strSearch As String)
' Comments : Searches for the specified string in the current
' help file
' Parameters: strSearch - String to search for
' Returns : Nothing
' Source : Total VB SourceBook 6
'
Dim intTemp As Integer

On Error GoTo PROC_ERR

intTemp = WinHelp(0, m_strHelpFile, HELP_PARTIALKEY, strSearch)

PROC_EXIT:
Exit Sub

PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
"SearchFor"
Resume PROC_EXIT

End Sub