Shiny Language Reference

Language Reference > User Interface > Scrollbars


setscrollbarsize

setscrollbarsize(int ID, int Width, int Height);


 

Sets the size of the scrollbar within the parent control

The SETSCROLLBARSIZE statement sets the width and height of the scrollbar within the parent control. This statement is mainly intended for use with custom draw controls, however it can also be used to alter the default scrollbar size of (for example) a standard list box.

Specifying a scrollbar position or size 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 listbox. This calculation is done using the dimensions of the scroll bar.

If necessary you should always call SETSCROLLBARSIZE prior to calling setscrollbarpos. For example, if the scrollbar is currently the same height as the parent control and you wish to reduce its height by 50% and move it down by 25%, you must first call SETSCROLLBARSIZE and then call setscrollbarpos. This restriction is necessary to ensure proper positioning of scrollbars. Brass detects invalid positioning using setscrollbarpos, and adjusts the position to make it valid.

Scrollbars will always be drawn over all other components of the parent control.

Calling SETSCROLLBARSIZE on a custom-draw control will cause the custom draw handler for that control to be called.

 

Parameters

ID

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

Width

The width of the scrollbar in pixels

Height

The height of the scrollbar in pixels

 

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);


// An example of how to swap the scrollbar to the left side of the
// list control.

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


// Set the scrollbar to be 20 pixels wide, 120 pixels high
setscrollbarsize(iListBoxID, 20, 120)