Results 1 to 10 of 10

Thread: Disable sizing of MDIform

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Cool

    Megatron helped with the min, max, x disabling. Thanks.

    Is there a way to stop the user from resizing?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  2. #2
    Guest
    Remove the Size commmand like you did with the rest.
    Code:
    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 Const MF_BYPOSITION = &H400&
    
    Private Sub Form_Load()
        RemoveMenu GetSystemMenu(hwnd, 0), 2, MF_BYPOSITION
    End Sub

  3. #3
    Lively Member
    Join Date
    May 1999
    Posts
    100
    I tryed Megatron's code in Windows 2000 with VB6 sp4 and I could NOT stop the form to maximize if I dbl-click on the titlebar. sorry

    Code:
    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 Const MF_BYPOSITION = &H400&
    
    Private Sub Form_Load()
        RemoveMenu GetSystemMenu(hwnd, 0), 2, MF_BYPOSITION
    End Sub

  4. #4
    Guest
    That because the above example will stop the user from resizing the Form. If you want to prevent them from maximizing the Form, use the following code.

    Code:
    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 Const MF_BYPOSITION = &H400&
    
    Private Sub Form_Load()
        RemoveMenu GetSystemMenu(hwnd, 0), 4, MF_BYPOSITION
    End Sub

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441
    Gentlemen, first thanks for you responses.

    I just wanted to explain things better. I have a MDIform that is maximized on startup. I have disabled the min,restore, and x button. Double clicking on titlebar resizes and that is the problem.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  6. #6
    Guest
    The code I gave above should fix the problem.

  7. #7
    Lively Member
    Join Date
    May 1999
    Posts
    100
    Megatron - Yeah.. Now I see.. and it works.. great!

  8. #8
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Disable Maximize Button

    Megatron, the maximize button will not function, true.
    However, it is not grayed out. This looks better and is not confusing. Lets the user know it is disabled.

  9. #9
    Guest
    Here is how to keep a form/mdiform from being resized:

    Code:
    'Author: Megatron
    'Origin: http://forums.vb-world.net/showthread.php?postid=91647
    'Purpose: Keep a form from being resized.
    'Version: VB4+
    
    
    Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
    Dim LockWindow As Boolean
    Dim iWidth As Integer
    Dim iHeight As Integer
    
    Private Sub MDIForm_Load()
        'Save the initial dimensions
        iWidth = Me.Width
        iHeight = Me.Height
    End Sub
    
    Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        LockWindowUpdate 0&
    End Sub
    
    Private Sub MDIForm_Resize()
    On Error Resume Next
        Static FirstLoad
        
        'If this is the First time the Window is loading then don't lock it
        If FirstLoad = False Then
            FirstLoad = True
            LockWindow = True
            Exit Sub
        End If
        
        'Lock the Window when the User tries to resize it
        If LockWindow = True Then
            'Restore the dimensions
            Me.Width = iWidth
            Me.Height = iHeight
            LockWindowUpdate Me.hWnd
        End If
    End Sub

  10. #10
    Guest
    With simple API, using LockWindowUpdate is not necessary, however, that method is good if you don't want the menu completely reomved.

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