Macintosh-like Progress Control
Posted
by Paul M. Meidinger
on January 11th, 2000
Environment: Windows NT4 SP4, Visual C++ 6

This class is my attempt at recreating the progress control of the Macintosh. This control (CMacProgressCtrl) allows you to change its colors as well as set an "indeterminate state" (similar to the "barber pole" look of progress controls on the Mac). This state can be used to indicate to the user that the length of time to finish the current operation is unknown.
Public Member Functions
void SetColor(COLORREF crColor) COLORREF GetColor() void SetIndeterminate(BOOL bIndeterminate = TRUE) BOOL GetIndeterminate()
Steps to add a CMacProgressCtrl to a dialog
Downloads
Special Note: The demo and source files are the sames available in the CMacSliderCtrl article.Download demo project - 35 Kb
Download source - 11 Kb

Comments
Progess bar resize and look
Posted by Legacy on 04/15/2003 12:00amOriginally posted by: proxima centauri
This control looks great as it is in the demo.
However, if I resize the progress bar control, to make it larger, the "macintosh" effect is lost and it doesn't look as sharp. This is due to the fact that you are using magic numbers (fixed number values) instead of parameterized value considering the height and width of the control to draw the mac-like effect.
Any chance anybody had spare time to implement it?
:-)
Reply
api windows
Posted by Legacy on 10/23/2002 12:00amOriginally posted by: didier
not mfc slider , with api windows ?
Style : wProc(WM_PAINT), SendMessage etc.
examples http://Getimage.free.fr
ReplyFix for: Immediate display of channel, thumb, and selection color changes for both Mac Sliders.
Posted by Legacy on 07/11/2001 12:00amOriginally posted by: Keith L Hatfield
ReplyReal fix for Color problems in Release mode
Posted by Legacy on 05/08/2001 12:00amOriginally posted by: Tim Ranker
ReplyChange Background color
Posted by Legacy on 01/18/2001 12:00amOriginally posted by: byungbok
I added bk-color change code .....
void CMacSliderCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMCUSTOMDRAW lpcd = (LPNMCUSTOMDRAW)pNMHDR;
if (lpcd->dwDrawStage == CDDS_PREPAINT)
{
// <----------- Add
CDC *pDC = CDC::FromHandle(lpcd->hdc);
int nSavedDC = pDC->SaveDC();
CRect rect(lpcd->rc);
pDC->FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(100,100,100));
// RGB(...) we can change ,we want to a color
}
pDC->RestoreDC(nSavedDC);
// $ <--------------Add
// Request prepaint notifications for each item.
*pResult = CDRF_NOTIFYITEMDRAW;
return;
}
// Because we returned CDRF_NOTIFYITEMDRAW in response to
// CDDS_PREPAINT, CDDS_ITEMPREPAINT is sent when the control is
// about to paint an item.
if (lpcd->dwDrawStage == CDDS_ITEMPREPAINT)
{
CDC *pDC = CDC::FromHandle(lpcd->hdc);
CRect rect(lpcd->rc);
int nSavedDC = pDC->SaveDC();
if (lpcd->dwItemSpec == TBCD_TICS)
{
*pResult = CDRF_DODEFAULT;
return;
} // if drawing tics
else if (lpcd->dwItemSpec == TBCD_THUMB)
{
...
...
...
...
ReplyFIXED: Color problems in release
Posted by Legacy on 02/18/2000 12:00amOriginally posted by: Sengoku
ReplyColor problem in Release-Builds
Posted by Legacy on 01/14/2000 12:00amOriginally posted by: Harald Dietewich
1.)
I have found out difference colorings in the CMacProgressCtrl when changing between Release- and Debug-Builds. In Debug-Builds, everything is OK. But when I do a Release-Build, the color is not the same!! I have also tested with the demo project by deleting the two lines that explicitly set the color in OnInitDialog(), so that my systems COLOR_HIGHLIGHT (= DWORD(8421376)) will be used.
// m_progMac1.SetColor(RGB(255, 0, 0));
// m_progMac2.SetColor(RGB(0, 0, 255));
But you can explicitly use
m_progMac1.SetColor((DWORD)8421376);
m_progMac2.SetColor((DWORD)8421376);
This also leads to different colors for the different builds. I have found out that removing the compilers optimization (switches "Full optimization" and "Global optimization") for release builds solves the problem. But I would like to know, why. For now, I have helped by including the following pragma immediately after #include "stdafx.h" in MacProgressCtrl.cpp:
#pragma optimize("g", off)
At the end of the file, the settings are restored with:
#pragma optimize("", on)
My system: TRUE COLOR on 1024*768, NT4 SP5, VC++ 6.0 SP3. Any idea?
2.)
The line no. 219
pOldPen = pDC->SelectObject(&m_penColor);
in CMacProgressCtrl::DrawHorizontalBar() is wrong and can be deleted completely. If not deleted it must be changed to
pDC->SelectObject(&m_penColor);
at least. The wrong statement leads to the wrong oldPen being selected at the end of the function.
ReplyUse of MacProgressCtrl with VC5
Posted by Legacy on 01/13/2000 12:00amOriginally posted by: Christian Schoenweger
Is there a posibility to compile (and use) the control with VC5 instead of VC6 ?
Reply