@@ -104,7 +104,9 @@ Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVa
104
104
Private Declare Function UpdateLayeredWindow Lib "user32 .dll " (ByVal hWnd As Long , ByVal hdcDest As Long , ptDst As Any , pSize As Any , ByVal hdcSrc As Long , ptSrc As Any , ByVal crKey As Long , pBlend As Any , ByVal dwFlags As Long ) As Long
105
105
Private Declare Function GetDC Lib "user32 " (ByVal hWnd As Long ) As Long
106
106
Private Declare Function ReleaseDC Lib "user32 " (ByVal hWnd As Long , ByVal hDC As Long ) As Long
107
- Private Declare Function GetWindowRect Lib "user32 " (ByVal hWnd As Long , lpRect As Any ) As Long
107
+ Private Declare Function GetClientRect Lib "user32 " (ByVal hWnd As Long , lpRect As Any ) As Long
108
+ Private Declare Function MapWindowPoints Lib "user32 " (ByVal hWndFrom As Long , ByVal hWndTo As Long , lppt As Any , ByVal cPoints As Long ) As Long
109
+ Private Declare Function GetParent Lib "user32 " (ByVal hWnd As Long ) As Long
108
110
'--- clipboard support
109
111
Private Declare Function OpenClipboard Lib "user32 " (ByVal hWnd As Long ) As Long
110
112
Private Declare Function CloseClipboard Lib "user32 " () As Long
@@ -245,13 +247,6 @@ Private Type BITMAPV5HEADER
245
247
bV5Reserved As Long
246
248
End Type
247
249
248
- Private Type BLENDFUNCTION
249
- BlendOp As Byte
250
- BlendFlags As Byte
251
- SourceConstantAlpha As Byte
252
- AlphaFormat As Byte
253
- End Type
254
-
255
250
Private Type POINTAPI
256
251
X As Long
257
252
Y As Long
@@ -675,7 +670,6 @@ Public Function GdipUpdateLayeredWindow(ByVal hWnd As Long) As Boolean
675
670
Dim hMemDC As Long
676
671
Dim hBmp As Long
677
672
Dim hPrevBmp As Long
678
- Dim uBlend As BLENDFUNCTION
679
673
Dim uRect(0 To 1 ) As POINTAPI
680
674
Dim ptSrc As POINTAPI
681
675
@@ -699,18 +693,14 @@ Public Function GdipUpdateLayeredWindow(ByVal hWnd As Long) As Boolean
699
693
If hPrevBmp = 0 Then
700
694
GoTo QH
701
695
End If
702
- Call GetWindowRect (hWnd, uRect(0 ))
696
+ Call GetClientRect (hWnd, uRect(0 ))
697
+ Call MapWindowPoints (hWnd, GetParent(hWnd), uRect(0 ), 2 )
703
698
With uRect(1 )
704
699
.X = .X - uRect(0 ).X
705
700
.Y = .Y - uRect(0 ).Y
706
701
End With
707
- With uBlend
708
- .BlendOp = AC_SRC_OVER
709
- .BlendFlags = 0
710
- .SourceConstantAlpha = 255 * m_sngOpacity
711
- .AlphaFormat = AC_SRC_ALPHA
712
- End With
713
- Call UpdateLayeredWindow (hWnd, hScreenDC, uRect(0 ), uRect(1 ), hMemDC, ptSrc, 0 , uBlend, ULW_ALPHA)
702
+ Call UpdateLayeredWindow (hWnd, hScreenDC, uRect(0 ), uRect(1 ), hMemDC, ptSrc, 0 , _
703
+ AC_SRC_ALPHA * &H1000000 + CByte(255 * m_sngOpacity) * &H10000 + AC_SRC_OVER, ULW_ALPHA)
714
704
'--- success
715
705
GdipUpdateLayeredWindow = True
716
706
QH:
@@ -1493,6 +1483,9 @@ DefPaint:
1493
1483
End If
1494
1484
Line (0 , 0 )-(ScaleWidth - 1 , ScaleHeight - 1 ), vbBlack, B
1495
1485
End If
1486
+ If hWnd <> 0 Then
1487
+ GdipUpdateLayeredWindow hWnd
1488
+ End If
1496
1489
If (GetWindowLong(ContainerHwnd, GWL_EXSTYLE) And WS_EX_LAYERED) <> 0 Then
1497
1490
GdipUpdateLayeredWindow ContainerHwnd
1498
1491
End If
@@ -1514,6 +1507,7 @@ Private Sub UserControl_InitProperties()
1514
1507
1515
1508
On Error GoTo EH
1516
1509
m_eContainerScaleMode = ToScaleMode(Ambient.ScaleUnits)
1510
+ BackStyle = IIf (hWnd = 0 , vbTransparent, 1 )
1517
1511
AutoRedraw = DEF_AUTOREDRAW
1518
1512
Opacity = DEF_OPACITY
1519
1513
Rotation = DEF_ROTATION
@@ -1530,6 +1524,7 @@ Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
1530
1524
1531
1525
On Error GoTo EH
1532
1526
m_eContainerScaleMode = ToScaleMode(Ambient.ScaleUnits)
1527
+ BackStyle = IIf (hWnd = 0 , vbTransparent, 1 )
1533
1528
With PropBag
1534
1529
m_bAutoRedraw = .ReadProperty("AutoRedraw" , DEF_AUTOREDRAW)
1535
1530
m_sngOpacity = .ReadProperty("Opacity" , DEF_OPACITY)
0 commit comments