📄 form1.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Appearance = 0 'Flat
BackColor = &H8000000A&
Caption = "画板"
ClientHeight = 3990
ClientLeft = 165
ClientTop = 450
ClientWidth = 5670
LinkTopic = "Form1"
ScaleHeight = 3990
ScaleWidth = 5670
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox ColorsToolbar
Align = 2 'Align Bottom
BorderStyle = 0 'None
Height = 495
Left = 0
ScaleHeight = 495
ScaleWidth = 5670
TabIndex = 2
Top = 3240
Width = 5670
Begin VB.CommandButton Command3
Caption = "橡皮"
Height = 375
Left = 4560
TabIndex = 18
Top = 0
Width = 975
End
Begin VB.CommandButton Command2
Caption = "线"
Height = 375
Left = 3360
TabIndex = 17
Top = 0
Width = 975
End
Begin VB.CommandButton Command1
Caption = "笔"
Height = 375
Left = 2160
TabIndex = 16
Top = 0
Width = 975
End
Begin VB.Label lblLgtGrey
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 720
TabIndex = 15
Top = 240
Width = 255
End
Begin VB.Label lblDarkGrey
BackColor = &H00808080&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 720
TabIndex = 14
Top = 0
Width = 255
End
Begin VB.Label lblDrkP
BackColor = &H00800080&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1680
TabIndex = 13
Top = 240
Width = 255
End
Begin VB.Label lblLgtP
BackColor = &H00FF00FF&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1680
TabIndex = 12
Top = 0
Width = 255
End
Begin VB.Label lblLgtGreen
BackColor = &H0000FF00&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1440
TabIndex = 11
Top = 240
Width = 255
End
Begin VB.Label lblDrkGreen
BackColor = &H00008000&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1440
TabIndex = 10
Top = 0
Width = 255
End
Begin VB.Label lblLgtBlue
BackColor = &H00FFFF00&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1200
TabIndex = 9
Top = 240
Width = 255
End
Begin VB.Label lblDrkBlue
BackColor = &H00FF0000&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1200
TabIndex = 8
Top = 0
Width = 255
End
Begin VB.Label lblYellow
BackColor = &H0000FFFF&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 960
TabIndex = 7
Top = 240
Width = 255
End
Begin VB.Label lblRed
BackColor = &H000000FF&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 960
TabIndex = 6
Top = 0
Width = 255
End
Begin VB.Label lblWhite
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 480
TabIndex = 5
Top = 240
Width = 255
End
Begin VB.Label lblBlack
BackColor = &H00000000&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 480
TabIndex = 4
Top = 0
Width = 255
End
Begin VB.Label lblColor
BackColor = &H80000008&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 120
TabIndex = 3
Top = 120
Width = 255
End
End
Begin MSComctlLib.StatusBar StatusBar
Align = 2 'Align Bottom
Height = 255
Left = 0
TabIndex = 1
Top = 3735
Width = 5670
_ExtentX = 10001
_ExtentY = 450
Style = 1
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 2
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Alignment = 2
AutoSize = 2
Enabled = 0 'False
Object.Width = 2461
MinWidth = 2469
Key = "CurPos"
EndProperty
BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
Style = 5
AutoSize = 2
Object.Width = 1111
MinWidth = 988
TextSave = "22:56"
EndProperty
EndProperty
End
Begin VB.PictureBox picBitmap
AutoRedraw = -1 'True
BackColor = &H80000009&
Height = 3135
Left = 450
MousePointer = 99 'Custom
ScaleHeight = 205
ScaleMode = 3 'Pixel
ScaleWidth = 341
TabIndex = 0
Top = 1
Width = 5175
Begin VB.Line StLine
Visible = 0 'False
X1 = 16
X2 = 16
Y1 = 80
Y2 = 96
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim ShiftPressed As Boolean
Dim ControlPressed As Boolean
Dim PenTool As Boolean
Dim LineTool As Boolean
Dim EraseTool As Boolean
Private Sub Command1_Click()
PenTool = True
LineTool = False
EraseTool = False
End Sub
Private Sub Command2_Click()
EraseTool = False
PenTool = False
LineTool = True
End Sub
Private Sub Command3_Click()
EraseTool = True
PenTool = False
LineTool = False
End Sub
Private Sub Form_Resize()
On Error Resume Next
picBitmap.Top = 0
picBitmap.Width = Form1.ScaleWidth
picBitmap.Height = Form1.ScaleHeight - ColorsToolbar.Height - StatusBar.Height - 100
End Sub
Private Sub lblBlack_Click()
lblColor.BackColor = lblBlack.BackColor
End Sub
Private Sub lblDarkGrey_Click()
lblColor.BackColor = lblDarkGrey.BackColor
End Sub
Private Sub lblDrkBlue_Click()
lblColor.BackColor = lblDrkBlue.BackColor
End Sub
Private Sub lblDrkGreen_Click()
lblColor.BackColor = lblDrkGreen.BackColor
End Sub
Private Sub lblDrkP_Click()
lblColor.BackColor = lblDrkP.BackColor
End Sub
Private Sub lblLgtBlue_Click()
lblColor.BackColor = lblLgtBlue.BackColor
End Sub
Private Sub lblLgtGreen_Click()
lblColor.BackColor = lblLgtGreen.BackColor
End Sub
Private Sub lblLgtGrey_Click()
lblColor.BackColor = lblLgtGrey.BackColor
End Sub
Private Sub lblLgtP_Click()
lblColor.BackColor = lblLgtP.BackColor
End Sub
Private Sub lblRed_Click()
lblColor.BackColor = lblRed.BackColor
End Sub
Private Sub lblWhite_Click()
lblColor.BackColor = lblWhite.BackColor
End Sub
Private Sub lblYellow_Click()
lblColor.BackColor = lblYellow.BackColor
End Sub
Private Sub picBitmap_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift Then
ShiftPressed = True
End If
If KeyCode = vbKeyControl Then
ControlPressed = True
End If
End Sub
Private Sub picBitmap_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift Then
ShiftPressed = False
End If
If KeyCode = vbKeyControl Then
ControlPressed = False
End If
End Sub
Private Sub picBitmap_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
picBitmap.CurrentX = X
picBitmap.CurrentY = Y
End Sub
Private Sub picBitmap_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
StatusBar.SimpleText = X & ":" & Y
If PenTool = True Then
If Button = 1 And ShiftPressed = True Then
picBitmap.Line (picBitmap.CurrentX, picBitmap.CurrentY)-(X, picBitmap.CurrentY), lblColor.BackColor
ElseIf Button = 1 And ControlPressed = True Then
picBitmap.Line (picBitmap.CurrentX, picBitmap.CurrentY)-(picBitmap.CurrentX, Y), lblColor.BackColor
ElseIf Button = 1 Then
picBitmap.Line (picBitmap.CurrentX, picBitmap.CurrentY)-(X, Y), lblColor.BackColor
End If
End If
If LineTool = True Then
If Button = 1 Then
StLine.Visible = True
StLine.BorderColor = lblColor.BackColor
StLine.X1 = picBitmap.CurrentX
StLine.X2 = X
StLine.Y1 = picBitmap.CurrentY
StLine.Y2 = Y
End If
End If
If EraseTool = True Then
If Button = 1 And ShiftPressed = True Then
picBitmap.Circle (X, Y), 4, picBitmap.BackColor
ElseIf Button = 1 And ControlPressed = True Then
picBitmap.Circle (X, Y), 4, picBitmap.BackColor
ElseIf Button = 1 Then
picBitmap.Circle (X, Y), 4, picBitmap.BackColor
End If
End If
End Sub
Private Sub picBitmap_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LineTool = True Then
If Button = 1 Then
StLine.Visible = False
picBitmap.Line (picBitmap.CurrentX, picBitmap.CurrentY)-(X, Y), lblColor.BackColor
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -