📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "程序运行时智能增减控件"
ClientHeight = 3120
ClientLeft = 60
ClientTop = 345
ClientWidth = 5115
LinkTopic = "Form1"
ScaleHeight = 3120
ScaleWidth = 5115
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command2
Caption = "退出"
Height = 315
Left = 3645
TabIndex = 7
Top = 2745
Width = 1425
End
Begin VB.TextBox Text1
Alignment = 2 'Center
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Index = 0
Left = 240
TabIndex = 6
Text = "ab|"
Top = 1860
Width = 585
End
Begin VB.TextBox Text4
Height = 270
Left = 1125
TabIndex = 4
Text = "1"
Top = 1950
Visible = 0 'False
Width = 855
End
Begin VB.TextBox Text3
Height = 300
Left = 1140
TabIndex = 3
Text = "Text3"
Top = 1650
Visible = 0 'False
Width = 1245
End
Begin VB.TextBox Text2
Height = 300
Left = 1155
TabIndex = 2
Text = "Text2"
Top = 2235
Visible = 0 'False
Width = 1155
End
Begin VB.CommandButton Command1
BackColor = &H00FF8080&
Height = 375
Index = 0
Left = 270
Style = 1 'Graphical
TabIndex = 0
Top = 750
Width = 480
End
Begin VB.Label Label3
Caption = "点击鼠标左键增加控件;点击鼠标右键删除控件"
Height = 225
Left = 1275
TabIndex = 8
Top = 75
Width = 3810
End
Begin VB.Label Label2
Caption = "可供自动添加的控件"
Height = 390
Left = 90
TabIndex = 5
Top = 135
Width = 945
End
Begin VB.Shape Shape1
BorderWidth = 2
Height = 3045
Left = 30
Top = 45
Width = 1065
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H00C0FFC0&
Caption = "A"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 270
TabIndex = 1
Top = 1290
Width = 480
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub Label1_Click(Index As Integer)
Text4.Text = 3
End Sub
Private Sub Label1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And Index > 0 Then
Unload Label1(Index) '删除label控件
End If
End Sub
Private Sub Text1_Click(Index As Integer)
Text4.Text = 2
End Sub
Private Sub Text1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And Index > 0 Then
Unload Text1(Index) '删除text控件
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim mouse As POINTAPI
GetCursorPos mouse
Text2.Text = Val(mouse.X) * 15 - Me.Left - 50
Text3.Text = Val(mouse.Y) * 15 - Me.Top - 300
If Text2.Text > 1000 Then
If Text4.Text = 1 Then
If Button = 1 Then '添加command控件
i = Command1.ubound + 1
Load Command1(i)
Command1(i).Left = Text2.Text
Command1(i).Top = Text3.Text
Command1(i).Caption = Str(i)
Command1(i).Visible = True
End If
End If
If Text4.Text = 2 Then
If Button = 1 Then '添加text控件
i = Text1.ubound + 1
Load Text1(i)
Text1(i).Left = Text2.Text
Text1(i).Top = Text3.Text
Text1(i).Visible = True
End If
End If
If Text4.Text = 3 Then
If Button = 1 Then '添加label控件
i = Label1.ubound + 1
Load Label1(i)
Label1(i).Left = Text2.Text
Label1(i).Top = Text3.Text
Label1(i).Caption = Str(i)
Label1(i).Visible = True
End If
End If
End If
End Sub
Private Sub Command1_Click(Index As Integer)
Text4.Text = 1
End Sub
Private Sub Command1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And Index > 0 Then
Unload Command1(Index) '删除command控件
End If
End Sub
Private Sub Command2_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -