Partager via


Slider Control Member Functions

An application can call the slider control's member functions to retrieve information about the slider control (CSliderCtrl) and to change its characteristics.

To retrieve the position of the slider (that is, the value the user has chosen), use the GetPos member function. To set the position of the slider, use the SetPos member function. At any time you can use the VerifyPos member function to make sure that the slider is between the minimum and maximum values.

The range of a slider control is the set of contiguous values that the slider control can represent. Most applications use the SetRange member function to set the range of a slider control when it is first created. Applications can dynamically alter the range after the slider control has been created by using the SetRangeMax and SetRangeMin member functions. An application that allows the range to be changed dynamically typically retrieves the final range settings when the user has finished working with the slider control. To retrieve these settings, use the GetRange, GetRangeMax, and GetRangeMin member functions.

An application can use the TBS_AUTOTICKS style to have a slider control's tick marks displayed automatically. If an application needs to control the position or frequency of the tick marks, however, a number of member functions can be used.

To set the position of a tick mark, an application can use the SetTic member function. The SetTicFreq member function allows an application to set tick marks that appear at regular intervals in the slider control's range. For example, the application can use this member function to display only 10 tick marks in a range of 1 through 100.

To retrieve the index in the range corresponding to a tick mark, use the GetTic member function. The GetTicArray member function retrieves an array of these indices. To retrieve the position of a tick mark, in client coordinates, use the GetTicPos member function. An application can retrieve the number of tick marks by using the GetNumTics member function.

The ClearTics member function removes all of a slider control's tick marks.

A slider control's line size determines how far the slider moves when an application receives a TB_LINEDOWN or TB_LINEUP notification message. Similarly, the page size determines the response to the TB_PAGEDOWN and TB_PAGEUP notification messages. Applications can retrieve and set the line and page size values by using the GetLineSize, SetLineSize, GetPageSize, and SetPageSize member functions.

An application can use member functions to retrieve the dimensions of a slider control. The GetThumbRect member function retrieves the bounding rectangle for the slider. The GetChannelRect member function retrieves the bounding rectangle for the slider control's channel. (The channel is the area over which the slider moves and which contains the highlight when a range is selected.)

If a slider control has the TBS_ENABLESELRANGE style, the user can select a range of contiguous values from it. A number of member functions allow the selection range to be adjusted dynamically. The SetSelection member function sets the starting and ending positions of a selection. When the user has finished setting a selection range, an application can retrieve the settings by using the GetSelection member function. To clear a user's selection, use the ClearSel member function.

See Also

Reference

Using CSliderCtrl

Concepts

Controls (MFC)