Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As LongPtr, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function ShowWindow Lib "user32" _
(ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const SW_MAXIMIZE = 3
Private Const WS_SIZEBOX = &H40000
Dim hWnd As LongPtr, uStyle As Long, OldWidth As Double, OldHeight As Double
Private Sub UserForm_Initialize()
OldWidth = Me.Width: OldHeight = Me.Height
hWnd = FindWindow("ThunderDFrame", Me.Caption)
uStyle = GetWindowLong(hWnd, GWL_STYLE)
SetWindowLong hWnd, GWL_STYLE, uStyle + WS_SIZEBOX + WS_MINIMIZEBOX + WS_MAXIMIZEBOX
End Sub
Private Sub UserForm_Activate()
ShowWindow hWnd, SW_MAXIMIZE
End Sub
Private Sub UserForm_Terminate()
SetWindowLong hWnd, GWL_STYLE, uStyle
End Sub
Private Sub UserForm_Resize()
Dim lW As Long, lH As Long, lngZoom As Long
lW = Round(Me.Width / OldWidth * 100, 0)
lH = Round(Me.Height / OldHeight * 100, 0)
lngZoom = IIf(lW > lH, lH, lW)
If lngZoom > 400 Then lngZoom = 400
If lngZoom < 10 Then lngZoom = 10
Zoom = lngZoom
End Sub