@@ -65,7 +65,7 @@ Attribute VB_Exposed = False
65
65
'=========================================================================
66
66
Option Explicit
67
67
DefObj A-Z
68
- Private Const STR_MODULE_NAME As String = "AlphaBlendTabStrip"
68
+ Private Const MODULE_NAME As String = "AlphaBlendTabStrip"
69
69
70
70
'=========================================================================
71
71
' Events
@@ -83,7 +83,7 @@ Private Declare Function OleTranslateColor Lib "oleaut32" (ByVal lOleColor As Lo
83
83
'--- GDI+
84
84
Private Declare Function GdipCreateSolidFill Lib "gdiplus " (ByVal argb As Long , hBrush As Long ) As Long
85
85
Private Declare Function GdipSetSolidFillColor Lib "gdiplus " (ByVal hBrush As Long , ByVal argb As Long ) As Long
86
- Private Declare Function GdipFillRectangleI Lib "gdiplus " (ByVal hGraphics As Long , ByVal hBrush As Long , ByVal lX As Long , ByVal lY As Long , ByVal lWidth As Long , ByVal lHeight As Long ) As Long
86
+ Private Declare Function GdipFillRectangle Lib "gdiplus " (ByVal hGraphics As Long , ByVal hBrush As Long , ByVal sngX As Single , ByVal sngY As Single , ByVal sngWidth As Single , ByVal sngHeight As Single ) As Long
87
87
Private Declare Function GdipDeleteBrush Lib "gdiplus " (ByVal hBrush As Long ) As Long
88
88
89
89
'=========================================================================
@@ -107,7 +107,11 @@ End Type
107
107
'=========================================================================
108
108
109
109
Private Function PrintError (sFunction As String ) As VbMsgBoxResult
110
- Debug.Print "Critical error: " & Err.Description & " [" & STR_MODULE_NAME & "." & sFunction & "]" , Timer
110
+ #If USE_DEBUG_LOG <> 0 Then
111
+ DebugLog MODULE_NAME, sFunction & "(" & Erl & ")" , Err.Description & " &H" & Hex$(Err.Number), vbLogEventTypeError
112
+ #Else
113
+ Debug.Print "Critical error: " & Err.Description & " [" & MODULE_NAME & "." & sFunction & "]"
114
+ #End If
111
115
End Function
112
116
113
117
'=========================================================================
@@ -166,6 +170,10 @@ Property Let TabCaption(ByVal Index As Long, sValue As String)
166
170
pvResizeTabs
167
171
End Property
168
172
173
+ Property Get TabCount() As Long
174
+ TabCount = UBound(m_aTabCaptions) + 1
175
+ End Property
176
+
169
177
'=========================================================================
170
178
' Methods
171
179
'=========================================================================
@@ -177,14 +185,17 @@ Private Sub pvLoadTabs()
177
185
On Error GoTo EH
178
186
For lIdx = 0 To UBound(m_aTabCaptions)
179
187
If labTab.UBound < lIdx + 1 Then
188
+ On Error GoTo QH
180
189
Load labTab(lIdx + 1 )
190
+ On Error GoTo EH
181
191
labTab(lIdx + 1 ).ZOrder vbBringToFront
182
192
labTab(lIdx + 1 ).BackColor = vbButtonFace
183
193
End If
184
194
Next
185
195
For lIdx = lIdx + 1 To labTab.UBound
186
196
Unload labTab(lIdx)
187
197
Next
198
+ QH:
188
199
Exit Sub
189
200
EH:
190
201
PrintError FUNC_NAME
@@ -199,9 +210,9 @@ Private Sub pvResizeTabs()
199
210
200
211
On Error GoTo EH
201
212
labBackgr.Move 0 , 0 , ScaleWidth, ScaleHeight
202
- lTop = labBackgr.Top + 30
203
- lLeft = labBackgr.Left + 90
204
- lHeight = labBackgr.Height - 30
213
+ lTop = labBackgr.Top + IconScale( 3 ) * ScreenTwipsPerPixelY
214
+ lLeft = labBackgr.Left + IconScale( 6 ) * ScreenTwipsPerPixelX
215
+ lHeight = labBackgr.Height - IconScale( 3 ) * ScreenTwipsPerPixelY
205
216
For lIdx = 0 To labTab.UBound - 1
206
217
With labTab(lIdx + 1 )
207
218
.Visible = False
@@ -269,72 +280,78 @@ EH:
269
280
PrintError FUNC_NAME
270
281
End Sub
271
282
272
- Private Sub labTab_OwnerDraw (Index As Integer , ByVal hGraphics As Long , ByVal hFont As Long , sCaption As String , lLeft As Long , lTop As Long , lWidth As Long , lHeight As Long )
283
+ Private Sub labTab_OwnerDraw (Index As Integer , ByVal hGraphics As Long , ByVal hFont As Long , sCaption As String , sngLeft As Single , sngTop As Single , sngWidth As Single , sngHeight As Single )
273
284
Const FUNC_NAME As String = "labTab_OwnerDraw"
274
285
Dim clrLight As Long
286
+ Dim sngPixel As Single
275
287
276
288
On Error GoTo EH
289
+ sngPixel = IconScale(16 !) / 16 !
277
290
If Index - 1 = m_lCurrentTab Then
278
291
clrLight = pvTranslateColor(vbWindowBackground)
279
- pvDrawRect hGraphics, 0 , 0 , lWidth, lHeight - 1 , clrLight, clrLight, pvTranslateColor(vbWindowText), pvTranslateColor(vbButtonFace)
280
- lLeft = lLeft + 1
281
- lWidth = lWidth - 2
292
+ pvDrawRect hGraphics, 0 , 0 , sngWidth, sngHeight , clrLight, clrLight, pvTranslateColor(vbWindowText), pvTranslateColor(vbButtonFace)
293
+ sngLeft = sngLeft + sngPixel
294
+ sngWidth = sngWidth - 2 * sngPixel
282
295
ElseIf Index <> m_lCurrentTab Then
283
- pvDrawRect hGraphics, 0 , 3 , lWidth, lHeight - 8 , 0 , 0 , pvTranslateColor(vbWindowText, 0.5 ), 0
284
- lWidth = lWidth - 1
296
+ pvDrawRect hGraphics, 0 , 3 * sngPixel, sngWidth, sngHeight - 6 * sngPixel , 0 , 0 , pvTranslateColor(vbWindowText, 0.5 ), 0
297
+ sngWidth = sngWidth - sngPixel
285
298
End If
286
- lTop = lTop + 1
287
- lHeight = lHeight - 2
299
+ sngTop = sngTop + sngPixel
300
+ sngHeight = sngHeight - 2 * sngPixel
288
301
Exit Sub
289
302
EH:
290
303
PrintError FUNC_NAME
291
304
End Sub
292
305
293
- Private Sub labBackgr_OwnerDraw (ByVal hGraphics As Long , ByVal hFont As Long , sCaption As String , lLeft As Long , lTop As Long , lWidth As Long , lHeight As Long )
306
+ Private Sub labBackgr_OwnerDraw (ByVal hGraphics As Long , ByVal hFont As Long , sCaption As String , sngLeft As Single , sngTop As Single , sngWidth As Single , sngHeight As Single )
294
307
Const FUNC_NAME As String = "labBackgr_OwnerDraw"
295
308
Dim clrDark As Long
309
+ Dim sngPixel As Single
296
310
297
311
On Error GoTo EH
312
+ sngPixel = IconScale(16 !) / 16 !
298
313
clrDark = pvTranslateColor(vbWindowText, 0.25 )
299
- pvDrawRect hGraphics, 0 , 0 , lWidth, lHeight , clrDark, clrDark, clrDark, pvTranslateColor(vbWindowBackground)
300
- lLeft = lLeft + 1
301
- lTop = lTop + 1
302
- lWidth = lWidth - 2
303
- lHeight = lHeight - 1
314
+ pvDrawRect hGraphics, 0 , 0 , sngWidth, sngHeight , clrDark, clrDark, clrDark, pvTranslateColor(vbWindowBackground)
315
+ sngLeft = sngLeft + sngPixel
316
+ sngTop = sngTop + sngPixel
317
+ sngWidth = sngWidth - 2 * sngPixel
318
+ sngHeight = sngHeight - sngPixel
304
319
Exit Sub
305
320
EH:
306
321
PrintError FUNC_NAME
307
322
End Sub
308
323
309
324
Private Function pvDrawRect (ByVal hGraphics As Long , _
310
- ByVal lLeft As Long , ByVal lTop As Long , ByVal lWidth As Long , ByVal lHeight As Long , _
325
+ ByVal sngLeft As Single , ByVal sngTop As Single , ByVal sngWidth As Single , ByVal sngHeight As Single , _
311
326
ByVal clrLeft As Long , ByVal clrTop As Long , ByVal clrRight As Long , ByVal clrBottom As Long ) As Boolean
312
327
Const FUNC_NAME As String = "pvDrawRect"
313
328
Dim hBrush As Long
329
+ Dim sngPixel As Single
314
330
315
331
On Error GoTo EH
332
+ sngPixel = IconScale(16 !) / 16 !
316
333
If GdipCreateSolidFill(clrLeft, hBrush) <> 0 Then
317
334
GoTo QH
318
335
End If
319
- If GdipFillRectangleI (hGraphics, hBrush, lLeft, lTop, 1 , lHeight ) <> 0 Then
336
+ If GdipFillRectangle (hGraphics, hBrush, sngLeft + 0.5 , sngTop + 0.5 , sngPixel, sngHeight ) <> 0 Then
320
337
GoTo QH
321
338
End If
322
339
If GdipSetSolidFillColor(hBrush, clrTop) <> 0 Then
323
340
GoTo QH
324
341
End If
325
- If GdipFillRectangleI (hGraphics, hBrush, lLeft + 1 , lTop, lWidth, 1 ) <> 0 Then
342
+ If GdipFillRectangle (hGraphics, hBrush, sngLeft + 0.5 + sngPixel, sngTop + 0.5 , sngWidth, sngPixel ) <> 0 Then
326
343
GoTo QH
327
344
End If
328
345
If GdipSetSolidFillColor(hBrush, clrRight) <> 0 Then
329
346
GoTo QH
330
347
End If
331
- If GdipFillRectangleI (hGraphics, hBrush, lLeft + lWidth - 1 , lTop + 1 , 1 , lHeight ) <> 0 Then
348
+ If GdipFillRectangle (hGraphics, hBrush, sngLeft + sngWidth - 0.5 - sngPixel, sngTop + 0.5 + sngPixel, sngPixel, sngHeight - sngPixel ) <> 0 Then
332
349
GoTo QH
333
350
End If
334
351
If GdipSetSolidFillColor(hBrush, clrBottom) <> 0 Then
335
352
GoTo QH
336
353
End If
337
- If GdipFillRectangleI (hGraphics, hBrush, lLeft + 1 , lTop + lHeight, lWidth - 1 , 1 ) <> 0 Then
354
+ If GdipFillRectangle (hGraphics, hBrush, sngLeft + 0.5 + sngPixel, sngTop + sngHeight - 0.5 - sngPixel, sngWidth - 2 * sngPixel - 1 , sngPixel ) <> 0 Then
338
355
GoTo QH
339
356
End If
340
357
pvDrawRect = True
349
366
Resume QH
350
367
End Function
351
368
369
+ Private Property Get ScreenTwipsPerPixelX() As Single
370
+ ScreenTwipsPerPixelX = Screen.TwipsPerPixelX
371
+ End Property
372
+
373
+ Private Property Get ScreenTwipsPerPixelY() As Single
374
+ ScreenTwipsPerPixelY = Screen.TwipsPerPixelY
375
+ End Property
376
+
377
+ Private Function IconScale (ByVal sngSize As Single ) As Long
378
+ If ScreenTwipsPerPixelX < 6.5 Then
379
+ IconScale = Int(sngSize * 3 )
380
+ ElseIf ScreenTwipsPerPixelX < 9.5 Then
381
+ IconScale = Int(sngSize * 2 )
382
+ ElseIf ScreenTwipsPerPixelX < 11.5 Then
383
+ IconScale = Int(sngSize * 3 \ 2 )
384
+ Else
385
+ IconScale = Int(sngSize * 1 )
386
+ End If
387
+ End Function
388
+
352
389
'=========================================================================
353
390
' Base class events
354
391
'=========================================================================
0 commit comments