Results 1 to 4 of 4

Thread: MDI Maximize button Grrrrrrrrrrrr

  1. #1
    Guest

    Angry

    Hello,

    Dose anybody know the API call to disable the Maximize button on a MDI form. I have spent 21/2 hours searching through the MSDS Library and I have absolutely no luck at all.

    Thank you in advance,

    Roger

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    You can eliminate the command of "maximize" from the popup menu of your task. You could also do it with the "minimize", "close", etc.

    Code:
    Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    
    Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
    Public Const MF_BYPOSITION = &H400&
    Public Const MF_REMOVE = &H1000&
    
    Sub NoMaximize()
        Dim hSysMenu As Long
        Dim nCnt As Long
        
        ' Get handle to our form's system menu
        ' (Restore, Maximize, Move, close etc.)
    
        hSysMenu = GetSystemMenu(Me.hwnd, False)
        
        If hSysMenu Then
            ' Get System menu's menu count\
            nCnt = GetMenuItemCount(hSysMenu)
                    
            If nCnt Then
                ' Menu count is based on 0 (0, 1, 2, 3...)
                RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE  'Remove the close
                RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE  ' Remove el separator (--------)
                RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION Or MF_REMOVE  ' Remove the maximize            
                RemoveMenu hSysMenu, nCnt - 4, MF_BYPOSITION Or MF_REMOVE  ' Remove the minimize
                RemoveMenu hSysMenu, nCnt - 5, MF_BYPOSITION Or MF_REMOVE  ' Remove the size
                RemoveMenu hSysMenu, nCnt - 6, MF_BYPOSITION Or MF_REMOVE  ' Remove the move        
                DrawMenuBar Me.hwnd
            End If
        End If
    end sub
    Hope this was what you were looking for, and get it work. It really works, but don't know if I forgot to paste some other declaration, or something.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I´ve no idea why, but the RemoveMenu lines should not be comments. Let´s paste it again. This lines should be executed or not, whether you wnat to disable that action or not.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4
    Guest

    Thumbs up

    Hello Mc Brain,

    Thank you very very much!

    I will give it a go.

    Thank you again.

    Roger

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