How do you disable the minimize/maximize/exit buttons in the upper-right corner of a form control? I'd just like to grey them out.
Thanks in advance,
spanqy
Printable View
How do you disable the minimize/maximize/exit buttons in the upper-right corner of a form control? I'd just like to grey them out.
Thanks in advance,
spanqy
Add the following code to a module:
Regards.Code:Option Explicit
Public Const MF_BYPOSITION = &H400&
Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Sub DisableMinimizeButton(lhWnd As Long)
Dim hSystemMenu As Long
hSystemMenu = GetSystemMenu(lhWnd, 0)
Call RemoveMenu(hSystemMenu, 3, MF_BYPOSITION)
End Sub
Public Sub DisableMaxButton(lhWnd As Long)
Dim hSystemMenu As Long
hSystemMenu = GetSystemMenu(lhWnd, 0)
Call RemoveMenu(hSystemMenu, 4, MF_BYPOSITION)
End Sub
Public Sub DisableCloseWindow(lhWnd As Long)
Dim hSystemMenu As Long
hSystemMenu = GetSystemMenu(lhWnd, 0)
Call RemoveMenu(hSystemMenu, 6, MF_BYPOSITION)
Call RemoveMenu(hSystemMenu, 5, MF_BYPOSITION)
End Sub
The Min and Max buttons can be disabled by setting the MaxButton and MaxButton properties to false.