home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch21code / help.cls < prev    next >
Text File  |  1995-08-14  |  3KB  |  113 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Help"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. ' Help class -- HELP.CLS
  9. '   Provides access to WinAPI Help functions.
  10. '
  11. '   Properties
  12. '       OnTop (Read/Write)
  13. '       hWnd (Read/Write)
  14. '       FileName (Read/Write)
  15. '       Keyword (Read/Write)
  16. '
  17. '   Methods
  18. '       Show
  19. '
  20. Option Explicit
  21.  
  22. #If Win16 Then
  23. '   Help engine declarations.
  24. Private Declare Function WinHelp Lib "User" _
  25.     (ByVal hwnd As Integer, _
  26.     ByVal lpszFileName As String, _
  27.     ByVal wCmd As Integer, _
  28.     dwData As Any) As Integer
  29. ' Win API declaration and constants used by OnTop property.
  30. Private Declare Sub SetWindowPos Lib "User" _
  31.     (ByVal hwnd As Integer, _
  32.     ByVal hWndInsertAfter As Integer, _
  33.     ByVal x As Integer, ByVal y As Integer, _
  34.     ByVal cx As Integer, ByVal cy As Integer, _
  35.     ByVal wFlags As Integer)
  36. #Else
  37. Private Declare Function SetWindowPos Lib "user32" _
  38.     (ByVal hwnd As Long, _
  39.     ByVal hWndInsertAfter As Long, _
  40.     ByVal x As Long, _
  41.     ByVal y As Long, _
  42.     ByVal cx As Long, _
  43.     ByVal cy As Long, _
  44.     ByVal wFlags As Long) As Long
  45. Private Declare Function WinHelp Lib "user32" _
  46.     Alias "WinHelpA" (ByVal hwnd As Long, _
  47.     ByVal lpHelpFile As String, _
  48.     ByVal wCommand As Long, _
  49.     ByVal dwData As Long) As Long
  50. #End If
  51. '  Commands to pass WinHelp()
  52. Const HELP_CONTEXT = &H1          '  Display topic in ulTopic
  53. Const HELP_QUIT = &H2             '  Terminate help
  54. Const HELP_INDEX = &H3            '  Display index
  55. Const HELP_HELPONHELP = &H4       '  Display help on using help
  56. Const HELP_SETINDEX = &H5         '  Set current Index for multi index help
  57. Const HELP_KEY = &H101            '  Display topic for keyword in offabData
  58. Const HELP_PARTIALKEY = &H105&
  59. Const HELP_MULTIKEY = &H201&
  60. ' Constants for SetWindowPos
  61. Const SWP_NOACTIVATE = &H10
  62. Const SWP_SHOWWINDOW = &H40
  63. Const SWP_NOSIZE = &H1
  64. Const SWP_NOMOVE = &H2
  65. Const HWND_TOPMOST = -1
  66. Const HWND_NOTOPMOST = -2
  67.  
  68. ' Flag used by OnTop property to track window state.
  69. Dim mbOnTop As Boolean
  70.  
  71. ' Help properties.
  72. Public hwnd As Integer
  73. Public FileName As String
  74. Public Keyword As String
  75.  
  76. Public Sub Show()
  77.     Dim Temp
  78.     Temp = WinHelp(hwnd, FileName, _
  79.         HELP_KEY, ByVal Keyword)
  80. End Sub
  81.  
  82.  
  83. ' Assigns the OnTop property.
  84. Property Let OnTop(bSetting As Boolean)
  85.      ' If True, Form is displayed as always on top.
  86.     If bSetting Then
  87.         SetWindowPos hwnd, _
  88.             HWND_TOPMOST, _
  89.             0, 0, 0, 0, _
  90.             SWP_NOSIZE Or SWP_NOMOVE _
  91.             Or SWP_NOACTIVATE Or SWP_SHOWWINDOW
  92.          ' Set flag to keep track of window state.
  93.          mbOnTop = True
  94.     ' If False, Form is displayed normally.
  95.     Else
  96.         SetWindowPos hwnd, _
  97.             HWND_NOTOPMOST, _
  98.             0, 0, 0, 0, _
  99.             SWP_NOSIZE Or SWP_NOMOVE _
  100.             Or SWP_NOACTIVATE
  101.         ' Set flag to keep track of window state.
  102.         mbOnTop = False
  103.     End If
  104. End Property
  105.  
  106. ' Returns True if the form is displayed as always on top,
  107. ' otherwise returns false.
  108. Property Get OnTop() As Boolean
  109.     ' Return the value of the flag set by Property Let.
  110.     OnTop = mbOnTop
  111. End Property
  112.  
  113.