Стандартные средства не позволяют свернуть форму VBA или развернуть на весь экран. Но это можно сделать при помощи WinAPI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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 Const WS_MINIMIZEBOX = &H20000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const GWL_STYLE = (-16)
Public Sub ChangeWindow(f As UserForm)
Dim hwnd As Long
Dim retval As Long
hwnd = FindWindow("ThunderDFrame", f.Caption)
If hwnd <> 0 Then
retval = SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
End If
If retval = 0 Then MsgBox "Fail"
End Sub |
1
2
3
| Private Sub UserForm_Initialize()
Call ChangeWindow(Me)
End Sub |
Результат для формы из
старого документа:
Комментариев нет:
Отправить комментарий