About the WM_PAINT message, it states: "Draws the progress bar. Then I found the About Progress Bar Controls page on MSDN, containing an explanation of a few standard Windows messages and how they are handled by the Windows Progress Bar. This had me burning the midnight oil without finding much of an answer as to how it should be done, while I was convinced there must be a simple way to make this work with a minimum of code.
CTRL PAINT PROGRESS HOW TO
I expected to find some explanation of how to implement custom drawing using the NM_CUSTOMDRAW notification but, much to my disappointment, I discovered that this scenario is not supported.
There are a few solutions out there, such as this one and this one but none of the proposed solutions fitted well with my particular project, mainly because there the progress bar is implemented in a class that derives the NativeWindow class, which does not expose the CreateGraphics method like the Control class does.Īs ProgressBar is in fact, a wrapper for the Windows Progress Bar common control, I then looked into the MSDN documentation on messages and styles supported for the msctls_progress32 class.
CTRL PAINT PROGRESS CODE
I have searched the web for a while, hoping to find some sample code that might provide easy answers, but to no avail.
The issue with the standard ProgressBar is that it does not support the Paint event. I sincerely hope that my solution may provide an easy answer to any programmer out there still working on Windows Forms projects, encountering this problem without the option to get a third party control that does this straight out of the box. Read on to follow my quest along some of the pages I have visited and the solution I managed to find. This is one of those programming tasks that seem trivial, until you actually start writing your code to implement the desired functionality, as I soon discovered. As a simple solution, painting a translucent white layer on top of the control seemed the way to go, so I created a Class which would implement the code to do the painting required. Whilst working on an experimental composite control which contains a progress bar in the background, I decided it would be nice to fade the coloring of the standard ProgressBar a little bit, to make any text, icons or controls drawn on top of it more distinguished and readable.