Last updated:
21. January 2002

User Interface Programming

(Start main menu) Home ­ Articles ­ Book ­ Resources (End main menu)

Range Slider

(Start sub-menu)


User Interface Programming Column


Tech Tips


Code Archive

Range Slider

Splitter Controls and Dialog Resizing



My blog »

(End sub-menu)

The Range Slider is a con­t­rol that lets you input two values, typically an upper and a lower bound. Normal sliders just lets you input one value.

The Range Slider was the subject of a User Interface Programming column. Due to space con­straints, the con­t­rol described in the column was fairly simple. The con­t­rol documented here has more fea­tures.

You will find that a lot of the code is half-baked. Development of the Range Slider continues, so watch this page for future developments. I’ll appre­cia­te any feedback and suggestions you might have.

(The documentation is on the thin side as well; I will extend it when I get the time. In the meantime, don’t hesitate to ask.)

Note that the demo dia­log is resizable and that the range slider is well-behaved, resizingwise.

Using the Range Slider



Programming the Range Slider

The Range Slider is of class wdmRangeSlider. Call initRangeSlider() to register this class.

The key structure for communicating with the range slider is RS_INFO:

typedef struct _RS_INFO {
    LONG _lower;        // Lower end of range
    LONG _upper;        // Upper end of range
    LONG _start;        // Current starting position (≥ _lower)
    LONG _end;          // Current ending position (≤ _upper)
    LONG _minRange;     // Minimum size of slider (may be zero)
    LONG _granularity;  // Steps when moving or changing size

To initialize the range slider, initialize an RS_INFO structure and send its address as the wParam of an RSN_SETINFO mes­sage. Although you can do this at any time and as many times as you like, the usual approach is to do this once, when initializing the con­t­rol.

When the user interacts with the con­t­rol to change its status in any way, the con­t­rol sends a WM_NOTIFY mes­sage to its parent win­dow. The parameter is a pointer to an NMRANGESLIDER structure:

typedef struct _NMRANGESLIDER {
    NMHDR   hdr;
    RS_INFO rsInfo;

Only the _start and _end members of RS_INFO are relevant; the user has no way of changing the other members.

Utility Functions


Sample Code

The ac­com­pa­ny­ing code contains a complete example of how to use the range slider.


See Also

(Start bottom menu)

Win­dows De­vel­oper Maga­zineR&D BooksCMP Books Petter Hesselberg

(End bottom menu)

Range Slider


Run Demo
Download Code