marcuslee
14-11-2010, 18:21
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
Petr Schreiber
14-11-2010, 19:01
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
marcuslee
14-11-2010, 19:30
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