Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
How to use it
To add controls at design time, drag the controls inside it as it is done with any other container.
The properties VirtualHeight and VirtualWidth determine the size of the virtual space at design time, and the properties VScrollValue and HScrollValue the scroll position.
Alternatively, you can right click on the control and select "Edit", and the scroll bars will become active at design time. Every time that you add a new control you'll have to select "Edit" again.
Reference
Properties:
Note: the extender's properties are not included here (Top, Left, Visible, Etc.)
Notation:
D: available at design time
R: read only property
AddingControls:
Use this property when you need to add controls to this container at run time. It is to indicate to the ScrollableContainer that you are adding controls, so that the position that you set to the newly added controls (Left and Top) are set correctly in the virtual space of the container.
Example use:
Code:
ScrollableContainer1.AddingControls = True
' Adding a command button
Set NewCmd1 = Me.Controls.Add("VB.CommandButton", "NewCommand1")
Set NewCmd1.Container = ScrollableContainer1
NewCmd1.Move 1000, 1000
NewCmd1.Caption = "New command 1"
NewCmd1.Visible = True
' Adding another command button
Set NewCmd2 = Me.Controls.Add("VB.CommandButton", "NewCommand2")
Set NewCmd2.Container = ScrollableContainer1
NewCmd2.Move 1600, 1000
NewCmd2.Caption = "New command 2"
NewCmd2.Visible = True
ScrollableContainer1.AddingControls = False
AutoScrollOnFocus:
Returns or sets a value that determines if when a contained control gets the focus, if the ScrollableContainer will automatically scroll to show the control in case that it is out of the view.
A control that is out of view can get the focus because the user is navigating with the Tab key, or pressed an accelerator that is set on the control, or there is a SetFocus to that control in the code.
BackColor:
Returns or sets the background color.
BorderColor:
Returns or sets the color of the border when BorderStyle is set to efnFlat1Pix or efnFlat2Pix.
BorderStyle:
Returns or sets a value that determines how the border of the control looks like.
BottomFreeSpace, RightFreeSpace:
Returns or sets a value that determines, in scale mode units of the ScrollableContainer's container, the free space that will be left at the bottom or the right of the virtual space (when there is no other control to scroll for).
HScrollBar, VScrollBar:
Returns or sets a value that determines the horizontal or vertical scrollbar visibility at run time.
HScrollMax, VScrollMax:
Returns a value, in scale mode units of the ScrollableContainer's container, that indicates the maximum value that HScrollValue / VScrollValue can take, corresponding to the scroll bar position's when the scroll box is in its bottom or rightmost position.
HScrollValue, VScrollValue:
Returns or sets a value, in scale mode units of the ScrollableContainer's container, that indicates the scroll actual position.
It can be set at design time to change the scroll position, but the design time value is not saved and at run time it starts with 0 (zero).
hWnd:
Returns the Windows handle of the control.
VirtualHeight, VirtualWidth:
Returns or sets a value that determines, in scale mode units of the ScrollableContainer's container, the height / width of the virtual space where the controls are located.
It can be set at design time to change the virtual space height, but the design time value is not saved and the run time value is calculated automatically.
TopScrollBound:
Returns or sets a value, in scale mode units of the ScrollableContainer's container, that sets a limit for the Vertical Scroll that the user can set.
Events:
HScrollChange, VScrollChange:
Generated when HScrollValue and VScrollValue change.
Methods:
EnsureControlVisible:
Ensures that the control referenced in the nControl parameter is visible on the container. If it is not, the ScrollableContainer is automatically scrolled in any needed direction to show the control.
Example use: ScrollableContainer1.EnsureControlVisible Text10
Update:
Updates the virtual space dimensions. Usually not necessary to call it because it is done automatically.
Last edited by Eduardo-; Aug 5th, 2020 at 12:39 AM.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
sorry for my english use translator.
When I open your project and open Form1 in design mode the ide closes automatically.
also if I execute it from the ide without opening any design sale closes the ide.
if I do not open anything and compile it the executable works perfectly.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
Originally Posted by yokesee
sorry for my english use translator.
When I open your project and open Form1 in design mode the ide closes automatically.
also if I execute it from the ide without opening any design sale closes the ide.
if I do not open anything and compile it the executable works perfectly.
summary only works for me compiled
OK, thanks for the explanation.
It doesn't happen here. It must be something in the subclassing code, I changed the subclassing technique for a self-contained one before posting the project here. The problem is that I can't fix something that is working.
To anyone else that have tried the code, does it crash also or it works?
What I could do is to try with another subclassing technique...
Edit: I also tested in another computer, that has Windows XP, and it works without crashing.
Last edited by Eduardo-; Jul 9th, 2019 at 03:24 PM.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
https://imgur.com/q5UHwMT
this is the version and tried many options that I have seen online to be able to update but I can not.
I know that if I uninstall it and install it again it will work but I am afraid of losing many settings and things.
a greeting
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
Originally Posted by Eduardo-
I don't understand the question, if you tested the demo.
If you didn't check the demo, then the answer is no, it scrolls only where there are controls.
The Mouse Scrolling is infinite in my test and leaves a blank area on bottom. When I go to top, the top visible control can't go to "Enter data 1" any more...
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
I saw that problem a few times. I think I remember that it returned to normal by closing the form and reopening it (or something like that, that reset the state. Maybe you need to close the project and reopen it).
I also remember that I tried to fix it, but it slipped away.
Unfortunately I am not being able to make it happen now.
Yes, it is not perfect, I shared this control that I made for me because I thought it might be useful for others.
If I could recreate the issue again, I could give it another try.
But... it has nothing to do with the mouse wheel, and it being infinite.
It is that the controls inside the container are left moved.
I strongly recommend to use this control from a compiled ocx. If you are going to use it in standard exes (I did), do not make anything weird, just put the controls inside and handle them by code (instead of design time) as much as possible.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
As a side note, that has nothing to do with this project directly, I strongly encourage to install SP6 (Visual Basic 6 Service Pack 6).
Any project that uses an UserControl can crash the IDE otherwise (due to a VB6 bug). Even with no code involved.
Unless stated otherwise, VB6 SP6 is assumed for all my projects.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
Originally Posted by Eduardo-
It works for me. Install SP6.
.Of course I installed SP6 if I drag the control don't change any attributes,will work ok .Of course I installed SP6. If I change some attributes, then the scroll bar cannot be rolled. EXE cannot be rolled. Mine is the home version of Win10 system.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
Originally Posted by xxdoc123
.Of course I installed SP6 if I drag the control don't change any attributes,will work ok .Of course I installed SP6. If I change some attributes, then the scroll bar cannot be rolled. EXE cannot be rolled. Mine is the home version of Win10 system.
This control works better compiled. Since it is subclassed in the IDE, it can cause issues when not compiled, unfortunately.
I suggest to put in in an OCX project, compile, and then use it.
I'll convert it to an OCX project (at some point, maybe later).
For a quick fix, try closing the IDE and opening the project again.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
Originally Posted by eduardo-
this control works better compiled. Since it is subclassed in the ide, it can cause issues when not compiled, unfortunately.
I suggest to put in in an ocx project, compile, and then use it.
I'll convert it to an ocx project (at some point, maybe later).
For a quick fix, try closing the ide and opening the project again.
Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability
Turned it into an OCX project now, so the people can choose between having the issues of using it in source code or having the issues of adding an OCX (it is that you need to add a dependency file).