dcsimg
Results 1 to 10 of 10

Thread: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,709

    [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

    This UserControl is a control container, like a PictureBox or a Frame but that can be scrolled.

    It can be useful when the controls we need to display do not fit in the available space.

    Name:  ScrollableContainer_scr.png
Views: 197
Size:  19.9 KB

    Last update: July 13, 2019
    Attached Files Attached Files
    Last edited by Eduardo-; Jul 12th, 2019 at 10:03 PM.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,709

    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: --
    AutoScrollOnFocus: D-
    BackColor: D-
    BorderColor: D-
    BorderStyle: D-
    BottomFreeSpace: D-
    HScrollBar: D-
    HScrollMax: -R
    HScrollValue: D-
    hWnd: -R
    RightFreeSpace: D-
    VirtualHeight: D(not persistable)-
    VirtualWidth: D(not persistable)-
    VScrollBar: D-
    VScrollMax: -R
    VScrollValue: D-

    Description

    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.


    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-; Jul 8th, 2019 at 11:31 PM.

  3. #3
    Member
    Join Date
    Jun 2016
    Posts
    62

    Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

    Hello,
    in the ide closes the ide does not work, compiled yes.
    a greeting

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,709

    Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

    Quote Originally Posted by yokesee View Post
    Hello,
    in the ide closes the ide does not work, compiled yes.
    a greeting
    Can you provide an example (a project) or a better explanation of what you mean?

  5. #5
    Member
    Join Date
    Jun 2016
    Posts
    62

    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.

    summary only works for me compiled

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,709

    Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

    Quote Originally Posted by yokesee View Post
    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.

  7. #7
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,418

    Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

    It works here at design-time w/o problems.

    @yokesee: Do you have SP6 installed? That is Service Pack 6 for VB6.

    cheers,
    </wqw>

  8. #8
    Member
    Join Date
    Jun 2016
    Posts
    62

    Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

    can that be the problem, I can not install the sp6 on windows 10
    I do not want to desisntalar it and reinstall any other solution

  9. #9
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,458

    Re: [VB6] ScrollableContainer: a container (like a PictureBox) with scroll capability

    What version of VB and which service pack are you using ?

  10. #10
    Member
    Join Date
    Jun 2016
    Posts
    62

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width