CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 1999
    Location
    Pakistan
    Posts
    366

    Disabling the Maximiza button on MDIForm

    Dear All,
    How can I disable the Maximize button on an MDIForm
    Eagerly waiting for a response...


  2. #2
    Join Date
    Feb 2000
    Location
    United Arab Emirates
    Posts
    11

    Re: Disabling the Maximiza button on MDIForm

    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


  3. #3
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    96

    Re: Disabling the Maximiza button on MDIForm

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured