Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Controls Exceeding Form Size - VScroll

Posted on 2002-07-18
Medium Priority
Last Modified: 2012-05-04
Hi, I'm using VB 6.0. Win 98 platform. resolution 800*600
At design time, I'd want to place my controls over a frame in a sstab.

Then, put in a Vscroll to allow user to scroll thru the frame in the SSTab.

both the frame & SSTab size are fixed.

ok, my problem arise when I can't place in those controls at design time... I wouldn't want to use coding to put it into a text file, save it as form & add it into my project later... this is too cumbersome.. any clue?

Question by:mah5696
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2

Expert Comment

ID: 7164045
Can u elaborate it a little.
What problem r u facing in placing the control in a frame in sstab during the design time.

BTW following is the link if you r facing a problem in resizing controls in SSTab when the form is resized.


Author Comment

ID: 7164076
nop, it's not problem for resizing...
I plan to put in a lot of controls onto the a frame, the frame sits inside a SSTab, the SStab is on a form.

I'll fix the size of the form, fix the size of the SSTab, & the size of the Frame.

inside my frame, I'll put in all my controls like textboxes, labels, etc..... together with 1 Vscroll.

ok, show me how u manage to put all the textboxes in the "can't see side" of the frame..

Got me?

Expert Comment

ID: 7164083
Technology Partners: 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!


Author Comment

ID: 7164106
any solution since u can get me? :D

basically, I want a scroll in a SSTab...

I can do that by pre-defined those controls position in the code. I dun want this. I'd prefer to do it at design time. Any clue?

Expert Comment

ID: 7164114
u wanna stuff many controls in a limited area and u don't want to increase the size of the form, U wanna do it i design time.

righto ?

well never done it, need some r&d like you....
LVL 17

Expert Comment

ID: 7164172
So here is what you do:

Place a picture box within the frame and place all of your controls within the picture box.

It would be better to use a picture box instead of a frame as the picture box provides you with a scalewidth, but you can use a frame if you want to.

In this example VS is your vscroll control.
FR is your frame control, or Picture box.
picVP is your picture box within the frame.

When you place the controls you wish to scroll within VP you set the height of VP so that all controls are exposed.
You will have to slide VP up/down while you place all of the controls within the frame/picturebox.

In your form resize event:

'Note if FR is a picture box use FR.ScaleWidth
VisibleWindowSize = FR.height ' set the size of the visibile

' now set the size of the max value of the VS
VS.Max = picVP.Height - VisibleWindowSize
VS.Mon = 0
VS.LargeMove = FR.Height - 255 ' control size of page down
VS.SmallMove = 340 ' About the isze of a text box

'Note if FR is a picture box use FR.ScaleWidth
picVP.Move 0,0, FR.Width ' Move to the top of the frame

VS.Value = 0

In the VScroll Change event:

Sub VS_Change()
VS_Scroll ' simply fire the scroll event
End Sub

Sub VS_Scroll()

' And now for the hard bit
' slide picVP within the frame
' because VS.Min/VS.Max will not let the VS scroll to low/heigh
' this is quite simple.

picVP.Top = -VS.Value ' and its that simple

End Sub
LVL 17

Expert Comment

ID: 7164179


' Make picVP as flat control at design time but leave
' the borderstyle so you can see the dimensions
' when placing you controls.
' also make a different color to your frame so you can see
' where you are.

' so at run time for best results
picVP.BorderStyle = 0
picVP.BackColor = FR.BackColor

etc.... Hope this helps

Expert Comment

ID: 7164982
I am assuming that the creation of the controls are not the actual issue. If I am mistaken please let me know.

I think what you are asking is once the form has the controls on it, how do you get them into the frame and get them to scroll at the same rate as the others...

Try this experiment...

Paste this code into a text file and name it Scroller.frm

