17. december 2001 - 20:52
#2
Man kan selvfølgelig tilskrive toolbar objektet direkte, men så skal commonctrl.ocx objektet vel installeres samtidig. Mere bøvl.
Fandens osse - bare fordi en EDBmongol ikke mener, hans fæller ikke kan huske at trykke F1 for hjælp, men abs skal have \'HJÆLP\' på toolbaren.
Har Terry en løsning eller skal jeg ned og skrive i registreringsdatabasen ?
Henrik
18. december 2001 - 13:48
#6
Jesper - her i julen skal man ikke være karrig med at dele ud af det, man har, så her er min egen løsning på problemet, der bygger på en klasse, der kalder windows APIen:
Dette placeres i et public modul:
Public Sub cmd_Vis_Help()
Dim HelpTest As CWinHelp
Dim lngContextID As Long
Dim lngCounter As Long
\' Create a new instance of the class
Set HelpTest = New CWinHelp
\' Point to the help file for the(windows) help FILE
Const cstrHelpFile = \"Henrikshelp.HLP\"
HelpTest.HelpFile = cstrHelpFile
\' Use the OpenContext method to display the topic associated
\' with Help Context ID #1
lngContextID = 1
HelpTest.OpenContext lngContextID
\' Display the help file for using Help.
\'HelpTest.HelpOnHelp
\' Open the help file to the default page.
\'HelpTest.OpenDefaultPage
\' Open the help file with the Contents page active
\'HelpTest.OpenContentsTab
\' Open the help file with the Index tab active
\'HelpTest.OpenIndexTab
\' Open the help file with the Index tab active,
\' and puts the supplies the word \"Buttons\" as the
\' search phrase.
\'HelpTest.OpenIndexTabWithSearch \"Buttons\"
\' Finally, open the help file with the Find tab
\' active.
\'HelpTest.OpenFindTab
\' Run the macro called MyTest. Uncomment this line
\' after supplying a valid macro name
\' HelpTest.RunMacro \"MyTest()\"
\' Mark the help file as closed.
\'HelpTest.CloseFile
\'Set HelpTest = Nothing
End Sub
Dette proppes ind i et klassemodul:
Option Compare Database
Option Explicit
\' Class : CWinHelp
\' Description : Code for working with Windows Help files
\' 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_TAB = &HF&
Private Const HELP_COMMAND = &H102
Private Const HELP_PARTIALKEY = &H105
Private Const HELP_FINDER = &HB&
\' Constants to define the tabs of the WinHelp dialog
Private Const TB_CONTENTS = 0
Private Const TB_INDEX = -2
Private Const TB_FIND = -1
\' 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 Declare Function WinHelpTabs Lib \"user32\" _
Alias \"WinHelpA\" _
(ByVal hWnd As Long, _
ByVal lpHelpFile As String, _
ByVal wCommand As Long, _
ByVal dwData As Long) _
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
\'
HelpFile = m_strHelpFile
End Property
Public Property Let HelpFile(strValue As String)
\' strValue - Name of the help file to use.
\'
m_strHelpFile = strValue
End Property
Public Sub CloseFile()
\' Comments : Marks the current help file as closed
\' Parameters: None
\' Returns : Nothing
\'
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
\'
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 OpenContentsTab()
\' Comments : Opens the Contents tab of the current help file
\' Parameters: None
\' Returns : Nothing
\'
Dim lngTemp As Long
On Error GoTo PROC_ERR
lngTemp = WinHelpTabs(0, m_strHelpFile, HELP_TAB, TB_CONTENTS)
PROC_EXIT:
Exit Sub
PROC_ERR:
MsgBox \"Error: \" & Err.Number & \". \" & Err.Description, , _
\"OpenContentsTab\"
Resume PROC_EXIT
End Sub
Public Function OpenContext(lngContextID As Long) As Boolean
\' Comments : Opens the specified Help context in the current help file
\' Parameters: Nothing
\' Returns : None
\'
Dim lngTemp As Long
On Error GoTo PROC_ERR
lngTemp = WinHelp(0, m_strHelpFile, HELP_CONTEXT, lngContextID)
OpenContext = (lngTemp = 0)
PROC_EXIT:
Exit Function
PROC_ERR:
MsgBox \"Error: \" & Err.Number & \". \" & Err.Description, , _
\"OpenContext\"
Resume PROC_EXIT
End Function
Public Sub OpenDefaultPage()
\' Comments : Opens the default page of the current help file
\' Parameters: None
\' Returns : Nothing
\'
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, , _
\"OpenDefaultPage\"
Resume PROC_EXIT
End Sub
Public Sub OpenFindTab()
\' Comments : Opens the Find tab of the current help file
\' Parameters: None
\' Returns : Nothing
\'
Dim lngTemp As Long
On Error GoTo PROC_ERR
lngTemp = WinHelpTabs(0, m_strHelpFile, HELP_TAB, TB_FIND)
PROC_EXIT:
Exit Sub
PROC_ERR:
MsgBox \"Error: \" & Err.Number & \". \" & Err.Description, , _
\"OpenFindTab\"
Resume PROC_EXIT
End Sub
Public Sub OpenIndexTab()
\' Comments : Opens the current help file with the Index tab active
\' Parameters: None
\' Returns : Nothing
\'
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, , _
\"OpenIndexTab\"
Resume PROC_EXIT
End Sub
Public Sub OpenIndexTabWithSearch(strSearch As String)
\' Comments : Opens the specified help file to the Index tab
\' and supplies the specified search string as the
\' Help search string
\' Parameters: strSearch - String to search for
\' Returns : Nothing
\'
Dim lngTemp As Long
On Error GoTo PROC_ERR
lngTemp = WinHelp(0, m_strHelpFile, HELP_PARTIALKEY, strSearch)
PROC_EXIT:
Exit Sub
PROC_ERR:
MsgBox \"Error: \" & Err.Number & \". \" & Err.Description, , _
\"OpenIndexTabWithSearch\"
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
\'
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
--------------
Man kan selvfølgelig kalde klassen fra en knaps klikfunktion eller i mit tilfælde fra en knap på Custom baren i.e. en hjælpefilicon.
Højreklik på iconen og under egenskaber -> ved handling indesættes: cmd_Vis_Help
----
Ded var ded - hav en god dag
Henrik