Solved

ScrollBar on MDI Child Form.

Posted on 1998-10-06
1
1,010 Views
Last Modified: 2008-03-17
When I resize my MDI child form, controls on the border of form are miss. How can I make the scrollber relate with the MDI child form.
0
Comment
Question by:chiab
1 Comment
 
LVL 2

Accepted Solution

by:
schild earned 100 total points
ID: 1438537
This is an artical from MSDN
Article ID: Q109741

This is good for any kind of a form

1. Start a new project in Visual Basic. Form1 is created by default.

2. Add a horizontal scroll bar control and a vertical scroll bar control to Form1. (The size doesn't matter because the program automatically sizes the scroll bars in the Form Resize event code.)

3. Add a picture box control to Form1. Draw a text box control inside the upper-left corner of the picture box such that when the picture box moves, the text box moves with it.
Select the Text1 box and press the F4 key to display the Properties window. Set the Text1 Index property to 0, which is required at design time to make an array of text controls.

You can also enhance this sample program by placing more controls into the picture box. When the picture box scrolls, all the controls scroll.


4. Add the following code to the Form Load event:

      Sub Form_Load ()
         ' Make the picture box bigger than the form:
         Picture1.Move 0, 0, 1.4 * ScaleWidth, 1.2 * ScaleHeight ' Place
            some sample controls in the picture box:
         Dim i As Integer
         For i = 1 To 20
            Load Text1(i)
            Text1(i).Visible = True
            Text1(i).Left = i * Picture1.Height / 20
            Text1(i).Top = Text1(i).Left
         Next
      End Sub


5. Add the following code to the Form Resize event:

      Sub Form_Resize ()
         ' Position the scroll bars:
         hscroll1.Left = 0
         vscroll1.Top = 0
         If Picture1.Width > scalewidth Then
            hscroll1.Top = ScaleHeight - hscroll1.Height
         Else
            hscroll1.Top = ScaleHeight
         End If
         If Picture1.Height > hscroll1.Top Then
            vscroll1.Left = scalewidth - vscroll1.Width
            If Picture1.Width > vscroll1.Left Then
               hscroll1.Top = ScaleHeight - hscroll1.Height
            End If
         Else
            vscroll1.Left = scalewidth
         End If
         hscroll1.Width = scalewidth
         If hscroll1.Top > 0 then vscroll1.Height=hscroll1.Top
         ' Set the scroll bar ranges
         hscroll1.Max = Picture1.Width - vscroll1.Left
         vscroll1.Max = Picture1.Height - hscroll1.Top
         hscroll1.SmallChange = Abs(hscroll1.Max \ 16) + 1
         hscroll1.LargeChange = Abs(hscroll1.Max \ 4) + 1
         vscroll1.SmallChange = Abs(vscroll1.Max \ 16) + 1
         vscroll1.LargeChange = Abs(vscroll1.Max \ 4) + 1
         hscroll1.ZOrder 0
         vscroll1.ZOrder 0
      End Sub


6. Add the following code to the HScroll1 Change event:

      Sub HScroll1_Change ()
         Picture1.Left = -HScroll1.Value
      End Sub


7. Add the following code to the VScroll1 Change event:

      Sub VScroll1_Change ()
         Picture1.Top = -VScroll1.Value
      End Sub


8. Start the program (or press the F5 key). Click the scroll bars to scroll the form. Close the form to end the program.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now