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

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