Application Security Testing: An Integral Part of DevOps
Environment: Windows 95, Visual C++ 4
The shape is passed to the Create() member function in the hbmArea parameter. This can be a colour or monochrome bitmap. Any colour that is non-white is used to form the progress control. Pixels that are white are transparent areas, and are not shaded. The bitmap is converted to a region, using a function from an article by Jean-Edouard Lachand-Robert. This region is then expanded by one pixel in both the horizontal and vertical directions. For this reason, make sure that the bitmap has a 2 pixel (at least) white border around any non-white pixels. This region is passed to the SetWindowRgn() function. The advantage of this is that we don't have to perform much clipping, and any windows underneath that are under the transparent areas can still be seen. The Create() function uses the width and height of the bitmap as the width and height of the progress control, so make your bitmap the same size as you would like the progress control to be.
Except for the Create() function. The progress control is designed to operate exactly as the CProgressCtrl MFC class, with a few additions. These additions are for setting the fill style and colours. I added a function that implements a MFC-compatible message loop. This function can be called regularly during a long operation, so that your program does not appear to have crashed. If a WM_QUIT message is received during this message loop, the function returns FALSE so that you can exit your processing loop, otherwise it returns TRUE.
NOTE: Before using this class, make sure you call the RegisterClass() function, to register the window class used by this control. This is a static member, so it can be called in CYourApp::InitInstance() (for example)
Please consult the source code and demo project for more information on this class.
DownloadsDownload demo project - 30 Kb
Download source - 8 Kb