Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Creating Scrollable MDI Child Forms

I am creating a Visual Basic 6 MDI application that is made up of numerous MDI child forms.  I would like for the child forms to have a vertical scroll bar that allows the user to scroll to view hard to see data.  I looked at the answer to question 10050026 from clsmaster and tried the code and it didn't work for me.  My vertical scroll bar kept shrinking to the top of my form.  In clsmaster's response there are several things that are unclear.  For instance, when he/she says set the tag property of the control to the top property on the control which control is he referring to?  Set the scroll bar control's tag property to the top property of the scroll bar or the form?  Also, there's no such thing as on local error resume next.  If someone could provide me with code that will allow me to add vertical and horizontal scroll bars to mdi child forms within a mdi environment to produce scrolling that is similiar to Microsoft Word, I would greatly appreciately.
0
lsmith2574
Asked:
lsmith2574
1 Solution
 
RuchiCommented:
0
 
paulstampCommented:
Ruchi... I dont see how that link helps - are you sure you got the URL right ?

To create scrollable forms I use the following technique :

Create a picture box to be the viewable area and call it picFrame and set it to the appropriate size (perhaps to cover the entire form). Then create another control inside this which will be the actual document itself (for this example I use a picture box called picCanvas).Set picCanvas's width and height properties to the actual size you want (not the visible area).

Add a vertical scrollbar and a horizontal scrollbar again into picFrame (not picCanvas). Then set the top and left properties of picCanvas to 0.

In picFrame_Resize event :

scrVertical.Left = picFrame.ScaleWidth - scrVertical.Width
    scrVertical.Height = picFrame.ScaleHeight - scrHorizontal.Height
    scrVertical.Max = picCanvas.Height - picFrame.ScaleHeight
   
    scrHorizontal.Width = picFrame.ScaleWidth - scrHorizontal.Left - scrVertical.Width
    scrHorizontal.Top = picFrame.ScaleHeight - scrHorizontal.Height
    scrHorizontal.Max = picCanvas.Width - picFrame.Width

Then in the vertical scrollbar Change event :

    picCanvas.Top = -scrVertical.Value
    picCanvas.SetFocus

And in the horizontal scrollbar :
    picCanvas.left= -scrHorizontal.Value
    picCanvas.SetFocus

Now when you move the scrollbars the viewable portion of picCanvas is panned. Not that a picture box can contain other controls, so picCanvas could have text boxes, labels etc placed on it.

Hope this helps.
0
 
jjmartinCommented:
Goto http://www.planet-source-code.com and check out the VB section.  In the VB section do a search on ScrollingForm.  You should find a custom control I posted there that might meet your needs.  The custom control allows you to automatically scroll objects on the form (that are placed within the control), and allows you to scroll during design time to place controls.  Hope this helps.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I implemented a small OCX that you can use to implement a scrollable area.
If you want to get it (including vb source code of course)
let me know
0
 
lsmith2574Author Commented:
AngelIII,
I would like to see the OCX that you have.  Just let me know where I can retrieve it from or what information you need from me.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Need your email
0
 
lsmith2574Author Commented:
My email is lsmith7@hotmail.com.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now