Last updated:
21. January 2002
(Start sub-menu)
User Interface Programming Column
Range Slider
Splitter Controls and Dialog Resizing
(End sub-menu)
The Range Slider is a control 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 constraints, the control described in the column was fairly simple. The control documented here has more features.
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 appreciate 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 dialog is resizable and that the range slider is well-behaved, resizingwise.
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 } RS_INFO;
To initialize the range slider, initialize an RS_INFO structure and send its address as the wParam of an RSN_SETINFO message. 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 control.
When the user interacts with the control to change its status in any way, the control sends a WM_NOTIFY message to its parent window. The parameter is a pointer to an NMRANGESLIDER structure:
typedef struct _NMRANGESLIDER { NMHDR hdr; RS_INFO rsInfo; } NMRANGESLIDER;
Only the _start and _end members of RS_INFO are relevant; the user has no way of changing the other members.
setSliderRange();
setDlgItemSliderRange();
The accompanying code contains a complete example of how to use the range slider.
(Start bottom menu)
Top •
Home
• Articles
• Book
• Resources
Windows Developer Magazine
• R&D Books
• CMP Books
Amazon.com
• Amazon.co.uk
• Contact Petter Hesselberg
(End bottom menu)