Option Explicit
'----------Private Function (PtrSafe for Windows x86)-------------------------------------
Private Declare PtrSafe Function StartWindow Lib "user32" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function MoveWindow Lib "user32" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Const CURRENT_SIZE As Long = (-16) '// New window NewSize
'-----------Window NewSize------------------------------------------------------------------
Private Const UF_MIN As Long = &H20000 '// Minimize button
Private Const UF_MAX As Long = &H10000 '// Maximize button
'----------Variable Module----------------------------------------------------------------
Dim UF_Resized As Long
Dim NewSize As Long
Private Sub MultiPage1_Change()
End Sub
Private Sub UserForm_Initialize()
' Me.Width = wsMenu.Range("UFW")
' Me.Height = wsMenu.Range("UFH")
' Call X1cFormResize
UF_Resized = FindWindowA(vbNullString, Me.Caption)
NewSize = StartWindow(UF_Resized, CURRENT_SIZE)
' NewSize = NewSize Or UF_MIN '//Minimize button
NewSize = NewSize Or UF_MAX '//Maximize button
MoveWindow UF_Resized, CURRENT_SIZE, (NewSize)
End Sub
Private Sub Cmd_Quit_Click()
Me.Hide
Unload Me
End Sub
Private Sub X1cFormResize()
Application.WindowState = xlMaximized
If ActiveWindow.Width > Me.Width And ActiveWindow.Height > Me.Height Then Exit Sub
If (Round((ActiveWindow.Width * 0.98) / Me.Width, 2) * 100) - 1 < _
(Round((ActiveWindow.Height * 0.98) / Me.Height, 2) * 100) - 1 Then
Me.Zoom = (Round((ActiveWindow.Width * 0.98) / Me.Width, 2) * 100) - 1
Me.Width = Me.Width * Me.Zoom / 100
Me.Height = Me.Height * Me.Zoom / 100
Else
Me.Zoom = (Round((ActiveWindow.Height * 0.98) / Me.Height, 2) * 100) - 1
Me.Width = Me.Width * Me.Zoom / 100
Me.Height = Me.Height * Me.Zoom / 100
End If
End Sub