HOWTO: Suppress Maximize & Minimize Buttons on MDI Parent FormID: Q137033
|
This article shows by example how to suppress the maximize and minimize
buttons on an MDI parent form.
On non-MDI forms, you can set the MinButton and MaxButton properties to
False to disable the form's Minimize and Maximize buttons. However, these
properties are not available on an MDI parent form. To disable an MDI
form's Minimize and Maximize buttons, you need to use the SetWindowLong
Windows API function to change the style of the window.
Both of the following examples eliminate the Minimize and Maximize buttons
from the main MDI form (MDIForm1).
NOTE: Information in the Visual Basic versions 4.0 and 5.0 section applies
only to Visual Basic versions 4.0 and 5.0, and information in the Visual
Basic 3.0 section applies only to Visual Basic 3.0.
Private Sub MDIForm_Load()
Dim L as Long
L = GetWindowLong(Me.hWnd, GWL_STYLE)
L = L And Not (WS_MINIMIZEBOX)
L = L And Not (WS_MAXIMIZEBOX)
L = SetWindowLong(Me.hWnd, GWL_STYLE, L)
End Sub
#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 If
Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)
Sub MDIForm_Load()
Dim L as Long
L = GetWindowLong(Me.hWnd, GWL_STYLE)
L = L And Not (WS_MINIMIZEBOX)
L = L And Not (WS_MAXIMIZEBOX)
L = SetWindowLong(Me.hWnd, GWL_STYLE, L)
End Sub
' Enter the following Declare statement as one, single line:
Declare Function SetWindowLong Lib "User" (ByVal hwnd As Integer,
ByVal nIndex As Integer, ByVal dwNewLong As Long) As Long
' Enter the following Declare statement as one, single line:
Declare Function GetWindowLong Lib "User" (ByVal hwnd As Integer,
ByVal nIndex As Integer) As Long
Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)
Keywords : kbui kbVBp400 kbVBp500 kbhowto PrgCtrlsStd VB4WIN vbwin
Version : 3.0 4.0 5.0
Platform : NT WINDOWS
Issue type :
Last Reviewed: June 18, 1999