Slider Button Control

Synopsis

I was developing an image editor and found my dialog boxes cluttered with edit boxes, spin buttons and sliders. I thought the slider edit box that Adobe Photoshop had was cool and saves spaces. I decided to make my own, and so, here is my Slider Button Control. The code was based on several examples I found in codeguru. Thanks to all those guys.

Using the Control

The control consists of four files, they are:

  • wcSliderButton.h
  • wcSliderButton.cpp
  • wcSliderPopup.h
  • wcSliderPopup.cpp

To use the control, you will only need to include wcSliderButton.h in your header file.

Step 1 :

Include "wcSliderButton.h" in your dialog's header file. Add an Edit Box to your dialog box and change it to wcSliderButton instead of CEdit..

Step 2 :

Replace the DDX_Control in the DoDataExchange() to DDX_SliderButtonCtrl(pDX, IDC_EDIT1, m_SliderEdit, 0); The fourth parameter determines where the drop arrow button in the edit box will be placed. 0 Right and 1 Left. Note that by having DDX_SliderButtonCtrl in the DoDataExchange, the compiler will complains whenever you invoke the Class Wizard. I haven't any solution to come around this yet. Changes to the edit box can be detected as normal CEdit using ON_EN_CHANGE. 

Downloads

Download demo project - 39 Kb
Download source - 9 Kb


Comments

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

Top White Papers and Webcasts

  • Live Event Date: September 19, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT In response to the rising number of data breaches and the regulatory and legal impact that can occur as a result of these incidents, leading analysts at Forrester Research have developed five important design principles that will help security professionals reduce their attack surface and mitigate vulnerabilities. Check out this upcoming eSeminar and join Chris Sherman of Forrester Research to learn how to deal with the influx of new device …

  • Adaptation and evolution are fundamental requirements of survival -- not only in nature, but also in business. Our world has changed dramatically in a short amount of time. Many businesses are fueling and capitalizing on this change, while others are desperately clinging to a bygone era. Who is left standing in the years and decades ahead should come as no surprise. This edition of Unleashing IT highlights the companies that are embracing new circumstances, new methods, and new opportunities. By downloading …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds