Click here to Skip to main content
15,868,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am trying to set different colors in the Progress bar.

CProgressCtrl m_progress;


SetWindowTheme(m_progress, _T(""), _T(""));

if (x<50)
m_progress.SendMessage(PBM_SETBARCOLOR, 0, RGB(0,255,0));
else
m_progress.SendMessage(PBM_SETBARCOLOR, 0, RGB(255,0,0));

The else part in the above code changes the whole progress bar color to RED.
Instead I want to have the progress bar displayed as half green and half red.

Is there anyway to achieve this.

I am using Windows 7 and I am unable to even set the progress bar to a stream of rectangles. instead it will always show smooth bar. Please provide a solution
Posted

1 solution

This requires deriving or subclassing the MFC CProgressCtrl and implementing your own drawing function.

There are lot of articles about progress bars with gradient colors. These can be adapted for your needs to draw portions of the bar with different colours. For an example see the sources of the article Gradient Progress Control[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900