Disable Scrollbar from a Form MDI Container

2

Does anyone know how to prevent Child Forms from moving across the screen and displaying a scrollbar?

I wish there was a limit to move the Child Forms ... That they only move up to the size of the screen and do not pass it

I do not want scrollbars in the main form.

Thank you in advance!

    
asked by anonymous 01.06.2015 / 22:53

1 answer

1

Correct me if I'm wrong, but to disable you can follow these attempts:

  • Has some control inside the form that is extending the size of it, or is larger than the window itself.
  • Change the property AutoScroll to False .
  • Change the property AutoScaleMode to Dpi .
  • Move some controls to a location visible in the window.

Not resolved? I found this template in this file . Try the following:

1. Declare this function

<DllImport("user32.dll")> _
Private Shared Function ShowScrollBar(ByVal hWnd As IntPtr, ByVal wBar As Integer, ByVal bShow As Integer) As Integer
End Function

2. Declare the Wnd method

Protected Overrides Sub WndProc(ByRef m As Message)
    If mdiClient IsNot Nothing Then
        'Oculta as barras
        ShowScrollBar(mdiClient.Handle, SB_BOTH, 0)
    End If
    MyBase.WndProc(m)
End Sub

3. Declare this field

Private mdiClient As MdiClient = Nothing

4. Put this in the initialization method of your initializer class

For Each c As Control In Me.Controls
   'Procura os clientes MDI na sua janela

    If TypeOf c Is MdiClient Then
       mdiClient = CType(c, MdiClient)
    End If
Next
    
02.06.2015 / 23:06