CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2010
    Posts
    18

    [RESOLVED] Scroll Bars MDI Form

    Hi,

    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?

    Thanx

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Scroll Bars MDI Form

    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...

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Scroll Bars MDI Form

    Show your code. If the child form is fixed size, why resize it?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jun 2010
    Posts
    18

    Re: Scroll Bars MDI Form

    Hi,

    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

    and still the scrollbars are shown.


    Thanx.

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Talking Re: Scroll Bars MDI Form

    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'm attaching a sample with
    Attached Files Attached Files

  6. #6
    Join Date
    Jun 2010
    Posts
    18

    Re: Scroll Bars MDI Form

    Thank you so much. It worked like a charm....Once again thank you........

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: [RESOLVED] Scroll Bars MDI Form

    You're welcome, I'm always glad to have helped

    I did notice some little flickering when the child forms are moved past the edges, though, so it's not 100&#37; perfect, unless you're not moving your child windows at all

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

Featured