Results 1 to 4 of 4

Thread: Form - Minimum Size

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brisbane Australia
    Posts
    150

    Question Form - Minimum Size

    I am using docking and anchoring etc to allow the user to resize a data entry form at run time. I have set the minimum size at form load from the size of the form at that time so that the user cant resize it less than the size at load. However this works fine if the form is not an MDI child.

    Once I set it as an MDI Child, it seems to ignore the Minimum size properties I have set and the user can resize it to a tiny little form with just a title bar. I have tried putting code in the Resize event but just causes so much flicker that its unworkable - have I overlooked something -does minimumsize not apply to MDI Child FOrms ??

    any help would be appreciated

    thanks BH

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    This is a confirmed bug in the framework. Microsoft referes to SubClassing as aworkaround.... example:

    Code:
    Private Const WM_GETMINMAXINFO = &H24
    
    Private Structure POINTAPI
        Dim x As Integer
        Dim y As Integer
    End Structure
    
    Private Structure MINMAXINFO
        Dim ptReserved As POINTAPI
        Dim ptMaxSize As POINTAPI
        Dim ptMaxPosition As POINTAPI
        Dim ptMinTrackSize As POINTAPI
        Dim ptMaxTrackSize As POINTAPI
    End Structure
    
    
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If Me.IsMdiChild Then
            Select Case m.Msg
                Case WM_GETMINMAXINFO
                    Dim mmi As MINMAXINFO = m.GetLParam(GetType(MINMAXINFO))
                    mmi.ptMinTrackSize.x = Me.MinimumSize.Width
                    mmi.ptMinTrackSize.y = Me.MinimumSize.Height
                    mmi.ptMaxTrackSize.x = Me.MaximumSize.Width
                    mmi.ptMaxTrackSize.y = Me.MaximumSize.Height
                    System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, True)
            End Select
        End If
        MyBase.WndProc(m)
    End Sub
    Theres an easier way around if I remeber correctly, but I have that code at work, so I'll post that tomorrow if someone does not do it befor me.

    /Leyan

  3. #3
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Using the layout event is possible too. Heres an example for the MinimumSize:

    Code:
    Private Sub Document_Layout(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.LayoutEventArgs) Handles MyBase.Layout
    
        If (Me.Bounds.Width < Me.MinimumSize.Width) Then
            Me.Size = New Size(Me.MinimumSize.Width, Me.Size.Height)
        End If
    
        If (Me.Bounds.Height < Me.MinimumSize.Height) Then
            Me.Size = New Size(Me.Size.Width, Me.MinimumSize.Height)
        End If
    
    End Sub
    /Leyan

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brisbane Australia
    Posts
    150

    minimum size of form

    Thanks Athley, This works OK - I did achieve something similar using the resize event. Is there any way you know to stop the flicker when the user is trying toresize smaller than the minimum size.

    regards

    BH

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