home *** CD-ROM | disk | FTP | other *** search
- Option Explicit
- Type POINTAPI
- x As Integer
- y As Integer
- End Type
-
- Global Const SW_SHOWNOACTIVATE = 4
- Global Const SEPARATOR = "/"
- Global Const GWW_HWNDPARENT = -8
-
- Declare Function dwGetPropertyValue Lib "dwspydll.dll" (ByVal hctl&, ByVal propname$, iresptr%) As Variant
- Declare Function dwGetControlHwnd% Lib "dwspydll.dll" (hctl As Control)
- Declare Function dwGetControlHwndByID% Lib "dwspydll.dll" Alias "dwGetControlHwnd" (ByVal hctl&)
- Declare Sub GetCursorPos Lib "user" (lppoint As POINTAPI)
- Declare Function ShowWindow Lib "user" (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
- Declare Function GetActiveWindow% Lib "user" ()
-
- Function ParseString (stringtoparse As String, subindex As Integer) As String
- 'assumes format of string being parsed is correct (a separator
- 'separates each substring), first substring at index 0
- Dim start%, offset%, substringcount%
-
- start% = 1
- offset% = InStr(start%, stringtoparse, SEPARATOR)
-
- Do While (substringcount% < subindex)
- start% = offset% + 1
- substringcount% = substringcount% + 1
- offset% = InStr(start%, stringtoparse, SEPARATOR)
- Loop
-
- ParseString = Mid$(stringtoparse, start%, offset% - start%)
- End Function
-
- Sub ShowToolTip (ByVal hctl&)
- Dim ctlhwnd%, res%
- Dim tagstring$, tipstring$
- Dim tippoint As POINTAPI
- Dim toffset%, loffset%, iresptr%
- Static changecolor%
-
- 'get control hwnd and display tooltip for appropriate control
- If hctl& Then
- 'gets Tag property and parses it, using the first substring
- 'for the status bar help
- tagstring$ = dwGetPropertyValue(hctl&, "Tag", iresptr%)
-
- If (iresptr% = 0) And (Len(tagstring$) > 0) Then
- tipstring$ = ParseString(tagstring$, 1)
- End If
- Else
- ToolTipForm.Hide
- 'reset back to the normal tooltip appearance
- If changecolor Then
- ToolTipForm.BackColor = &H80FFFF
- ToolTipForm!ToolTipLab.BackColor = &H80FFFF
- ToolTipForm!ToolTipLab.ForeColor = 0
- changecolor = False
- End If
- End If
-
- If tipstring$ <> "" Then
- 'the tooltip form is always loaded
- ToolTipForm.ToolTipLab.Caption = tipstring$
- 'calculate position of the form
- GetCursorPos tippoint
- toffset% = 18: loffset% = -2 'offsets to cursor
- ToolTipForm.Top = (tippoint.y + toffset%) * Screen.TwipsPerPixelY
- ToolTipForm.Left = (tippoint.x + loffset%) * Screen.TwipsPerPixelX
- ToolTipForm.Width = ToolTipForm.ToolTipLab.Width + (4 * Screen.TwipsPerPixelX)
- ToolTipForm.Height = ToolTipForm.ToolTipLab.Height + (2 * Screen.TwipsPerPixelY)
- ToolTipForm.ZOrder 'place on top of zorder
-
- 'Under certain conditions, we can change the
- 'ToolTip appearance
- tipstring$ = UCase$(ParseString(tagstring$, 2))
- If tipstring$ = "WARNING" Then
- 'display different background and foreground colors
- ToolTipForm.BackColor = &HFF
- ToolTipForm!ToolTipLab.BackColor = &HFF
- ToolTipForm!ToolTipLab.ForeColor = &HFFFFFF
- changecolor = True
- End If
-
- 'do not activate the tooltip form after displaying it
- res% = ShowWindow(ToolTipForm.hWnd, SW_SHOWNOACTIVATE)
- Else
- ToolTipForm.Hide
- 'reset back to the normal tooltip appearance
- If changecolor Then
- ToolTipForm.BackColor = &H80FFFF
- ToolTipForm!ToolTipLab.BackColor = &H80FFFF
- ToolTipForm!ToolTipLab.ForeColor = 0
- changecolor = False
- End If
- End If
- End Sub
-
- Sub UpdateStatusBar (ByVal hctl&, statusbar As Control)
- 'Gets the status help text from the control's tag property,
- 'also assume statusbar is a label control
- Dim statusstring$
- Dim iresptr%
-
- If hctl& = 0 Then 'clear status bar
- statusbar.Caption = ""
- Exit Sub
- End If
-
- 'gets Tag property and parses it, using the first substring
- 'for the status bar help
- statusstring$ = dwGetPropertyValue(hctl&, "Tag", iresptr%)
-
- If (iresptr% = 0) And (Len(statusstring$) > 0) Then
- 'get first substring
- statusstring$ = ParseString(statusstring$, 0)
- statusbar.Caption = statusstring$
- Else
- statusbar.Caption = ""
- End If
- End Sub
-
-