Results 1 to 3 of 3

Thread: Scrollbar with a Tab Control?

  1. #1
    Member marcuslee's Avatar
    Join Date
    Sep 2008
    Location
    Kansas, USA
    Age
    42
    Posts
    222
    Rep Power
    38

    Question Scrollbar with a Tab Control?

    I was wondering if it is possible to have a scrollbar with a tab control. I have gotten the scrollbar to show up inside the tab page when the tab page is initialized, but I am not sure how to connect the scrollbar to the contents of the tab page. I would like to be able to scroll through a long list of things under certain tab pages. Other pages will not need a scrollbar (or not much of one).

    I thought I could have the position of the scrollbar dictate the yPos of the elements on the page, but I am at a loss as how to do that.

    Any clue or better yet a short example would be greatly appreciated. It is one of those things that could make it to the samplescripts folder for future releases ... if it is a practical thing to do.




    Mark

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,129
    Rep Power
    732
    Hi Mark,

    maybe you could create viewport control inside tab to do what you need.

    Please have a look at:
    SampleScripts/UI/Viewport/Viewport.tBasic

    After you launch it, click on Options and you will see nice "dialog in dialog" you can create with it.

    The principle is easy - you create huge dialog with viewport as parent, put controls on it and the viewport takes care of scrolling the controls once you use the scrollbars.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    Member marcuslee's Avatar
    Join Date
    Sep 2008
    Location
    Kansas, USA
    Age
    42
    Posts
    222
    Rep Power
    38

    Exclamation Control set loc

    Quote Originally Posted by Petr Schreiber View Post
    maybe you could create viewport control inside tab to do what you need.
    I think your suggestion will work. It will also solve another problem I was pondering over yesterday - multiple tabs, a hierarchy of tabs, if you will. That was a nightmare for an amateur like me.

    On another note, I did find a way to get the contents of the tab page to move with the scrollbar: Control Set Loc.

    Here's how it might work:

      '------------------------------------------------------------------
      CallBack Function cb_SB_proc() As Long
      '------------------------------------------------------------------
        
        Local lID       As Long   = 2005   
        Local x, y As Integer
        
        Select Case CBMSG
             
          Case %WM_VSCROLL
            Select Case LOWRD(CBWPARAM)
              Case %SB_TOP
                ScrollBar_SetPos(CBHNDL, lID, ScrollBar_GetRangeLow(CBHNDL, lID))
              Case %SB_BOTTOM
                ScrollBar_SetPos(CBHNDL, lID, ScrollBar_GetRangeHi(CBHNDL, lID))
              Case %SB_LINEUP
                ScrollBar_SetPos(CBHNDL, lID, ScrollBar_GetPos(CBHNDL, lID) - 1)
              Case %SB_LINEDOWN
                ScrollBar_SetPos(CBHNDL, lID, ScrollBar_GetPos(CBHNDL, lID) + 1)
              Case %SB_PAGEUP
                ScrollBar_SetPos(CBHNDL, lID, ScrollBar_GetPos(CBHNDL, lID) - ScrollBar_GetPageSize(CBHNDL, lID))
              Case %SB_PAGEDOWN
                ScrollBar_SetPos(CBHNDL, lID, ScrollBar_GetPos(CBHNDL, lID) + ScrollBar_GetPageSize(CBHNDL, lID))
              Case %SB_THUMBTRACK
                ScrollBar_SetPos(CBHNDL, lID, ScrollBar_GetTrackPos(CBHNDL, lID))
            End Select  
    
            y = 10
            For x = 5 To 10 
              Control Set Loc  CBHNDL, x, 10, y - ScrollBar_GetPos(CBHNDL, lID) 
              y += 20
            Next x
    
        End Select
      End Function
    
    The important part is at the bottom of the function when CONTROL SET LOC is used. I also put the CONTROL SET LOC command in a FOR/NEXT loop so that you could go through an entire page of controls with a little amount of code. The control IDs would all have to be either in a row or in a pattern that could be picked up with the STEP keyword.




    Mark

Similar Threads

  1. Vertical scrollbar in Listview
    By martin in forum thinBasic General
    Replies: 4
    Last Post: 22-05-2009, 17:10

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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