Private Function StyleDrawFill(ByVal hDCDst As Long, _
tRectDst As RECT, _
ByVal eBorder As BorderStyle, _
ByVal eFill As FillStyle, _
ByVal crBorder As Long, _
ByVal crFill1 As Long, _
Optional ByVal crFill2 As Long, _
Optional ByVal byFillAlpha As Byte = 255) As Boolean
Dim hDCSrc As Long, hDCMask As Long
Dim hBmpSrc As Long, hBmpOld1 As Long
Dim hBmpMask As Long, hBmpOld2 As Long
Dim hPen As Long, hPenOld As Long
Dim hBrush As Long, hBrushOld As Long
Dim tRect As RECT
Dim tPoint(2) As POINTAPI
Dim tBlend As BLENDFUNCTION
Dim lpBlend As Long
Dim tVertex(3) As TRIVERTEX
Dim tGRect(1) As GRADIENT_RECT
Dim nBorderWidth As Long
'边框
Select Case eBorder
Case BS_NONE
Case BS_RAISED, BS_SUNKEN
Call DrawEdge(hDCDst, tRectDst, eBorder, BF_RECT)
Case BS_ETCHED, BS_BUMP
Call DrawEdge(hDCDst, tRectDst, eBorder, BF_RECT)
nBorderWidth = nBorderWidth + 1
Case Else
hPen = CreatePen(Choose(eBorder And &HF, PS_SOLID, PS_DASH, PS_DOT), 1, crBorder)
hBrush = GetStockObject(NULL_BRUSH)
hPenOld = SelectObject(hDCDst, hPen)
hBrushOld = SelectObject(hDCDst, hBrush)
If CBool(eBorder And BS_ROUNDRECT) Then
Call RoundRect(hDCDst, tRectDst.Left, tRectDst.Top, tRectDst.Right, tRectDst.Bottom, 6, 6)
Else
Call Rectangle(hDCDst, tRectDst.Left, tRectDst.Top, tRectDst.Right, tRectDst.Bottom)
End If
Call DeleteObject(SelectObject(hDCDst, hPenOld))
Call SelectObject(hDCDst, hBrushOld)
End Select
nBorderWidth = nBorderWidth + 1
'填充 - - - - - - - - - - - - - - - - - - - - -
'创建目标 DC 副本
Call SetRect(tRect, 0, 0, tRectDst.Right - tRectDst.Left, tRectDst.Bottom - tRectDst.Top)
hDCSrc = CreateCompatibleDC(hDCDst)
hBmpSrc = CreateCompatibleBitmap(hDCDst, tRect.Right - tRect.Left, tRect.Bottom - tRect.Top)
hBmpOld1 = SelectObject(hDCSrc, hBmpSrc)
Call BitBlt(hDCSrc, 0, 0, tRect.Right - tRect.Left, tRect.Bottom - tRect.Top, hDCDst, tRectDst.Left, tRectDst.Top, vbSrcCopy)
'填充此副本
Call InflateRect(tRect, -nBorderWidth, -nBorderWidth)
hDCMask = CreateCompatibleDC(hDCDst)
hBmpMask = CreateCompatibleBitmap(hDCDst, tRect.Right - tRect.Left, tRect.Bottom - tRect.Top)
hBmpOld2 = SelectObject(hDCMask, hBmpMask)
Call OffsetRect(tRect, -nBorderWidth, -nBorderWidth)
Select Case eFill
Case FS_NONE
byFillAlpha = 0
Case FS_SOLIDCOLOR
hBrush = CreateSolidBrush(crFill1)
Call FillRect(hDCMask, tRect, hBrush)
Call DeleteObject(hBrush)
Case FS_GRADIENT_H, FS_GRADIENT_V
With tVertex(0)
.x = tRect.Left
.y = tRect.Top
.red = GetRedGB16(crFill1)
.green = GetRGreenB16(crFill1)
.blue = GetRGBlue16(crFill1)
.alpha = 0
End With
With tVertex(1)
.x = tRect.Right
.y = tRect.Bottom
.red = GetRedGB16(crFill2)
.green = GetRGreenB16(crFill2)
.blue = GetRGBlue16(crFill2)
.alpha = 0
End With
tGRect(0).UpperLeft = 0
tGRect(0).LowerRight = 1
Call GradientFill(hDCMask, tVertex(0), 2, tGRect(0), 1, Choose(eFill \ 2, GRADIENT_FILL_RECT_H, GRADIENT_FILL_RECT_V))
Case Else '双矩形填充
With tVertex(0)
.x = tRect.Left
.y = tRect.Top
.red = GetRedGB16(crFill1)
.green = GetRGreenB16(crFill1)
.blue = GetRGBlue16(crFill1)
.alpha = 0
End With
With tVertex(3)
.x = tRect.Right
.y = tRect.Bottom
.red = GetRedGB16(crFill1)
.green = GetRGreenB16(crFill1)
.blue = GetRGBlue16(crFill1)
.alpha = 0
End With
With tVertex(1)
'.x = (pending)
'.y = (pending)
.red = GetRedGB16(crFill2)
.green = GetRGreenB16(crFill2)
.blue = GetRGBlue16(crFill2)
.alpha = 0
End With
With tVertex(2)
'.x = (pending)
'.y = (pending)
.red = GetRedGB16(crFill2)
.green = GetRGreenB16(crFill2)
.blue = GetRGBlue16(crFill2)
.alpha = 0
End With
tGRect(0).UpperLeft = 0
tGRect(0).LowerRight = 1
tGRect(1).UpperLeft = 2
tGRect(1).LowerRight = 3
Select Case (eFill A