Macintosh-like Slider Control | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 11, 2000
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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.

    Advertisement

    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

    CodeGuru Logo

    CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

    Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

    Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.