- 精华
- 活跃值
-
- 积分
- 229
- 违规
-
- 印币
-
- 鲜花值
-
- 在线时间
- 小时
累计签到:152 天 连续签到:1 天
|
发表于 2019-5-19 20:29:30
|
显示全部楼层
- 'VBA窗体可调大小,放在窗体代码中
- Option Explicit
- 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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Private Declare Function DrawMenuBar Lib "user32" (ByVal Hwnd As Long) As Long
- Private Const GWL_STYLE = (-16) '窗口样式
- Private Const WS_THICKFRAME = &H40000 '可更改大小
- Private Const WS_THICKFRAME As Long = &H40000 ’(恢复大小)
- Private Const WS_MINIMIZEBOX As Long = &H20000 ’(最小化)
- Private Const WS_MAXIMIZEBOX As Long = &H10000 ’(最大化)
- Private Sub UserForm_Initialize()
- Dim Hwnd As String, MyType As String
- Hwnd = FindWindow("ThunderDFrame", Me.Caption) '取得窗口句柄
- MyType = GetWindowLong(Hwnd, GWL_STYLE) '取得窗口样式
- MyType = MyType Or WS_THICKFRAME '重新设置窗口样式
- MyType = MyType Or WS_MAXIMIZEBOX '添加最大化按钮
- MyType = MyType Or WS_MINIMIZEBOX '添加最小化按钮
- SetWindowLong Hwnd, GWL_STYLE, MyType '应用样式
- DrawMenuBar (Hwnd) '重绘窗体
- End Sub
- Private Sub UserForm_Resize() '//定义窗体大小变化后控件位置及尺寸变化
- End Sub
复制代码 |
|