home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axdata / contxtid.bas < prev    next >
Encoding:
BASIC Source File  |  1999-02-03  |  11.1 KB  |  255 lines

  1. Attribute VB_Name = "ContextIDs"
  2. Option Explicit
  3. '=====================================================================
  4. '=====================================================================
  5. '
  6. 'This source code contains the following routines:
  7. '  o SetAppHelp() 'Called in the main Form_Load event to register your
  8. '                 'program with WINHELP.EXE
  9. '  o QuitHelp()    'Deregisters your program with WINHELP.EXE. Should
  10. '                  'be called in your main Form_Unload event
  11. '  o ShowHelpTopic(Topicnum) 'Brings up context sensitive help based on
  12. '                  'any of the following CONTEXT IDs
  13. '  o ShowContents  'Displays the startup topic
  14. '  o HelpWindowSize(x,y,dx,dy) ' Position help window in a screen
  15. '                              ' independent manner
  16. '  o SearchHelp()  'Brings up the windows help KEYWORD SEARCH dialog box
  17. '***********************************************************************
  18. '
  19. '=====================================================================
  20. 'List of Context IDs for <axData>
  21. '=====================================================================
  22. Global Const Hlp_Contents = 10    'Main Help Window
  23. Global Const Hlp_Overview = 20    'Main Help Window
  24. Global Const Hlp_Revisions = 30    'Main Help Window
  25. Global Const Hlp_License = 40    'Main Help Window
  26. Global Const Hlp_Tech_Support = 50    'Main Help Window
  27. Global Const Hlp_Properties = 60    'Main Help Window
  28. Global Const Hlp_Methods = 70    'Main Help Window
  29. Global Const Hlp_Events = 80    'Main Help Window
  30. Global Const Hlp_Installation = 90    'Main Help Window
  31. '=====================================================================
  32. '
  33. '
  34. '  Help engine section.
  35.  
  36. ' Commands to pass WinHelp()
  37. Global Const HELP_CONTEXT = &H1 '  Display topic in ulTopic
  38. Global Const HELP_QUIT = &H2    '  Terminate help
  39. Global Const HELP_FINDER = &HB  '  Display Contents tab
  40. Global Const HELP_INDEX = &H3   '  Display index
  41. Global Const HELP_HELPONHELP = &H4      '  Display help on using help
  42. Global Const HELP_SETINDEX = &H5        '  Set the current Index for multi index help
  43. Global Const HELP_KEY = &H101           '  Display topic for keyword in offabData
  44. Global Const HELP_MULTIKEY = &H201
  45. Global Const HELP_CONTENTS = &H3     ' Display Help for a particular topic
  46. Global Const HELP_SETCONTENTS = &H5  ' Display Help contents topic
  47. Global Const HELP_CONTEXTPOPUP = &H8 ' Display Help topic in popup window
  48. Global Const HELP_FORCEFILE = &H9    ' Ensure correct Help file is displayed
  49. Global Const HELP_COMMAND = &H102    ' Execute Help macro
  50. Global Const HELP_PARTIALKEY = &H105 ' Display topic found in keyword list
  51. Global Const HELP_SETWINPOS = &H203  ' Display and position Help window
  52.  
  53. #If Win32 Then
  54.     Type HELPWININFO
  55.       wStructSize As Long
  56.       X As Long
  57.       Y As Long
  58.       dX As Long
  59.       dY As Long
  60.       wMax As Long
  61.       rgChMember As String * 2
  62.     End Type
  63.     Declare Function WinHelp Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Any) As Long
  64.     Declare Function WinHelpByInfo Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, dwData As HELPWININFO) As Long
  65.     Declare Function WinHelpByStr Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData$) As Long
  66.     Declare Function WinHelpByNum Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData&) As Long
  67.     Dim m_hWndMainWindow as Long ' hWnd to tell WINHELP the helpfile owner
  68.  
  69. #Else
  70.     Type HELPWININFO
  71.         wStructSize As Integer
  72.         X As Integer
  73.         Y As Integer
  74.         dX As Integer
  75.         dY As Integer
  76.         wMax As Integer
  77.         rgChMember As String * 2
  78.     End Type
  79.     Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData As Any) As Integer
  80.     Declare Function WinHelpByInfo Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, dwData As HELPWININFO) As Integer
  81.     Declare Function WinHelpByStr Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData$) As Integer
  82.     Declare Function WinHelpByNum Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData&) As Integer
  83.     Dim m_hWndMainWindow as Integer ' hWnd to tell WINHELP the helpfile owner
  84.  
  85. #End If
  86. Dim MainWindowInfo as HELPWININFO
  87. Sub SetAppHelp (ByVal hWndMainWindow)
  88. '=====================================================================
  89. 'To use these subroutines to access WINHELP, you need to add
  90. 'at least this one subroutine call to your code
  91. '     o  In the Form_Load event of your main Form enter:
  92. '        Call SetAppHelp(Me.hWnd) 'To setup helpfile variables
  93. '         (If you are not interested in keyword searching or context
  94. '         sensitive help, this is the only call you need to make!)
  95. '=====================================================================
  96.     m_hWndMainWindow = hWndMainWindow
  97.     If Right$(Trim$(App.Path),1) = "\" then
  98.         App.HelpFile = App.Path + "axData.HLP"
  99.     else
  100.         App.HelpFile = App.Path + "\axData.HLP"
  101.     end if
  102. #If Win32 Then
  103.     MainWindowInfo.wStructSize = 26
  104. #Else
  105.     MainWindowInfo.wStructSize = 14
  106. #End If 
  107.     MainWindowInfo.X=256
  108.     MainWindowInfo.Y=256
  109.     MainWindowInfo.dX=512
  110.     MainWindowInfo.dY=512
  111.     MainWindowInfo.rgChMember=Chr$(0)+Chr$(0)
  112. End Sub
  113. Sub QuitHelp ()
  114.     Dim Result as Variant
  115.     Result = WinHelp(m_hWndMainWindow, App.HelpFile, HELP_QUIT, Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0))
  116. End Sub
  117. Sub ShowHelpTopic (ByVal ContextID As Long)
  118. '=====================================================================
  119. '  FOR CONTEXT SENSITIVE HELP IN RESPONSE TO A COMMAND BUTTON ...
  120. '=====================================================================
  121. '     o   For 'Help button' controls, you can call:
  122. '         Call ShowHelpTopic(<any Hlpxxx entry above>)
  123. '=====================================================================
  124. '  TO ADD FORM LEVEL CONTEXT SENSITIVE HELP...
  125. '=====================================================================
  126. '     o  For FORM level context sensetive help, you should set each 
  127. '        Me.HelpContext=<any Hlp_xxx entry above>
  128. '
  129.     Dim Result as Variant
  130.  
  131.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXT, Clng(ContextID))
  132.  
  133. End Sub
  134. Sub ShowHelpTopic2 (ByVal ContextID As Long)
  135. '=====================================================================
  136. '  DISPLAY CONTEXT SENSITIVE HELP IN WINDOW 2 ...
  137. '=====================================================================
  138. '     o   For 'Help button' controls, you can call:
  139. '         Call ShowHelpTopic2(<any Hlpxxx entry above>)
  140. '
  141.     Dim Result as Variant
  142.  
  143.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile &">HlpWnd02", HELP_CONTEXT, Clng(ContextID))
  144.  
  145. End Sub
  146. Sub ShowHelpTopic3 (ByVal ContextID As Long)
  147. '=====================================================================
  148. '  DISPLAY CONTEXT SENSITIVE HELP IN WINDOW 3 ...
  149. '=====================================================================
  150. '     o   For 'Help button' controls, you can call:
  151. '         Call ShowHelpTopic3(<any Hlpxxx entry above>)
  152. '
  153.     Dim Result as Variant
  154.  
  155.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile &">HlpWnd03", HELP_CONTEXT, Clng(ContextID))
  156.  
  157. End Sub
  158. Sub ShowGlossary ()
  159.     Dim Result as Variant
  160.  
  161.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXT, Clng(64000))
  162.  
  163. End Sub
  164. Sub ShowPopupHelp (ByVal ContextID As Long)
  165. '=====================================================================
  166. '  FOR POPUP HELP IN RESPONSE TO A COMMAND BUTTON ...
  167. '=====================================================================
  168.     Dim Result as Variant
  169.  
  170.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXTPOPUP, Clng(ContextID))
  171.  
  172. End Sub
  173. Sub DoHelpMacro (ByVal MacroString As String)
  174. '=====================================================================
  175. '  FOR POPUP HELP IN RESPONSE TO A COMMAND BUTTON ...
  176. '=====================================================================
  177.     Dim Result as Variant
  178.  
  179.     Result = WinHelpByStr(m_hWndMainWindow, APP.HelpFile, HELP_COMMAND, ByVal(Macrostring))
  180.  
  181. End Sub
  182. Sub ShowHelpContents ()
  183. '=====================================================================
  184. '  DISPLAY STARTUP TOPIC IN RESPONSE TO A COMMAND BUTTON or MENU ...
  185. '=====================================================================
  186. '
  187.     Dim Result as Variant
  188.  
  189.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTENTS, Clng(0))
  190.  
  191. End Sub
  192. Sub ShowContentsTab ()
  193. '=====================================================================
  194. '  DISPLAY Contents tab (*.CNT)
  195. '=====================================================================
  196. '
  197.     Dim Result as Variant
  198.  
  199.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_FINDER, Clng(0))
  200.  
  201. End Sub
  202. Sub ShowHelpOnHelp ()
  203. '=====================================================================
  204. '  DISPLAY HELP for WINHELP.EXE  ...
  205. '=====================================================================
  206. '
  207.     Dim Result as Variant
  208.  
  209.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_HELPONHELP, Clng(0))
  210.  
  211. End Sub
  212.  
  213. Sub SearchHelp ()
  214. '=====================================================================
  215. '  TO ADD KEYWORD SEARCH CAPABILITY...
  216. '=====================================================================
  217. '     o   In your Help|Search menu selection, simply enter:
  218. '         Call SearchHelp() 'To invoke helpfile keyword search dialog
  219. '
  220.     Dim Result as Variant
  221.  
  222.     Result = WinHelp(m_hWndMainWindow, APP.HelpFile, HELP_PARTIALKEY, ByVal "" )
  223.  
  224. End Sub
  225.  
  226. Sub SearchHelpKeyWord (Argument as String)
  227. '=====================================================================
  228. '  TO ADD KEYWORD SEARCH CAPABILITY...
  229. '=====================================================================
  230. '     o   In your Help|Search menu selection, simply enter:
  231. '         Call SearchHelp() 'To invoke helpfile keyword search dialog
  232. '
  233.     Dim Result as Variant
  234.  
  235.     Result = WinHelp(m_hWndMainWindow, APP.HelpFile, HELP_PARTIALKEY, ByVal Trim$(Argument))
  236.  
  237. End Sub
  238. Sub HelpWindowSize (x As Integer, y As Integer, wx As Integer, wy As Integer)
  239. '=====================================================================
  240. '  TO SET THE SIZE AND POSITION OF THE MAIN HELP WINDOW...
  241. '=====================================================================
  242. '     o   Call HelpWindowSize(x, y, dx, dy), where:
  243. '             x = 1-1024 (position from left edge of screen)
  244. '             y = 1-1024 (position from top of screen)
  245. '             dx= 1-1024 (width)
  246. '             dy= 1-1024 (height)
  247. '
  248.     Dim Result as Variant
  249.     MainWindowInfo.x = x
  250.     MainWindowInfo.y = y
  251.     MainWindowInfo.dx = wx
  252.     MainWindowInfo.dy = wy
  253.     Result = WinHelpByInfo(m_hWndMainWindow, App.HelpFile, HELP_SETWINPOS, MainWindowInfo)
  254. End Sub
  255.