A Slider Control For Range Selection

What does it do?

This derivation of CSliderCtrl allows the user to use the mouse or the keyboard to select a range in the slider control. The program can then use CSliderCtrl::GetSelection() to retrieve the range selected by the user. This is the way I thought that CSliderCtrl worked in the first place, only to discover that the selection was just a static representation of the values set by CSlider::CtrlSetSelection(). This class corrects this shortcoming of the slider control.

How to use it?

This code was originally compiled and tested with Visual C++ 4.2 and WinNT 4.0 SP4. It should not present any problem when using a more recent version of the compiler.

Be aware that you need to turn on the TBS_ENABLESELRANGE style for the control.

The usage is very simple you just have to include the files in your project, replace the ocurrences of CSliderCtrl in your code for CSelectionSliderCtrl and include SelectionSliderCtrl.h. For example


// MyDialog.h  header file
//


/////////////////////////////////////////////////////////////////////////////
// CMyDialog dialog


#include "SelectionSliderCtrl.h"

class CMyDialog  public CDialog
{
...



// Dialog Data
	//{{AFX_DATA(CMyDialog)
	enum { IDD = IDD_MY_DIALOG };
	//}}AFX_DATA
	CSelectionSliderCtrl	m_sliderTest;
...
};

Download source - 3 Kb



Comments

  • Any Demo project.?

    Posted by Legacy on 03/14/2003 12:00am

    Originally posted by: TINKLE

    Hi.,
    Can you please send me a Demo project for this.?

    Best Regards,

    TINKLE.

    Reply
  • Multiple selections?

    Posted by Legacy on 07/16/2002 12:00am

    Originally posted by: Andrew

    I think that it would be useful to allow a user to make more than 1 selection (actually, its the type of functionality I am looking for right now).

    Reply
  • test

    Posted by Legacy on 08/23/1999 12:00am

    Originally posted by: Zafir Anjum

    test comment

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 13, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT If you are developing applications, you'll want to join us to learn how applications are changing as a result of gesture recognition. This technology will change how you and your users interact - not simply with your devices, but with the world around you. Your devices will be able to see and hear what your users are doing. Are your applications ready for this? Join us to learn about Intel® RealSense™ Technology, including never been …

  • Intelligent N+X Redundancy, Placement Affinities, & Future Proofing in the Virtualized Data Center Virtualization brought about the ability to simplify business continuity management in IT. Workload portability and data replication capabilities mean that physical infrastructure failures no longer need impact application services, and they can rapidly be recovered even in the event of complete site failure. However, Enterprises and Service Providers face new challenges ensuring they have enough compute …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds