Click here to Skip to main content
11,926,429 members (54,493 online)
Click here to Skip to main content
Add your own
alternative version


42 bookmarked

Gradient Progress Control

, 7 Jun 2000
Rate this:
Please Sign up or sign in to vote.
Subclasses the standard CProgressCtrl to allow for gradient fills. Supports vertical progress controls as well.
  • Download demo project - 47 Kb
  • Download source files - 6 Kb
  • Sample Image - GradientProgressCtrl.jpg


    This is a simple class to display a gradient fill progress control. It works just like the normal progress control. The main enhancements are that you can define the start and end colors and toggle the percentage caption's visibility. It supports both horizontal and vertical progress control styles. The sample application shows both types of controls on a single dialog-based application.

    The control can be incorporated into a project like any other CProgressCtrl-derived control. Either create the control manually, subclass an existing CProgressCtrl, or use the ClassWizard to DDX_control it. The actual code for the progress control is located in GradientProgressCtrl.h and GradientProgressCtrl.cpp. Most of the work happens in the DrawGradient(...) function, which also uses Keith Rule's CMemDC class. The sample project also uses Chris Maunder's ColourPicker. Both of these classes are included in the sample project and can be downloaded elsewhere at this site.

    It is derived from CProgressCtrl so all standard CProgressCtrl functions are available. Additional functions are listed below.

    Please let me know of any problems or improvements. Thanks and good luck.

    Member Set Functions

    void SetTextColor(const COLORREF& color)    // Set the percentage text color
    void SetBkColor(const COLORREF& color)      // Set background color
    void SetStartColor(const COLORREF& color)   // Set starting color
    void SetEndColor(const COLORREF& color)     // Set ending color
    void ShowPercent(BOOL bShowPercent = TRUE)  // Show the percent caption?

    Member Get Functions

    const COLORREF    GetTextColor(void)
    const COLORREF    GetBkColor(void)
    const COLORREF    GetStartColor(void)
    const COLORREF    GetEndColor(void)
    const BOOL    GetShowPercent()


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Matt Weagle
    Web Developer
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    BugCompile Errors Pin
    C3D125-Feb-13 2:19
    memberC3D125-Feb-13 2:19 
    GeneralThank you... Very helpful! Pin
    Destiny77718-Nov-11 16:29
    memberDestiny77718-Nov-11 16:29 
    QuestionStatic border on WinXP? Pin
    One Stone21-Feb-05 23:43
    memberOne Stone21-Feb-05 23:43 
    GeneralOn VisualC++.Net Pin
    Tanki9514-Nov-04 15:33
    memberTanki9514-Nov-04 15:33 
    GeneralA gradual StepIt() Pin
    Benjamin Ng7-Aug-00 21:20
    sussBenjamin Ng7-Aug-00 21:20 
    The StepIt() function causes a sudden increases in the progress bar. To have a gradual animated increase, I've written the following function:

    int CGradientProgressCtrl::StepItGradually(void)
    int oldPos = m_nCurrentPosition; // save current position

    for (UINT i=0; i < m_nStep; i++)

    return oldPos; // return previous position

    Just use it as if you were using the original StepIt() function.
    GeneralRe: Vertical filling Pin
    sunsam10-Mar-03 13:09
    membersunsam10-Mar-03 13:09 
    GeneralRe: A gradual StepIt() Pin
    dunniu19-Nov-13 16:33
    memberdunniu19-Nov-13 16:33 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web01 | 2.8.151126.1 | Last Updated 8 Jun 2000
    Article Copyright 2000 by Matt Weagle
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid