CProgressCtrl::SetBarColor

显示安装进度栏的颜色在当前进度栏控件的。

COLORREF SetBarColor(
         COLORREF clrBar
);

参数

Parameter

说明

[in] clrBar

指定显示进度栏的新颜色的 COLORREF 值。 指定 CLR_DEFAULT 导致进度栏使用其默认颜色。

返回值

进度栏显示以前的颜色,表示为 COLORREF 值或 CLR_DEFAULT,如果显示进度栏的颜色为默认颜色。

备注

仅当 Windows Vista主题 实际上,而不是 SetBarColor 方法设置进度栏颜色。

此方法发送 PBM_SETBARCOLOR 信息,在 Windows SDK所述。

示例

下面的代码示例定义任何变量,m_progressCtrl,用于以编程方式访问进度栏控件。 此变量在下一个示例。

    // Variable to access the progress control
    CProgressCtrl m_progressCtrl;

下面的代码示例更改进度栏的颜色设置为红色,绿色,蓝色或者默认值。

// 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);
}

要求

标头: afxcmn.h

请参见

参考

CProgressCtrl选件类

层次结构图

PBM_SETBARCOLOR

COLORREF

使用CProgressCtrl

CProgressCtrl::GetBarColor