Share via


CProgressCtrl::SetBarColor

Sets the color of the progress indicator bar in the current progress bar control.

COLORREF SetBarColor(
         COLORREF clrBar
);

Parameters

Parameter

Description

[in] clrBar

A COLORREF value that specifies the new color of the progress indicator bar. Specify CLR_DEFAULT to cause the progress bar to use its default color.

Return Value

The previous color of the progress indicator bar, represented as a COLORREF value, or CLR_DEFAULT if the color of the progress indicator bar is the default color.

Remarks

The SetBarColor method sets the progress bar color only if a Windows Vista theme is not in effect.

This method sends the PBM_SETBARCOLOR message, which is described in the Windows SDK.

Example

The following code example defines the variable, m_progressCtrl, that is used to programmatically access the progress bar control. This variable is used in the next example.

   // Variable to access the progress control
    CProgressCtrl m_progressCtrl;

The following code example changes the color of the progress bar to red, green, blue, or the default.

// Set the progress bar color to red, green, blue, or  
// the system default. The SetBarColor method has an  
// effect only if the Windows system theme is Classic. 
void CCProgressCtrl_s1Dlg::OnSetbarcolorRed()
{
    m_progressCtrl.SetBarColor(RGB(255,0,0));
}

void CCProgressCtrl_s1Dlg::OnSetbarcolorGreen()
{
    m_progressCtrl.SetBarColor(RGB(0,255,0));
}

void CCProgressCtrl_s1Dlg::OnSetbarcolorBlue()
{
    m_progressCtrl.SetBarColor(RGB(0,0,255));
}

void CCProgressCtrl_s1Dlg::OnSetbarcolorOri()
{
    m_progressCtrl.SetBarColor(CLR_DEFAULT);
}

Requirements

Header: afxcmn.h

See Also

Reference

CProgressCtrl Class

Hierarchy Chart

PBM_SETBARCOLOR

COLORREF

Using CProgressCtrl

CProgressCtrl::GetBarColor