📄 candybutton.ctl
字号:
Case Is = PIC_LEFT
If CornerRadius Then StartX = CornerRadius Else StartX = 8
StartY = (uH - pH) \ 2
Picture1.CurrentX = Abs(uW \ 2 - lW \ 2)
Picture1.CurrentY = Abs(uH \ 2 - lH \ 2)
Case Is = PIC_RIGHT
If CornerRadius Then StartX = uW - CornerRadius - pW Else StartX = uW - 8 - pW
StartY = (uH - pH) \ 2
Picture1.CurrentX = Abs(uW \ 2 - lW \ 2)
Picture1.CurrentY = Abs(uH \ 2 - lH \ 2)
End Select
If vState = ePressed Then
StartX = StartX + 1: Picture1.CurrentX = Picture1.CurrentX + 1
StartY = StartY + 1: Picture1.CurrentY = Picture1.CurrentY + 1
End If
Picture1.Print m_Caption
If Not m_StdPicture Is Nothing Then m_StdPicture.Render Picture1.hdc, CLng(StartX), CLng(StartY), CLng(pW), CLng(pH), _
0, m_StdPicture.Height, m_StdPicture.Width, -m_StdPicture.Height, ByVal 0&
Set UserControl.Picture = Picture1.Image
End Sub
Private Function DrawXPToolbarButton(Optional vState As eState)
Dim i As Long
Dim r1 As Long, g1 As Long, b1 As Long
Dim r2 As Long, g2 As Long, b2 As Long
Dim uH As Long, uW As Long
uH = UserControl.ScaleHeight - 1
uW = UserControl.ScaleWidth - 1
On Error Resume Next
Picture1.Line (0, 0)-(uW, uH), UserControl.Parent.BackColor, BF
On Error GoTo 0
If vState = ePressed Then
r1 = 220: g1 = 218: b1 = 209
r2 = 231: g2 = 230: b2 = 224
For i = 0 To 3
Picture1.Line (0, 1 + i)-(uW, 1 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
Next
r1 = 231: g1 = 230: b1 = 224
r2 = 225: g2 = 224: b2 = 216
For i = 4 To uH - 4
Picture1.Line (0, i)-(uW, i), RGB(r2 * (i / (uH - 6)) + r1 - (r1 * (i / (uH - 6))), g2 * (i / (uH - 6)) + g1 - (g1 * (i / (uH - 6))), b2 * (i / (uH - 6)) + b1 - (b1 * (i / (uH - 6))))
Next
r1 = 225: g1 = 224: b1 = 216
r2 = 235: g2 = 234: b2 = 229
For i = 0 To 3
Picture1.Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
Next
Picture1.PSet (1, 0), RGB(215, 215, 204): Picture1.PSet (0, 1), RGB(215, 215, 204)
Picture1.Line (0, 2)-(2, 0), RGB(179, 179, 168) '7617536
Picture1.Line (2, 0)-(uW - 2, 0), RGB(157, 157, 146)
Picture1.PSet (uW - 1, 0), RGB(215, 215, 204): Picture1.PSet (uW, 1), RGB(215, 215, 204)
Picture1.Line (uW - 2, 0)-(uW, 2), RGB(179, 179, 168) '7617536
Picture1.Line (uW, 2)-(uW, uH - 2), RGB(157, 157, 146)
Picture1.PSet (uW, uH - 1), RGB(215, 215, 204): Picture1.PSet (uW - 1, uH), RGB(215, 215, 204)
Picture1.Line (uW, uH - 2)-(uW - 2, uH), RGB(179, 179, 168) ' 7617536
Picture1.Line (uW - 2, uH)-(2, uH), RGB(157, 157, 146)
Picture1.PSet (1, uH), RGB(215, 215, 204): Picture1.PSet (0, uH - 1), RGB(215, 215, 204)
Picture1.Line (2, uH)-(0, uH - 2), RGB(179, 179, 168) '7617536
Picture1.Line (0, uH - 2)-(0, 2), RGB(157, 157, 146)
ElseIf vState = eHover Then
r1 = 254: g1 = 254: b1 = 253
r2 = 252: g2 = 252: b2 = 249
For i = 0 To 3
Picture1.Line (0, 1 + i)-(uW, 1 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
Next
r1 = 252: g1 = 252: b1 = 249
r2 = 238: g2 = 237: b2 = 229
For i = 4 To uH - 4
Picture1.Line (0, i)-(uW, i), RGB(r2 * (i / (uH - 6)) + r1 - (r1 * (i / (uH - 6))), g2 * (i / (uH - 6)) + g1 - (g1 * (i / (uH - 6))), b2 * (i / (uH - 6)) + b1 - (b1 * (i / (uH - 6))))
Next
r1 = 238: g1 = 237: b1 = 229
r2 = 215: g2 = 210: b2 = 198
For i = 0 To 3
Picture1.Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
Next
Picture1.PSet (1, 0), RGB(232, 232, 221): Picture1.PSet (0, 1), RGB(232, 232, 221)
Picture1.Line (0, 2)-(2, 0), RGB(216, 216, 205) '7617536
Picture1.Line (2, 0)-(uW - 2, 0), RGB(206, 206, 195)
Picture1.PSet (uW - 1, 0), RGB(232, 232, 221): Picture1.PSet (uW, 1), RGB(232, 232, 221)
Picture1.Line (uW - 2, 0)-(uW, 2), RGB(216, 216, 205) '7617536
Picture1.Line (uW, 2)-(uW, uH - 2), RGB(206, 206, 195)
Picture1.PSet (uW, uH - 1), RGB(232, 232, 221): Picture1.PSet (uW - 1, uH), RGB(232, 232, 221)
Picture1.Line (uW, uH - 2)-(uW - 2, uH), RGB(216, 216, 205) ' 7617536
Picture1.Line (uW - 2, uH)-(2, uH), RGB(206, 206, 195)
Picture1.PSet (1, uH), RGB(232, 232, 221): Picture1.PSet (0, uH - 1), RGB(232, 232, 221)
Picture1.Line (2, uH)-(0, uH - 2), RGB(216, 216, 205) '7617536
Picture1.Line (0, uH - 2)-(0, 2), RGB(206, 206, 195)
ElseIf vState = eChecked Then
Picture1.Line (1, 1)-(uW - 1, uH - 1), vbWhite, BF
Picture1.PSet (1, 0), RGB(203, 213, 214): Picture1.PSet (0, 1), RGB(203, 213, 214)
Picture1.Line (0, 2)-(2, 0), RGB(152, 175, 190) '7617536
Picture1.Line (2, 0)-(uW - 2, 0), RGB(122, 152, 175)
Picture1.PSet (uW - 1, 0), RGB(203, 213, 214): Picture1.PSet (uW, 1), RGB(203, 213, 214)
Picture1.Line (uW - 2, 0)-(uW, 2), RGB(152, 175, 190) '7617536
Picture1.Line (uW, 2)-(uW, uH - 2), RGB(122, 152, 175)
Picture1.PSet (uW, uH - 1), RGB(203, 213, 214): Picture1.PSet (uW - 1, uH), RGB(203, 213, 214)
Picture1.Line (uW, uH - 2)-(uW - 2, uH), RGB(152, 175, 190) ' 7617536
Picture1.Line (uW - 2, uH)-(2, uH), RGB(122, 152, 175)
Picture1.PSet (1, uH), RGB(203, 213, 214): Picture1.PSet (0, uH - 1), RGB(203, 213, 214)
Picture1.Line (2, uH)-(0, uH - 2), RGB(152, 175, 190) '7617536
Picture1.Line (0, uH - 2)-(0, 2), RGB(122, 152, 175)
End If
End Function
Private Function DrawXPButton(Optional vState As eState)
Dim i As Long
Dim r1 As Long, g1 As Long, b1 As Long
Dim r2 As Long, g2 As Long, b2 As Long
Dim uH As Long, uW As Long
uH = UserControl.ScaleHeight - 1
uW = UserControl.ScaleWidth - 1
On Error Resume Next
Picture1.Line (0, 0)-(uW, uH), UserControl.Parent.BackColor, BF
On Error GoTo 0
If vState = ePressed Then
r1 = 209: g1 = 204: b1 = 193
r2 = 229: g2 = 228: b2 = 221
For i = 0 To 3
Picture1.Line (0, 1 + i)-(uW, 1 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
Next
r1 = 229: g1 = 228: b1 = 221
r2 = 226: g2 = 226: b2 = 218
For i = 4 To uH - 4
Picture1.Line (0, i)-(uW, i), RGB(r2 * (i / (uH - 6)) + r1 - (r1 * (i / (uH - 6))), g2 * (i / (uH - 6)) + g1 - (g1 * (i / (uH - 6))), b2 * (i / (uH - 6)) + b1 - (b1 * (i / (uH - 6))))
Next
r1 = 226: g1 = 226: b1 = 218
r2 = 242: g2 = 241: b2 = 238
For i = 0 To 4
Picture1.Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
Next
Else
r1 = 236: g1 = 235: b1 = 230
r2 = 214: g2 = 208: b2 = 197
For i = 0 To uH - 3
Picture1.Line (1, i)-(uW, i), RGB(r1 * (i / (uH - 3)) + 255 - (255 * (i / (uH - 3))), g1 * (i / (uH - 3)) + 255 - (255 * (i / (uH - 3))), b1 * (i / (uH - 3)) + 255 - (255 * (i / (uH - 3))))
Next
For i = 0 To 3
Picture1.Line (0, uH - 4 + i)-(uW, uH - 4 + i), RGB(r2 * (i / 3) + r1 - (r1 * (i / 3)), g2 * (i / 3) + g1 - (g1 * (i / 3)), b2 * (i / 3) + b1 - (b1 * (i / 3)))
Next
End If
Select Case vState
Case Is = eFocus
Picture1.Line (0, 1)-(uW, 1), RGB(206, 231, 255)
Picture1.Line (0, 2)-(uW, 2), RGB(188, 212, 246)
r1 = 188: g1 = 212: b1 = 246
r2 = 137: g2 = 173: b2 = 228
For i = 3 To uH - 3
Picture1.Line (0, i)-(3, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
Picture1.Line (uW - 2, i)-(uW, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
Next
Picture1.Line (0, uH - 2)-(uW, uH - 2), RGB(137, 173, 228)
Picture1.Line (0, uH - 1)-(uW, uH - 1), RGB(105, 130, 238)
Case Is = eHover
Picture1.Line (0, 1)-(uW, 1), RGB(255, 240, 202)
Picture1.Line (0, 2)-(uW, 2), RGB(253, 216, 137)
r1 = 253: g1 = 216: b1 = 137
r2 = 248: g2 = 178: b2 = 48
For i = 3 To uH - 3
Picture1.Line (0, i)-(3, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
Picture1.Line (uW - 2, i)-(uW, i), RGB(r2 * (i / uH) + r1 - (r1 * (i / uH)), g2 * (i / uH) + g1 - (g1 * (i / uH)), b2 * (i / uH) + b1 - (b1 * (i / uH)))
Next
Picture1.Line (0, uH - 2)-(uW, uH - 2), RGB(248, 178, 48)
Picture1.Line (0, uH - 1)-(uW, uH - 1), RGB(229, 151, 0)
End Select
Picture1.PSet (0, 1), RGB(122, 149, 168): Picture1.PSet (1, 0), RGB(122, 149, 168)
Picture1.Line (0, 2)-(2, 0), RGB(37, 87, 131) '7617536
Picture1.Line (2, 0)-(uW - 2, 0), 7617536
Picture1.PSet (uW - 1, 0), RGB(122, 149, 168): Picture1.PSet (uW, 1), RGB(122, 149, 168)
Picture1.Line (uW - 2, 0)-(uW, 2), RGB(37, 87, 131) '7617536
Picture1.Line (uW, 2)-(uW, uH - 2), 7617536
Picture1.PSet (uW, uH - 1), RGB(122, 149, 168): Picture1.PSet (uW - 1, uH), RGB(122, 149, 168)
Picture1.Line (uW, uH - 2)-(uW - 2, uH), RGB(37, 87, 131) ' 7617536
Picture1.Line (uW - 2, uH)-(2, uH), 7617536
Picture1.PSet (1, uH), RGB(122, 149, 168): Picture1.PSet (0, uH - 1), RGB(122, 149, 168)
Picture1.Line (2, uH)-(0, uH - 2), RGB(37, 87, 131) '7617536
Picture1.Line (0, uH - 2)-(0, 2), 7617536
End Function
Private Function DrawCrystalButton(vState As eState)
Dim CrystalParam As tCrystalParam
If m_Style = Mac Then 'Mac
CrystalParam.Ref_MixColorFrom = 0 '20
CrystalParam.Ref_Intensity = 70 '50
CrystalParam.Ref_Left = (CornerRadius \ 3)
CrystalParam.Ref_Top = 0
CrystalParam.Ref_Height = 10 'CornerRadius - 2
CrystalParam.Ref_Width = Picture1.ScaleWidth + 2 * CornerRadius
CrystalParam.Ref_Radius = 5 'CornerRadius \ 2
CrystalParam.RadialGXPercent = 100
CrystalParam.RadialGYPercent = 100 - (7 * 100 / UserControl.ScaleHeight)
If CrystalParam.RadialGYPercent > 80 Then CrystalParam.RadialGYPercent = 80
ElseIf m_Style = WMP Then 'WMP
CrystalParam.Ref_Intensity = 50
CrystalParam.Ref_Left = -CornerRadius / 2
CrystalParam.Ref_Top = -CornerRadius - 2
CrystalParam.Ref_Height = (2 * CornerRadius) + 1
CrystalParam.Ref_Width = Picture1.ScaleWidth + 2 * CornerRadius
CrystalParam.Ref_Radius = CornerRadius
CrystalParam.RadialGXPercent = 80
CrystalParam.RadialGYPercent = 70
ElseIf m_Style = Mac_Variation Then
CrystalParam.Ref_Intensity = 70
CrystalParam.Ref_Left = (CornerRadius \ 3) - 1
CrystalParam.Ref_Height = CornerRadius - 2
CrystalParam.Ref_Width = Picture1.ScaleWidth + 2 * CornerRadius
CrystalParam.Ref_Top = 0
CrystalParam.Ref_Radius = (CornerRadius \ 2)
CrystalParam.RadialGXPercent = 100
CrystalParam.RadialGYPercent = 70
ElseIf m_Style = Crystal Then
CrystalParam.Ref_Intensity = 50
CrystalParam.Ref_Left = CornerRadius / 2
CrystalParam.Ref_Height = CornerRadius
CrystalParam.Ref_Width = Picture1.ScaleWidth + 2 * CornerRadius
CrystalParam.Ref_Top = 1
CrystalParam.Ref_Radius = CornerRadius \ 2
CrystalParam.RadialGXPercent = 100
CrystalParam.RadialGYPercent = 60
End If
Select Case vState
Case eHover
DrawCrystal 0, 0, Picture1.ScaleWidth - 1, UserControl.ScaleHeight - 1, m_ColorButtonHover, CrystalParam
Case ePressed, eChecked
DrawCrystal 0, 0, UserControl.ScaleWidth - 1, UserControl.ScaleHeight - 1, ColorButtonDown, CrystalParam
Case eNormal, eFocus
DrawCrystal 0, 0, UserControl.ScaleWidth - 1, UserControl.ScaleHeight - 1, m_ColorButtonUp, CrystalParam
End Select
End Function
Private Sub DrawCrystal(x As Long, y As Long, Width As Long, Height As Long, Color As Long, CrystalParam As tCrystalParam)
Dim i As Long, j As Long, HighlightColor As Long, BorderColor As Long
Dim ptColor As Long, RadialGRadius As Long, LinearGPercent As Long
Dim RGXPercent As Single, RGYPercent As Single
RGYPercent = (100 - CrystalParam.RadialGYPercent) / (Height * 2)
RGXPercent = (100 - CrystalParam.RadialGXPercent) / Width
If m_BorderBrightness >= 0 Then
BorderColor = BlendColors(Color, vbWhite, m_BorderBrightness)
Else
BorderColor = BlendColors(Color, vbBlack, -m_BorderBrightness)
End If
For j = 0 To Height
For i = 0 To Width \ 2
If IsInRoundRect(i, j, 1, 1, Width - 2, Height - 2, CornerRadius) Then
If j > CrystalParam.Ref_Top And j < CrystalParam.Ref_Top + CrystalParam.Ref_Height Then
HighlightColor = BlendColors(vbWhite, Color, CrystalParam.Ref_MixColorFrom + j * CrystalParam.Ref_Intensity \ CornerRadius)
End If
'Drawing the button properly
If IsInRoundRect(i, j, CrystalParam.Ref_Left, CrystalParam.Ref_Top, CrystalParam.Ref_Width, CrystalParam.Ref_Height, CrystalParam.Ref_Radius) Then
ptColor = HighlightColor 'draw reflected highlight
Else
RadialGRadius = ((j - y - Height) * RGYPercent) ^ 2 + _
((i - x - Width \ 2) * RGXPercent) ^ 2
ptColor = BlendColors(m_ColorBright, Color, RadialGRadius)
If i < CornerRadius Then
ptColor = BlendColors(vbBlack, ptColor, (j * 3 \ 2 + i) * 70 \ CornerRadius)
End If
End If
SetPixelV Picture1.hdc, i + x, j + y, ptColor
SetPixelV Picture1.hdc, x + Width - i, j + y, ptColor
ElseIf IsInRoundRect(i, j, 0, 0, Width, Height, CornerRadius) Then
'this draw a thin border
SetPixelV Picture1.hdc, i + x, j + y, BorderColor
SetPixelV Picture1.hdc, x + Width - i, j + y, BorderColor
End If
Next i
Next j
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -