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.