I have an mdi form and few child forms. I have set the autoscroll property to false, size to (640,480) for the mdi form, but still the scrollbars are shown. I am setting the width of the child forms on mdi resize event to the width of mdi parent. My requirement is that the mdi parent should not show scrollbars at all for the entire life of the application. What are the properties that I need to set additionally?
Is the scrollbars of the MDI parent always there, or does it appear when a child form is dragged past the MDI form's edge?
I did a small test ( based on your description ), and the scrollbars of the MDI only appear if I dragged the child windows past the MDI form's borders...
I am working on a vb6 to vb.net migration. Initially, in the vb6 application, there are no scrollbars shown even though the width of the child form is greater than that of the mdi parent form. But after migration to vb.net, the scrollbars are shown. Is there a way to hide the scrollbars, though the child form is dragged past the edges of the parent mdi form.Then I added the below code in the Resize event of the parent mdi form,
For Each frm In Me.MdiChildren
frm.Width = Me.Width
Next
You'll have to override your MDI Parent's WndProc procedure and use the ShowScrollBar API
My code looks like this :
Code:
Imports System.Runtime.InteropServices
Public Class Form1
Private Const SB_BOTH As Integer = 3
Private Const WM_NCCALCSIZE As Integer = &H83
<DllImport("user32.dll")> _
Private Shared Function ShowScrollBar(ByVal hWnd As IntPtr, ByVal wBar As Integer, ByVal bShow As Integer) As Integer
End Function
Protected Overrides Sub WndProc(ByRef m As Message)
If mdiClient IsNot Nothing Then
'Hide the ScrollBars
ShowScrollBar(mdiClient.Handle, SB_BOTH, 0)
End If
MyBase.WndProc(m)
End Sub
Private mdiClient As MdiClient = Nothing
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
For Each c As Control In Me.Controls
'Find the MdiClient in the MdiWindow
If TypeOf c Is MdiClient Then
mdiClient = TryCast(c, MdiClient)
End If
Next
Dim F2 As New Form2
F2.MdiParent = Me
F2.Show()
Dim F3 As New Form3
F3.MdiParent = Me
F3.Show()
End Sub
End Class
I did notice some little flickering when the child forms are moved past the edges, though, so it's not 100% perfect, unless you're not moving your child windows at all
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.