Link to home
Start Free TrialLog in
Avatar of mah5696
mah5696

asked on

Controls Exceeding Form Size - VScroll

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?

thanks.
Avatar of Amitabh
Amitabh

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.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q187562
Avatar of mah5696

ASKER

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?
Yup...
Avatar of mah5696

ASKER

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?
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....
Avatar of inthedark
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
Further:

Form_Load()

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

VERSION 5.00
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
         End
         Begin VB.TextBox Text1
            Height          =   315
            Index           =   0
            Left            =   1080
            TabIndex        =   4
            Text            =   "Text1"
            Top             =   120
            Width           =   1695
         End
      End
      Begin VB.VScrollBar BoxScroller
         Height          =   2475
         Left            =   3000
         TabIndex        =   2
         Top             =   0
         Width           =   255
      End
   End
   Begin VB.Frame Frame1
      Caption         =   "Frame1"
      Height          =   2955
      Left            =   60
      TabIndex        =   0
      Top             =   120
      Width           =   3555
   End
End
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()
    BoxScroller_Change
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


Avatar of mah5696

ASKER

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



ASKER CERTIFIED SOLUTION
Avatar of ianouii
ianouii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mah5696

ASKER

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