Enhanced Multislider Control

Sample Image

Environment: Developed with VC++6 SP3, tested on NT4 SP3, Win9x and Win2K (see below)

The slider control described in this article is an extension of the cute CMultislider control by Terry Braxton. Here is a list of the enhancements I introduced:

  1. Full support to multiple layout:
    • Horizontal and vertical orientation
    • Markers' arrows may point both top/left and bottom/right (this works fine, only some tiny graphical flaws were noticed occasionally on some platforms - especially Win2K. Any fix is welcome!).
    • Possibility of inverting ranges (from left to right and viceversa and top-down or viceversa). I introduced this because I needed a vertical Slider, and it looked better going upwards, while the default was the opposite.
    • The control works fine (graphic is OK) for any reasonable size.
  2. Markers that are dragged outside the control may disappear (behaviour on original control) or simply stop at the end of the sliding channel.

  3. Markers in original control may overcross (?) so that you could drag the leftmost to become the rightmost and viceversa. I found little use of this for my purpouses - to say it all, I wanted to avoid it! Now such a behaviour is configurable.

  4. Original control had two cool right-click effects: change of intervals colors (cliccking on intervals) and setting of exact position of a marker (cliccking on the marker itself). Now you can decide what the user can or can't do.

  5. I found the focus rect disturbing in my application. You can remove it setting an apposite flag.

  6. A notification mechanism
  7. is set, so that parent window knows when the user modifies position of a marker in the control.

To set all of these features (excluded orientation, which must be decided in the usual way), all you need is to pass a suitable mask to Init function, together with usual parameters (Min and Max ranges, number of ticks, number of markers, list of colors...)

 int LayOut = MLTSLD_DISPLAY_VALUES | MLTSLD_DISPLAY_TOOLTIPS |
               MLTSLD_PREVENT_CROSSING | MLTSLD_ALLOW_SET_POS;
      for (int j=0; j<SLIDERS_NUM; j++)
	      m_Slider[j].Init(min, max, 10, m_NumMarkers, NULL, colors, LayOut);  

All that you need is to include few files in your project. See comment in the zip of Demo project for more info.

Downloads

Download demo project - 51 Kb
Download executable - 511 Kb