Add A Minimize Button To Form That Has Fixed Border

If you set the form border to be Fixed Single or Fixed Dialog, the form will appear without the minimize button. This code shows you how to fix this problem.


Set the form BorderStyle property to 1 - Fixed Single or 3 - Fixed Dialog.

Module Code

Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
   (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
   (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000

Form Code

Private Function AddMinimizeButton(po_Form As Form)
   Dim ll_Style As Long
   'Get window style
   ll_Style = GetWindowLong(po_Form.hwnd, GWL_STYLE)
   'Add the minimize button
Call SetWindowLong(po_Form.hwnd, GWL_STYLE, ll_Style Or WS_MINIMIZEBOX)
End Function
Private Sub Form_Load()
    AddMinimizeButton Me
End Sub

Go Back