Open this new form (the text file) in VB and run the program.

Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3705
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   3705
   StartUpPosition =   3  'Windows Default
   Begin VB.PictureBox BoxFrame
      Height          =   2535
      Left            =   180
      ScaleHeight     =   2475
      ScaleWidth      =   3255
      TabIndex        =   1
      Top             =   420
      Width           =   3315
      Begin VB.PictureBox Box
         Height          =   2475
         Left            =   0
         ScaleHeight     =   2415
         ScaleWidth      =   2955
         TabIndex        =   3
         Top             =   0
         Width           =   3015
         Begin VB.CheckBox Check1
            Caption         =   "Check"
            Height          =   255
            Index           =   0
            Left            =   60
            TabIndex        =   5
            Top             =   120
            Width           =   795
         Begin VB.TextBox Text1
            Height          =   315
            Index           =   0
            Left            =   1080
            TabIndex        =   4
            Text            =   "Text1"
            Top             =   120
            Width           =   1695
      Begin VB.VScrollBar BoxScroller
         Height          =   2475
         Left            =   3000
         TabIndex        =   2
         Top             =   0
         Width           =   255
   Begin VB.Frame Frame1
      Caption         =   "Frame1"
      Height          =   2955
      Left            =   60
      TabIndex        =   0
      Top             =   120
      Width           =   3555
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub BoxScroller_Change()
    Box.Top = 0 - BoxScroller.Value
End Sub

Private Sub BoxScroller_Scroll()
End Sub

Private Sub Form_Load()
    Dim x As Integer
    ' Hide the frames on the picture boxes
    BoxFrame.BorderStyle = 0
    Box.BorderStyle = 0
    ' Load the controls
    For x = 1 To 50
        Load Text1(x)
        SetParent Text1(x).hWnd, Box.hWnd
        Text1(x).Move Text1(0).Left, Text1(x - 1).Top + 2 * Text1(x).Height
        Text1(x).Visible = True
        Load Check1(x)
        SetParent Check1(x).hWnd, Box.hWnd
        Check1(x).Move Check1(0).Left, Text1(x).Top
        Check1(x).Visible = True
    Next x
    ' Use the height of the last control to figure out the
    ' picture box size and scroller settings.
    Box.Height = Text1(50).Top + 2 * Text1(50).Height
    BoxScroller.Max = Box.Height
    BoxScroller.SmallChange = 10 * Screen.TwipsPerPixelY
    BoxScroller.LargeChange = 10 * BoxScroller.SmallChange
    BoxScroller.Value = 0
End Sub


Author Comment

ID: 7168486
guys, preferable without any coding.. just provide me the way how to place all those controls while I can't see them in actual.... thanks.
LVL 17

Expert Comment

ID: 7168494
Best way is to generate the controls at run-time and have the form load move all the controls to their correct location.

There are other ways:

Create a picture box Array.

In the topleft corner of each box place an invisible lable like:
(0), (1), (2)

Move your controls onto the picture boxes. Using the send to back you can neatly stack your picture boxes with the top left just showing ad the main part of the box hidden within the right side of the frame. When you want to work on one part you slide it out, like getting a card out of a pack. Work on it, then slide it back.

At run time your form load just stacks the picture boxes so that they look like one continuous picbox.

At design time you make sure each picture box has a border. At run time form_load you set the bordstyle=0.


Accepted Solution

ianouii earned 800 total points
ID: 7168532
Hi, I think what u want can be done in such a way.

1) place a form
2) place a ssTab on the form
3) place a frame onto the ssTab exactly same size as the ssTab
4) place the Vscroll on the ssTab
5) place another frame on the 1st frame.
6) ok, place all your controls on the 2nd frame.
7) when you fix the size of the form, wanting to put more controls onto the ssTab, just drag the 2nd frame to be bigger. U can push it up from the form & resize.
8) Max resize of the frame is limited. u'd have to use the property box of the frame to make it big. then, push up the frame, add all your controls down within.
9) after u've completed all your controls, nicely put back your 2nd frame back to normal (dun resize), just put the top same as the 1st frame.

good luck.

Author Comment

ID: 7168628
This is what I wanted.... thanks.. though it makes my life difficult of pulling up & down.. anyway, it solves my prob.

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

604 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