form1.frm
来自「很好的教程原代码!」· FRM 代码 · 共 79 行
FRM
79 行
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text1
Height = 1935
Left = 120
TabIndex = 1
Text = "Text1"
Top = 360
Width = 4335
End
Begin VB.CommandButton Command1
Caption = "改变控件尺寸"
Height = 495
Left = 1560
TabIndex = 0
Top = 2520
Width = 1335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'API函数声明
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long _
) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long _
) As Long
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long _
) As Long
'使用常量声明
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_NOMOVE = &H2
Const SWP_DRAWFRAME = &H20
Const GWL_STYLE = (-16)
Const WS_THICKFRAME = &H40000
'
'按钮单击,使文本框可以自由改变大小
Private Sub Command1_Click()
Resize Text1, Form1
End Sub
'
'使控件大小可以自由改变的函数
'第一个参数为要作用的控件
'第二个参数为控件所在的窗体
Sub Resize(ControlName As Control, FormName As Form)
Dim NewStyle As Long
NewStyle = GetWindowLong(ControlName.hwnd, GWL_STYLE)
NewStyle = NewStyle Or WS_THICKFRAME
NewStyle = SetWindowLong(ControlName.hwnd, GWL_STYLE, NewStyle)
SetWindowPos ControlName.hwnd, FormName.hwnd, 0, 0, 0, 0, SWP_NOZORDER _
Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?