📄 command.ctl
字号:
Next
' Draws corners
' First set of pixels
' Upper Left Corner
PSet (2, 0), FirstCornerPixelD
PSet (0, 2), FirstCornerPixelD
' Bottom left corner
PSet (0, .ScaleHeight - 3), FirstCornerPixelD
PSet (2, .ScaleHeight - 1), FirstCornerPixelD
' Top right corner
PSet (.ScaleWidth - 1, 2), FirstCornerPixelD
PSet (.ScaleWidth - 3, 0), FirstCornerPixelD
' Bottom right corner
PSet (.ScaleWidth - 3, .ScaleHeight - 1), FirstCornerPixelD
PSet (.ScaleWidth - 1, .ScaleHeight - 3), FirstCornerPixelD
' Second set of pixels
' Upper Left Corner
PSet (1, 0), SecondCornerPixelD
PSet (0, 1), SecondCornerPixelD
' Bottom left corner
PSet (0, .ScaleHeight - 2), SecondCornerPixelD
PSet (1, .ScaleHeight - 1), SecondCornerPixelD
' Top right corner
PSet (.ScaleWidth - 1, 1), SecondCornerPixelD
PSet (.ScaleWidth - 2, 0), SecondCornerPixelD
' Bottom right corner
PSet (.ScaleWidth - 2, .ScaleHeight - 1), SecondCornerPixelD
PSet (.ScaleWidth - 1, .ScaleHeight - 2), SecondCornerPixelD
' Third set of pixels
PSet (1, 1), ThirdCornerPixelD
PSet (1, .ScaleHeight - 2), ThirdCornerPixelD
PSet (.ScaleWidth - 2, 1), ThirdCornerPixelD
PSet (.ScaleWidth - 2, .ScaleHeight - 2), ThirdCornerPixelD
' Fourth set of pixels
'Upper left corner
PSet (2, 1), FourthCornerPixelD
PSet (1, 2), FourthCornerPixelD
' Bottom left corner
PSet (1, .ScaleHeight - 3), FourthCornerPixelD
PSet (2, .ScaleHeight - 2), FourthCornerPixelD
' Bottom right corner
PSet (.ScaleWidth - 3, .ScaleHeight - 2), FourthCornerPixelD
PSet (.ScaleWidth - 2, .ScaleHeight - 3), FourthCornerPixelD
' Top right corner
PSet (.ScaleWidth - 3, 1), FourthCornerPixelD
PSet (.ScaleWidth - 2, 2), FourthCornerPixelD
End With
End Sub
Private Sub DrawDisabled()
Dim Gradient As New Collection, x As Long
With UserControl
' Draws border lines (not corners)
Line (3, 0)-(.ScaleWidth - 3, 0), BorderColorLinesX
Line (0, 3)-(0, .ScaleHeight - 3), BorderColorLinesX
Line (3, .ScaleHeight - 1)-(.ScaleWidth - 3, .ScaleHeight - 1), BorderColorLinesX
Line (.ScaleWidth - 1, 3)-(.ScaleWidth - 1, .ScaleHeight - 3), BorderColorLinesX
' Draws the fade at the bottom
Line (1, .ScaleHeight - 4)-(.ScaleWidth - 1, .ScaleHeight - 4), FirstBottomLineX
Line (2, .ScaleHeight - 3)-(.ScaleWidth - 2, .ScaleHeight - 3), SecondBottomLineX
Line (3, ScaleHeight - 2)-(.ScaleWidth - 3, .ScaleHeight - 2), ThirdBottomLineX
' Draws the background gradient
Set Gradient = CreateFade(FromColorFadeX, ToColorFadeX, .ScaleHeight - 5)
For x = 1 To Gradient.Count
Select Case x
Case 1
Line (3, x + 1)-(.ScaleWidth - 4, x + 1), Gradient(x)
Case 2
Line (2, x + 1)-(.ScaleWidth - 3, x + 1), Gradient(x)
Case Else
Line (1, x + 1)-(.ScaleWidth - 2, x + 1), Gradient(x)
End Select
Next
' Draws corners
' First set of pixels
' Upper Left Corner
PSet (2, 0), FirstCornerPixelX
PSet (0, 2), FirstCornerPixelX
' Bottom left corner
PSet (0, .ScaleHeight - 3), FirstCornerPixelX
PSet (2, .ScaleHeight - 1), FirstCornerPixelX
' Top right corner
PSet (.ScaleWidth - 1, 2), FirstCornerPixelX
PSet (.ScaleWidth - 3, 0), FirstCornerPixelX
' Bottom right corner
PSet (.ScaleWidth - 3, .ScaleHeight - 1), FirstCornerPixelX
PSet (.ScaleWidth - 1, .ScaleHeight - 3), FirstCornerPixelX
' Second set of pixels
' Upper Left Corner
PSet (1, 0), SecondCornerPixelX
PSet (0, 1), SecondCornerPixelX
' Bottom left corner
PSet (0, .ScaleHeight - 2), SecondCornerPixelX
PSet (1, .ScaleHeight - 1), SecondCornerPixelX
' Top right corner
PSet (.ScaleWidth - 1, 1), SecondCornerPixelX
PSet (.ScaleWidth - 2, 0), SecondCornerPixelX
'Bottom right corner
PSet (.ScaleWidth - 2, .ScaleHeight - 1), SecondCornerPixelX
PSet (.ScaleWidth - 1, .ScaleHeight - 2), SecondCornerPixelX
' Third set of pixels
PSet (1, 1), ThirdCornerPixelX
PSet (1, .ScaleHeight - 2), ThirdCornerPixelX
PSet (.ScaleWidth - 2, 1), ThirdCornerPixelX
PSet (.ScaleWidth - 2, .ScaleHeight - 2), ThirdCornerPixelX
' Fourth set of pixels
' Upper left corner
PSet (2, 1), FourthCornerPixelX
PSet (1, 2), FourthCornerPixelX
' Bottom left corner.
PSet (1, .ScaleHeight - 3), FourthCornerPixelX
PSet (2, .ScaleHeight - 2), FourthCornerPixelX
' Bottom right corner.
PSet (.ScaleWidth - 3, .ScaleHeight - 2), FourthCornerPixelX
PSet (.ScaleWidth - 2, .ScaleHeight - 3), FourthCornerPixelX
' Top right corner.
PSet (.ScaleWidth - 3, 1), FourthCornerPixelX
PSet (.ScaleWidth - 2, 2), FourthCornerPixelX
End With
End Sub
Private Sub DrawIdle()
Dim Gradient As New Collection, x As Long
With UserControl
' Draws border lines (not corners)
Line (3, 0)-(.ScaleWidth - 3, 0), BorderColorLines
Line (0, 3)-(0, .ScaleHeight - 3), BorderColorLines
Line (3, .ScaleHeight - 1)-(.ScaleWidth - 3, .ScaleHeight - 1), BorderColorLines
Line (.ScaleWidth - 1, 3)-(.ScaleWidth - 1, .ScaleHeight - 3), BorderColorLines
' Draws the fade at the bottom
Line (1, .ScaleHeight - 4)-(.ScaleWidth - 1, .ScaleHeight - 4), FirstBottomLine
Line (2, .ScaleHeight - 3)-(.ScaleWidth - 2, .ScaleHeight - 3), SecondBottomLine
Line (3, ScaleHeight - 2)-(.ScaleWidth - 3, .ScaleHeight - 2), ThirdBottomLine
' Draws the background gradient
Set Gradient = CreateFade(FromColorFade, ToColorFade, .ScaleHeight - 5)
For x = 1 To Gradient.Count
Select Case x
Case 1
Line (3, x + 1)-(.ScaleWidth - 4, x + 1), Gradient(x)
Case 2
Line (2, x + 1)-(.ScaleWidth - 3, x + 1), Gradient(x)
Case Else
Line (1, x + 1)-(.ScaleWidth - 2, x + 1), Gradient(x)
End Select
Next
' Draws corners
' First set of pixels
' Upper Left Corner
PSet (2, 0), FirstCornerPixel
PSet (0, 2), FirstCornerPixel
' Bottom left corner
PSet (0, .ScaleHeight - 3), FirstCornerPixel
PSet (2, .ScaleHeight - 1), FirstCornerPixel
' Top right corner
PSet (.ScaleWidth - 1, 2), FirstCornerPixel
PSet (.ScaleWidth - 3, 0), FirstCornerPixel
' Bottom right corner
PSet (.ScaleWidth - 3, .ScaleHeight - 1), FirstCornerPixel
PSet (.ScaleWidth - 1, .ScaleHeight - 3), FirstCornerPixel
' Second set of pixels
' Upper Left Corner
PSet (1, 0), SecondCornerPixel
PSet (0, 1), SecondCornerPixel
' Bottom left corner
PSet (0, .ScaleHeight - 2), SecondCornerPixel
PSet (1, .ScaleHeight - 1), SecondCornerPixel
' Top right corner
PSet (.ScaleWidth - 1, 1), SecondCornerPixel
PSet (.ScaleWidth - 2, 0), SecondCornerPixel
' Bottom right corner
PSet (.ScaleWidth - 2, .ScaleHeight - 1), SecondCornerPixel
PSet (.ScaleWidth - 1, .ScaleHeight - 2), SecondCornerPixel
' Third set of pixels
PSet (1, 1), ThirdCornerPixel
PSet (1, .ScaleHeight - 2), ThirdCornerPixel
PSet (.ScaleWidth - 2, 1), ThirdCornerPixel
PSet (.ScaleWidth - 2, .ScaleHeight - 2), ThirdCornerPixel
' Fourth set of pixels
' Upper left corner
PSet (2, 1), FourthCornerPixel
PSet (1, 2), FourthCornerPixel
' Bottom left corner
PSet (1, .ScaleHeight - 3), FourthCornerPixel
PSet (2, .ScaleHeight - 2), FourthCornerPixel
' Bottom right corner
PSet (.ScaleWidth - 3, .ScaleHeight - 2), FourthCornerPixel
PSet (.ScaleWidth - 2, .ScaleHeight - 3), FourthCornerPixel
' Top right corner
PSet (.ScaleWidth - 3, 1), FourthCornerPixel
PSet (.ScaleWidth - 2, 2), FourthCornerPixel
End With
End Sub
Private Sub DrawHot()
Dim Gradient As New Collection, x As Long
With UserControl
' Draws border lines (not corners)
Line (3, 0)-(.ScaleWidth - 3, 0), BorderColorLinesH
Line (0, 3)-(0, .ScaleHeight - 3), BorderColorLinesH
Line (3, .ScaleHeight - 1)-(.ScaleWidth - 3, .ScaleHeight - 1), BorderColorLinesH
Line (.ScaleWidth - 1, 3)-(.ScaleWidth - 1, .ScaleHeight - 3), BorderColorLinesH
' Draws the fade at the bottom
Line (1, .ScaleHeight - 4)-(.ScaleWidth - 1, .ScaleHeight - 4), FirstBottomLineH
Line (2, .ScaleHeight - 3)-(.ScaleWidth - 2, .ScaleHeight - 3), SecondBottomLineH
Line (3, ScaleHeight - 2)-(.ScaleWidth - 3, .ScaleHeight - 2), ThirdBottomLineH
'Draws the background gradient
Set Gradient = CreateFade(FromColorFadeH, ToColorFadeH, .ScaleHeight - 5)
For x = 1 To Gradient.Count
Select Case x
Case 1
Line (3, x + 1)-(.ScaleWidth - 4, x + 1), FirstTopLineH
Case 2
Line (2, x + 1)-(.ScaleWidth - 3, x + 1), SecondTopLineH
Case Else
Line (1, x + 1)-(.ScaleWidth - 2, x + 1), Gradient(x)
End Select
Next
' Draws side gradients
Set Gradient = CreateFade(SideFromColorFadeH, SideToColorFadeH, .ScaleHeight - 7)
For x = 1 To Gradient.Count
PSet (1, x + 3), Gradient(x)
PSet (2, x + 3), Gradient(x)
PSet (.ScaleWidth - 2, x + 3), Gradient(x)
PSet (.ScaleWidth - 3, x + 3), Gradient(x)
Next
' Draws corners
' First set of pixels
' Upper Left Corner
PSet (2, 0), FirstCornerPixelH
PSet (0, 2), FirstCornerPixelH
' Bottom left corner
PSet (0, .ScaleHeight - 3), FirstCornerPixelH
PSet (2, .ScaleHeight - 1), FirstCornerPixelH
' Top right corner
PSet (.ScaleWidth - 1, 2), FirstCornerPixelH
PSet (.ScaleWidth - 3, 0), FirstCornerPixelH
' Bottom right corner
PSet (.ScaleWidth - 3, .ScaleHeight - 1), FirstCornerPixelH
PSet (.ScaleWidth - 1, .ScaleHeight - 3), FirstCornerPixelH
' Second set of pixels
' Upper Left Corner
PSet (1, 0), SecondCornerPixelH
PSet (0, 1), SecondCornerPixelH
' Bottom left corner
PSet (0, .ScaleHeight - 2), SecondCornerPixelH
PSet (1, .ScaleHeight - 1), SecondCornerPixelH
' Top right corner
PSet (.ScaleWidth - 1, 1), SecondCornerPixelH
PSet (.ScaleWidth - 2, 0), SecondCornerPixelH
' Bottom right corner
PSet (.ScaleWidth - 2, .ScaleHeight - 1), SecondCornerPixelH
PSet (.ScaleWidth - 1, .ScaleHeight - 2), SecondCornerPixelH
' Third set of pixels
PSet (1, 1), ThirdCornerPixelH
PSet (1, .ScaleHeight - 2), ThirdCornerPixelH
PSet (.ScaleWidth - 2, 1), ThirdCornerPixelH
PSet (.ScaleWidth - 2, .ScaleHeight - 2), ThirdCornerPixelH
' Fourth set of pixels
' Upper left corner
PSet (2, 1), FourthCornerPixelH
PSet (1, 2), FourthCornerPixelH
' Bottom left corner
PSet (1, .ScaleHeight - 3), FourthCornerPixelH
PSet (2, .ScaleHeight - 2), FourthCornerPixelH
' Bottom right corner
PSet (.ScaleWidth - 3, .ScaleHeight - 2), FourthCornerPixelH
PSet (.ScaleWidth - 2, .ScaleHeight - 3), FourthCornerPixelH
' Top right corner
PSet (.ScaleWidth - 3, 1), FourthCornerPixelH
PSet (.ScaleWidth - 2, 2), FourthCornerPixelH
End With
End Sub
Private Sub UserControl_DblClick()
If PropEnabled = False Then
Exit Sub
End If
RaiseEvent DblClick
End Sub
Private Sub UserControl_EnterFocus()
HasFocus = True
Redraw
End Sub
Private Sub UserControl_ExitFocus()
HasFocus = False
Redraw
End Sub
Private Sub UserControl_InitProperties()
Caption = Ambient.DisplayName
Set Font = UserControl.Parent.Font
Enabled = True
ForeColor = vbBlack
End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
MouseDown = True
Redraw
RaiseEvent MouseDown(Button, Shift, x, Y)
End Sub
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Dim DrawIt As Boolean
SetCapture UserControl.hwnd
If x < 0 Or x > UserControl.ScaleWidth Or Y < 0 Or Y > UserControl.ScaleHeight Then
ReleaseCapture
MouseOver = False
MouseDown = False
Redraw
Else
If MouseOver = False Then DrawIt = True
MouseOver = True
If DrawIt = True Then Redraw
End If
RaiseEvent MouseMove(Button, Shift, x, Y)
End Sub
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
If PropEnabled = False Then
Exit Sub
End If
RaiseEvent Click
MouseDown = False
Redraw
RaiseEvent MouseUp(Button, Shift, x, Y)
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Caption = PropBag.ReadProperty("Caption", Ambient.DisplayName)
Set Font = PropBag.ReadProperty("Font", UserControl.Parent.Font)
Enabled = PropBag.ReadProperty("Enabled", True)
ForeColor = PropBag.ReadProperty("ForeColor", vbBlack)
End Sub
Private Sub UserControl_Resize()
Redraw
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Caption", PropCaption, Ambient.DisplayName
PropBag.WriteProperty "Font", UserControl.Font, UserControl.Parent.Font
PropBag.WriteProperty "Enabled", PropEnabled, True
PropBag.WriteProperty "ForeColor", PropForeColor, vbBlack
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -