Disable Scrollbar from a Form MDI Container

Asked

Viewed 444 times

2

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

I wish there was a limit to moving the Child Forms... that they only move up to the screen size and do not go beyond that

inserir a descrição da imagem aqui

I don’t want scrollbars on the main form.

Thank you in advance!

1 answer

1


Correct me if I’m wrong, but to deactivate you can follow these attempts:

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

Didn’t you? I found this model on this filing cabinet. Try the following:

1. State 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
  • 1

    Cypherpotato, your tip worked dear! _ But there’s a problem with the visualization... The scrollbars are flashing like a lag or something when mdichild goes through the corners... I think the solution would be to assign the Mdichilds window as None and thus prevent them from moving... Seems like the best option

  • You can also create a Timer, with interval set to 1 millisecond, which when making the event Timer1.Tick can restore the location of a Mdichild to an object System.Drawing.Point (Local) fixed, then when the user tries to move it it will go back to the Timer location. Here’s the hint ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.