home *** CD-ROM | disk | FTP | other *** search
/ BUG 6 / BUGCD1997_09.BIN / UTIL / ADDZIP / ADDZIP.EXE / VB / QUICKZIP / TTIPS.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-06-01  |  2.5 KB  |  97 lines

  1. Const TIPS_SW_SHOWNOACTIVATE = 4
  2. Const TIPS_XGW_CHILD = 5         ' Needed for edit portion of combo box
  3.  
  4. Type TIPS_POINTAPI  '4 Bytes - Synonymous with LONG
  5.         x As Integer
  6.         y As Integer
  7. End Type
  8.  
  9. Type tooltip_type
  10.     hWnd As Long
  11.     Tip As String
  12. End Type
  13.  
  14. Declare Sub GetCursorPos Lib "User" (lpPoint As TIPS_POINTAPI)
  15. Declare Function GetActiveWindow Lib "User" () As Integer
  16. Declare Function WindowFromPoint Lib "user" (ByVal lpPointY As Integer, ByVal lpPointX As Integer) As Integer
  17. Declare Function GetWindow Lib "User" (ByVal hWnd As Integer, ByVal wCmd As Integer) As Integer
  18. Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
  19.  
  20.  
  21.  
  22.  
  23. Global gtooltip() As tooltip_type
  24.  
  25. Sub AddTip (ByVal hWnd As Long, ByVal Tip As String)
  26. x = UBound(gtooltip) + 1
  27.  
  28. ReDim Preserve gtooltip(x) As tooltip_type
  29. gtooltip(x).hWnd = hWnd
  30. gtooltip(x).Tip = Tip
  31. End Sub
  32.  
  33. Sub DisplayTips ()
  34. Static LastHwnd As Long
  35. Dim p As TIPS_POINTAPI
  36.  
  37. GetCursorPos p
  38. CurHwnd = WindowFromPoint(p.y, p.x)
  39.  
  40. If LastHwnd = CurHwnd Then Exit Sub
  41.  
  42. LastHwnd = CurHwnd
  43.  
  44. For a = LBound(gtooltip) To UBound(gtooltip)
  45.     If CurHwnd = gtooltip(a).hWnd And gtooltip(a).Tip <> "" Then
  46.         TTips.Tip = gtooltip(a).Tip
  47.         Theight = TTips.Tip.Height
  48.         TWidth = TTips.Tip.Width
  49.         TTips.Tip.AutoSize = False
  50.         TTips.Tip.Width = TWidth + 15
  51.         TTips.Tip.Height = Theight + 16
  52.         TTips.Top = (p.y + 18) * Screen.TwipsPerPixelY
  53.         TTips.Left = (p.x - 2) * Screen.TwipsPerPixelY
  54.         TTips.Height = TTips.Tip.Height
  55.         TTips.Width = TTips.Tip.Width
  56.         '----------------------------------------
  57.         TTips.ZOrder
  58.         ' Show form without the focus:
  59.         ret = ShowWindow(TTips.hWnd, TIPS_SW_SHOWNOACTIVATE)
  60.         If (frmQuickZIP.mnuOptionsOnTop.Checked = True) Then
  61.           I% = SetWindowPos(TTips.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS Or 16)
  62.         End If
  63.  
  64.         Exit Sub
  65.     End If
  66.     
  67.     TTips.Hide
  68.     ' Help on StatBar
  69.     TTips.Tip.AutoSize = True
  70. Next a
  71.  
  72.  
  73.  
  74. End Sub
  75.  
  76. Sub InitializeTips ()
  77. ReDim gtooltip(0) As tooltip_type
  78. End Sub
  79.  
  80. Sub removeTip (ByVal hWnd As Long)
  81. Dim a, b, u As Integer
  82.  
  83. up = UBound(gtooltip)
  84.  
  85. For a = LBound(gtooltip) To up
  86.     If gtooltip(a).hWnd = hWnd Then
  87.         For b = a + 1 To up
  88.             gtooltip(b - 1).hWnd = gtooltip(b).hWnd
  89.             gtooltip(b - 1).Tip = gtooltip(b).Tip
  90.         Next b
  91.         ReDim Preserve gtooltip(up - 1) As tooltip_type
  92.         Exit For
  93.      End If
  94. Next a
  95. End Sub
  96.  
  97.