-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathViToolTip.cls
73 lines (55 loc) · 1.69 KB
/
ViToolTip.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ViToolTip"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private m_toolTipHwnd As Long
Private m_parenthWnd As Long
Public Property Get hWnd() As Long
hWnd = m_toolTipHwnd
End Property
Public Sub Hide()
SendMessage ByVal m_toolTipHwnd, ByVal TTM_POP, ByVal 0, ByVal 0
End Sub
Public Sub Show()
End Sub
Public Sub AttachWindow(ByVal hWnd As Long)
m_parenthWnd = hWnd
SetOwner m_toolTipHwnd, hWnd
'm_toolTipHwnd = CreateWindowEx(0, _
"tooltips_class32", "", _
0, 5, 5, 200, 200, m_parenthWnd, 0, 0, ByVal 0)
End Sub
Private Sub Class_Initialize()
m_toolTipHwnd = CreateWindowEx(0, _
"tooltips_class32", "", _
0, 0, 0, 0, 0, 0, 0, 0, ByVal 0)
SendMessage ByVal m_toolTipHwnd, ByVal TTM_SETDELAYTIME, 1, 500
SetWindowPos m_toolTipHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE
End Sub
Public Sub SetToolTip(ByVal szToolTipText As String)
Dim udtTool As TOOLINFO
' add control
With udtTool
.cbSize = Len(udtTool)
.hWnd = m_parenthWnd
.uFlags = TTF_IDISHWND Or TTF_SUBCLASS
.uId = m_parenthWnd
.lpszText = szToolTipText
End With
SendMessage ByVal m_toolTipHwnd, ByVal TTM_ADDTOOLA, ByVal 0, udtTool
End Sub
Private Sub Class_Terminate()
If m_toolTipHwnd <> 0 Then
DestroyWindow m_toolTipHwnd
End If
End Sub