-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDockPopup.frm
More file actions
179 lines (131 loc) · 5.57 KB
/
DockPopup.frm
File metadata and controls
179 lines (131 loc) · 5.57 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
VERSION 5.00
Begin VB.Form DockPopup
AutoRedraw = -1 'True
BackColor = &H00000000&
BorderStyle = 0 'None
Caption = "Form1"
ClientHeight = 945
ClientLeft = 0
ClientTop = 0
ClientWidth = 17430
LinkTopic = "Form1"
ScaleHeight = 63
ScaleMode = 3 'Pixel
ScaleWidth = 1162
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "DockPopup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_graphics As GDIPGraphics
Private m_layeredWindowProperties As LayerdWindowHandles
Private m_backgroundImage As GDIPImage
Private m_Path As GDIPGraphicPath
Private m_textPosition As gdiplus.POINTF
Private m_caption As String
Private m_centerX As Long
Private m_pointerPosition As Long
Private m_slices As Collection
Private m_pointerSlice As Slice
Private m_pointerY As Long
Public Function ShowTextPopup(ByVal theText As String, X As Long)
'Me.Hide
Debug.Print "Showing Text Popup: " & theText
Dim ms As gdiplus.RECTF
Dim BorderWidth As Long: BorderWidth = FindBorderWidth(m_slices) * 2
Dim borderHeight As Long: borderHeight = FindBorderHeight(m_slices) * 2
Dim proposedHeight As Long
ms = m_graphics.MeasureString(theText, AppDefaultFont)
Debug.Print "MeasureStringWidth:: " & m_graphics.MeasureStringWidth(theText, AppDefaultFont)
Me.Width = (ms.Width + BorderWidth) * Screen.TwipsPerPixelX
proposedHeight = (ms.Height + borderHeight - 15)
If proposedHeight < borderHeight Then
proposedHeight = borderHeight
End If
Me.Height = proposedHeight * Screen.TwipsPerPixelY
Me.Left = (X * Screen.TwipsPerPixelX)
m_centerX = (Me.ScaleWidth / 2)
Me.Left = Me.Left - (m_centerX * Screen.TwipsPerPixelX)
m_pointerPosition = m_centerX - (m_pointerSlice.Image.Width / 2)
If Me.Left + Me.Width > Screen.Width Then
m_pointerPosition = m_pointerPosition + (Me.Left - (Screen.Width - Me.Width)) / Screen.TwipsPerPixelX
Me.Left = Screen.Width - Me.Width
End If
If (Me.ScaleWidth - m_pointerPosition) < 42 Then
m_pointerPosition = Me.ScaleWidth - 42
End If
m_caption = theText
InitializeGraphics
Repaint
'ShowWindow Me.hWnd, SW_SHOWNOACTIVATE
Me.Show
End Function
Private Sub PreparePath()
'm_path.AddString "Test", FontHelper.AppFontFamily, fontStyle.FontStyleRegular, 14, m_textPosition, StringFormatFlagsNoWrap
End Sub
Private Sub Form_Initialize()
m_textPosition.X = 30
m_textPosition.Y = 27
m_caption = "{no text}"
StayOnTop Me, True
Set m_layeredWindowProperties = MakeLayerdWindow(Me)
Set m_backgroundImage = New GDIPImage
Set m_Path = New GDIPGraphicPath
Set m_slices = SliceHelper.CreateSlicesFromXML("tooltip", m_backgroundImage)
If ExistInCol(m_slices, "pointer") Then
Set m_pointerSlice = m_slices("pointer")
m_pointerY = m_backgroundImage.Height - m_pointerSlice.Y
End If
InitializeGraphics
Repaint
End Sub
Private Function InitializeGraphics()
If Not m_graphics Is Nothing Then
If Not m_layeredWindowProperties Is Nothing Then
m_graphics.ReleaseHDC m_layeredWindowProperties.theDC
m_layeredWindowProperties.Release
End If
End If
Set m_layeredWindowProperties = MakeLayerdWindow(Me)
Set m_graphics = New GDIPGraphics
m_graphics.FromHDC m_layeredWindowProperties.theDC
m_graphics.TextRenderingHint = TextRenderingHintClearTypeGridFit
m_graphics.SmoothingMode = SmoothingModeHighQuality
m_graphics.PixelOffsetMode = PixelOffsetModeHighQuality
'm_graphics.CompositingMode = CompositingModeSourceCopy
'm_graphics.CompositingQuality = CompositingQualityHighQuality
m_graphics.InterpolationMode = InterpolationModeNearestNeighbor
'm_graphics.
End Function
Sub Repaint()
m_graphics.Clear
'm_graphics.DrawImage m_backgroundImage, 0, 0, m_backgroundImage.Width, m_backgroundImage.Height
Dim pointerArea As gdiplus.RECTF
If Not m_pointerSlice Is Nothing Then
If Not m_pointerSlice.Image Is Nothing Then
pointerArea = CreateRectF(CSng(m_pointerPosition), CSng(m_pointerY), CSng(m_pointerSlice.Image.Height), CSng(m_pointerSlice.Image.Width))
End If
End If
m_graphics.Exclude pointerArea
SliceHelper.DrawSlices m_slices, m_graphics, Me
If Not m_pointerSlice Is Nothing Then
'm_graphics.DrawRectangle SolidBlackPen, 0, 0, 30, 30
m_graphics.ResetExclusions
'm_graphics.DrawImage m_pointerSlice.Image, m_centerX - (m_pointerSlice.Image.Width / 2), Me.ScaleHeight - m_pointerSlice.Image.Height - 1, m_pointerSlice.Image.Width, m_pointerSlice.Image.Height
m_graphics.DrawImageRectF m_pointerSlice.Image, pointerArea
End If
m_graphics.DrawString m_caption, AppDefaultFont, FontHelper.GetBlackBrush, m_textPosition
m_layeredWindowProperties.Update Me.hWnd, m_layeredWindowProperties.theDC
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not m_graphics Is Nothing And Not m_layeredWindowProperties Is Nothing Then
m_graphics.ReleaseHDC m_layeredWindowProperties.theDC
m_layeredWindowProperties.Release
End If
'FontHelper.Dispose
'GDIPlusDispose
End Sub