devxlogo

Remove Min/Max Buttons From MDI Form

Remove Min/Max Buttons From MDI Form

Unlike other forms, MDI forms don’t have MinButton and MaxButton properties to enable or disable the form’s Minimize and Maximize buttons. If you add this code to an MDI parent form’s Load event, it disables the Minimize and Maximize buttons on the MDI form. If you just want to disable one or the other, comment out the appropriate line, based on which constant you don’t need:

 Sub MDIForm_Load()	Dim lWnd as Long	lWnd = GetWindowLong(Me.hWnd, GWL_STYLE)	lWnd = lWnd And Not (WS_MINIMIZEBOX)	lWnd = lWnd And Not (WS_MAXIMIZEBOX)	lWnd = SetWindowLong(Me.hWnd, GWL_STYLE, lWnd)End Sub

Add this code (which includes the required API declarations) to a BAS module:

 #If Win32 Then	Private Declare Function SetWindowLong Lib "user32" _		Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal _		nIndex As Long, ByVal dwNewLong As Long) As Long	Private Declare Function GetWindowLong Lib "user32" _		Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal _		nIndex As Long) As Long#Else	Declare Function SetWindowLong Lib "User" (ByVal hwnd _		As Integer, ByVal nIndex As Integer, ByVal _		dwNewLong As Long) As Long	Declare Function GetWindowLong Lib "User" (ByVal hwnd _		As Integer, ByVal nIndex As Integer) As Long#End IfConst WS_MINIMIZEBOX = &H20000Const WS_MAXIMIZEBOX = &H10000Const GWL_STYLE = (-16)
See also  How to Create and Deploy QR Codes Online: A Comprehensive Guide
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist