I'm trying to turn the Maximize & Minimize buttons off on my Child forms but it doesn't seem to be working. I have set the Max and Min on the form to false but that doesn't seem to work.

Also, how can I make the child form fill the available space automatically, no matter the size of the Parent form.

set FormBoarderStyle to FixedToolWindow

The maximized is still an option.

set the MaximumSize and MinimumSize property on the form to ur form size .

The only option I have are these.

MaximizeBox : Boolean
MaximumSize : 0,0
MinimizeBox : Boolean
MinimumSize : 0,0

set MaximumSize=500,500
MinimumSize=500,500

change 500 with ur value.

That still doesn't take the double box icon next to the X away.

It's hard to set that on the child forms because the Parent form has the ability to be maximized which would make it larger than the initial sizes set.

Member Avatar for Unhnd_Exception

I don't know why you can't turn them off by setting the maximizebox and minimizebox to false.

You can try this.

Put the MakeFormCloseOnly sub in the load event.

Private Const GWL_STYLE As Integer = -16 'Retrieves the window style
    Private Const WS_MAXIMIZEBOX As Long = 65536
    Private Const WS_MINIMIZEBOX As Long = 131072

    'Used to set the window style of the form
    <System.Runtime.InteropServices.DllImport("user32.dll")> _
    Private Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
    End Function

    'Used to get the window style of the form
    <System.Runtime.InteropServices.DllImport("user32.dll")> _
    Private Shared Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    End Function


    Private Sub MakeFormCloseOnly()

        'Get the bitwise combination of the current window style
        Dim CurrentWindowStyle As Long = GetWindowLong(Me.Handle, GWL_STYLE)

        'Test if the maximize style is in the combination.
        If (CurrentWindowStyle And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX Then
            'It is. Use Xor to strip the style.
            CurrentWindowStyle = CurrentWindowStyle Xor WS_MAXIMIZEBOX
        End If

        'Do the same for the minimize.
        If (CurrentWindowStyle And WS_MINIMIZEBOX) = WS_MINIMIZEBOX Then
            CurrentWindowStyle = CurrentWindowStyle Xor WS_MINIMIZEBOX
        End If

        'Set the new style that contains no maximize or minimize styles.
        SetWindowLong(Me.Handle, GWL_STYLE, CurrentWindowStyle)

    End Sub

What do you mean by make the child form fill the available space.
The screen? is it a mdi child and fill the mdi's parent client rectangle?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.