Dear All,
How can I disable the Maximize button on an MDIForm
Eagerly waiting for a response...
Printable View
Dear All,
How can I disable the Maximize button on an MDIForm
Eagerly waiting for a response...
Just a guess will it be okay, thwi will make form to be always in normal state.
Private Sub MDIForm_Resize()
If Me.WindowState <> 0 Then Me.WindowState = 0
End Sub
Paste this code into your MDIForm's code module
private Declare Function RemoveMenu Lib "user32" (byval hMenu as Long, byval nPosition as Long, byval wFlags as Long) as Long
private Declare Function GetSystemMenu Lib "user32" (byval hWnd as Long, byval bRevert as Long) as Long
private Declare Function GetMenuItemCount Lib "user32" (byval hMenu as Long) as Long
private Declare Function GetMenuItemID Lib "user32" (byval hMenu as Long, byval nPos as Long) as Long
private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (byval hWnd as Long, byval nIndex as Long) as Long
private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (byval hWnd as Long, byval nIndex as Long, byval dwNewLong as Long) as Long
'
private Const GWL_STYLE = (-16)
'
private Const WS_MAXIMIZE = &H1000000
private Const WS_MAXIMIZEBOX = &H10000
'
private Const SC_MAXIMIZE = &HF030&
'
private Const MF_BYPOSITION = &H400&
'
private Sub MDIForm_Load()
Dim lngHSysMenu as Long
Dim lngCount as Long
Dim lngPos as Long
Dim lngID as Long
'
lngHSysMenu = GetSystemMenu(me.hWnd, false)
lngCount = GetMenuItemCount(lngHSysMenu)
'
for lngPos = 0 to (lngCount - 1)
lngID = GetMenuItemID(lngHSysMenu, lngPos)
If lngID = SC_MAXIMIZE then
RemoveMenu lngHSysMenu, lngPos, MF_BYPOSITION
Exit for
End If
next
RemoveMaxBox
End Sub
'
private Sub RemoveMaxBox()
Dim lngStyle as Long
'
lngStyle = GetWindowLong(me.hWnd, GWL_STYLE)
lngStyle = lngStyle And Not WS_MAXIMIZEBOX
SetWindowLong me.hWnd, GWL_STYLE, lngStyle
End Sub
Hope this helps,
Rippin