Macintosh-like Slider Control

Environment: Windows NT4 SP4, Visual C++ 6

This image shows an example of my CMacSliderCtrl and CMacProgressCtrl. For more information on the CMacProgressCtrl, please refer to this article.

This class is my attempt at recreating the slider control of the Macintosh. This control (CMacSliderCtrl) allows you to change the thumb, channel and selection colors.

Public Member Functions


void SetChannelColor(COLORREF crColor)
COLORREF GetChannelColor()
void SetSelectionColor(COLORREF crColor)
COLORREF GetSelectionColor()
void SetThumbColor(COLORREF crColor)
COLORREF GetThumbColor()

Steps to add a CMacSliderCtrl to a dialog

  • Add the desired files to your project.
  • Add the #include directive to the header file of your dialog class.
  • Add a slider control to your dialog in the resource editor.
  • Use ClassWizard to add a member variable of type CMacSliderCtrl for the corresponding controls you just added. If the CMacSliderCtrl classe is not in the Variable Type list, choose CSliderCtrl, and manually change the types in the header file of your dialog class.
  • Known bugs

    There is one problem with the CMacSliderCtrl class that have been unable to fix. If run the sample application and change the slider's thumb, channel or selection colors, you will notice that the colors do not change immediately. If you click on the slider, then the color will change. In my SetXXXColor() functions, I call RedrawWindow() so the control is drawn with the new color. RedrawWindow() starts the painting process, which sends the NM_CUSTOMDRAW message for the prepainting stage. I then return CDRF_NOTIFYITEMDRAW in my OnCustomDraw, which is supposed to request prepaint notifications for each item. But the item prepaint notifications are never sent. If anyone can come up with a solution for this I would love to hear about it.

    Downloads

    Special Note: The demo and source files are the sames available in the CMacProgressCtrl article.
    Download demo project - 35 Kb
    Download source - 11 Kb


    Comments

    • SetChannelColor() doesn't work if change orientation to Horizontal?

      Posted by Legacy on 03/16/2000 12:00am

      Originally posted by: zigzag

      Very COOL! But if you change the orientation of CMacSliderCtrl from Vertical to Horizontal, the SetChannelColor() will not work. Can't change the Channel Color of CMacSliderCtrl!
      Why?

      Reply
    • How to do a transparent background beside CMacSliderCtrl?

      Posted by Legacy on 02/01/2000 12:00am

      Originally posted by: Roland Chanishvily

      How to do a transparent background beside CMacSliderCtrl?
      I am beginner, sorry if question foolish ;(

      Reply
    • Kludgy, but it fixes the redraw-after-color-change problem...

      Posted by Legacy on 01/13/2000 12:00am

      Originally posted by: James R. Twine

         Had a similar problem with the updating of a Custom-Draw ListView control...  In place of your RedrawWindow(...) calls, use:
      
      

      EnableWindow( FALSE );
      EnableWindow( TRUE );

      This "blipping" of the window state will cause Custom Draw to correctly send a full set of drawing messages.

      -=- James.

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

    Top White Papers and Webcasts

    • Given today's threat environment and the increasing connectivity of digital infrastructures, security teams now realize that they must assume their IT environments are subject to periodic compromise. Gone are the days when preventive measures to secure the perimeter or trying to detect malware problems using signature-match technologies were enough. New practices based on an understanding of the phases of an attack, continuous threat monitoring, and rapid attack detection and remediation are necessary. This …

    • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

    Most Popular Programming Stories

    More for Developers

    Latest Developer Headlines

    RSS Feeds