Shiny Language Reference

Language Reference > User Interface > Scrollbars


setscrollbarpos

setscrollbarpos(int ID, int X, int Y);


 

Sets the position of the scrollbar within the parent control

The SETSCROLLBARPOS statement sets the position of the scrollbar within the parent control. This statement is mainly intended for use with custom draw controls, although (for example) using it with setlistboxtextrect on standard list boxes is an easy way to position the scrollbar on the left of the list box rather than at its default position on the right.

Specifying a scrollbar position that causes the scrollbar to be partially or completely outside the boundaries (width/height) of the parent control will in turn cause Brass to automatically reposition the scrollbar to fit inside the parent control. Warning: for this reason you should call setscrollbarsize before SETSCROLLBARPOS, otherwise unintended side-effects may occur. For example: by default, scrollbars are the same height as the parent control. Moving the scrollbar without adjusting the height first will cause Brass to reposition the scrollbar back to the top of the parent control.

Scrollbars will always be drawn over all other items in the parent control.

 

Parameters

ID

The control ID of the parent control you wish to reposition the scrollbar in

X

The top left X position of the scrollbar. This is relative to the upper left corner of the parent control.

Y

The top left Y position of the scrollbar. This is relative to the upper left corner of the parent control.

 

Return Value

None

 

Example Code

// Create the list box X: 10, Y:10 and sized 200*120
int iListBoxID = createlistbox(1, 10, 10, 200, 120);


// Add 25 test items
for(int iTest = 0; iTest < 25; iTest++)
    addlistboxitem(iListBoxID, "Test item " + iTest);


// Set the text to start at 30 pixels in from the left and
// one pixel down from the top, with a maximum width of
// 150 pixels and height of 100 pixels
setlistboxtextrect(iListBoxID, 30, 1, 150, 100);


// Set the scrollbar to be on the left of the control by
// specifying 0,0 for the top left pixel
setscrollbarpos(iListBoxID, 0, 0);