⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 本文件包含200个visual baisc实例
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   Caption         =   "一个简易的画图程序"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6330
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   6330
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command5 
      Caption         =   "退出"
      Height          =   375
      Left            =   5280
      TabIndex        =   10
      Top             =   2775
      Width           =   975
   End
   Begin VB.CommandButton Command4 
      Caption         =   "清除画布"
      Height          =   375
      Left            =   4230
      TabIndex        =   6
      Top             =   2775
      Width           =   975
   End
   Begin VB.CommandButton Command3 
      Caption         =   "保存文件"
      Height          =   375
      Left            =   3180
      TabIndex        =   5
      Top             =   2775
      Width           =   975
   End
   Begin VB.CommandButton Command2 
      Caption         =   "打开文件"
      Height          =   375
      Left            =   2115
      TabIndex        =   4
      Top             =   2775
      Width           =   975
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   1245
      Top             =   2175
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.ComboBox Combo1 
      ForeColor       =   &H00FF0000&
      Height          =   300
      ItemData        =   "Form1.frx":0000
      Left            =   270
      List            =   "Form1.frx":0002
      TabIndex        =   2
      Text            =   "2"
      Top             =   945
      Width           =   1530
   End
   Begin VB.CommandButton Command1 
      Caption         =   "画笔颜色"
      Height          =   375
      Left            =   300
      TabIndex        =   1
      Top             =   210
      Width           =   1530
   End
   Begin VB.PictureBox Picture1 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00FFFFFF&
      DrawWidth       =   2
      Height          =   2625
      Left            =   2130
      ScaleHeight     =   2565
      ScaleWidth      =   4035
      TabIndex        =   0
      Top             =   60
      Width           =   4095
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Height          =   405
      Index           =   1
      Left            =   540
      TabIndex        =   9
      Top             =   1890
      Width           =   690
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Height          =   360
      Index           =   2
      Left            =   615
      TabIndex        =   8
      Top             =   2460
      Width           =   540
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Height          =   405
      Index           =   0
      Left            =   585
      TabIndex        =   7
      Top             =   1365
      Width           =   690
   End
   Begin VB.Line Line1 
      X1              =   660
      X2              =   1035
      Y1              =   1410
      Y2              =   1695
   End
   Begin VB.Shape Shape2 
      Height          =   450
      Left            =   570
      Shape           =   3  'Circle
      Top             =   2415
      Width           =   600
   End
   Begin VB.Shape Shape1 
      Height          =   450
      Left            =   570
      Top             =   1875
      Width           =   600
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "设置画笔的尺寸:"
      Height          =   180
      Left            =   270
      TabIndex        =   3
      Top             =   690
      Width           =   1425
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim oldx, oldy, shape As Integer

Private Sub Combo1_Change()
  Picture1.DrawWidth = Int(Combo1.Text)
End Sub

Private Sub Combo1_Click()
  Picture1.DrawWidth = Int(Combo1.Text)
End Sub

Private Sub Form_Load()
  Dim i As Integer
  shape = 1
  Do While i <= 40
     i = i + 2
     Combo1.AddItem Str(i)
  Loop
End Sub

Private Sub Label2_Click(Index As Integer)
  Select Case Index
    Case 0
      shape = 0
    Case 1
      shape = 1
    Case 2
      shape = 2
  End Select
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  oldx = X
  oldy = Y
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If shape = 0 Then Picture1.Line (oldx, oldy)-(X, Y)
  If shape = 1 Then
     Picture1.Line (oldx, oldy)-(oldx, Y)
     Picture1.Line (oldx, oldy)-(X, oldy)
     Picture1.Line (oldx, Y)-(X, Y)
     Picture1.Line (X, oldy)-(X, Y)
  End If
  If shape = 2 Then
     If Abs(X - oldx) > Abs(Y - oldy) Then radius = Abs(Y - oldy) Else radius = Abs(X - oldx)
     Picture1.Circle (oldx, oldy), radius
  End If
End Sub

Private Sub Command1_Click()
  CommonDialog1.ShowColor
  Picture1.ForeColor = CommonDialog1.Color
End Sub

Private Sub Command2_Click()
  CommonDialog1.Filter = "BMP文件|*.bmp"
  CommonDialog1.ShowOpen
  If CommonDialog1.FileName <> "" Then
     Picture1.Picture = LoadPicture(CommonDialog1.FileName)
  End If
End Sub

Private Sub Command3_Click()
  CommonDialog1.Filter = "BMP文件|*.bmp"
  CommonDialog1.ShowSave
  If CommonDialog1.FileName <> "" Then
     SavePicture Picture1.Image, CommonDialog1.FileName
  End If
End Sub

Private Sub Command4_Click()
  Picture1.Cls
End Sub

Private Sub Command5_Click()
  End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -