更改CListCtrl滚动条的颜色

时间:2014-09-19 12:49:22

标签: c++ windows visual-c++ mfc clistctrl

我有一个派生自CListCtrl的类,名为CListCtrlExt,我需要更改滚动条的颜色......我怎样才能实现呢? 我做了一个试验,就像那样:

HBRUSH CListCtrlExt::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
HBRUSH hbr = CListCtrl::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here

if(CTLCOLOR_SCROLLBAR == nCtlColor)
{
    pDC->SetBkColor(RGB(0, 0, 0));   
    HBRUSH b = CreateSolidBrush(RGB(233,233,220));   
    return b;   
}

// TODO: Return a different brush if the default is not desired
return hbr;
}

甚至没有通过这里...另一个试验:

HBRUSH CTestDlg2Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here

if(pWnd == GetDlgItem(IDC_LIST1) && CTLCOLOR_SCROLLBAR == nCtlColor)
{
    pDC->SetBkColor(RGB(0, 0, 0));
    HBRUSH b = CreateSolidBrush(RGB(0, 0, 0));
    return b;   
}

// TODO: Return a different brush if the default is not desired
return hbr;
}

不工作...... 我还有一个CScrollbarEx(来自here),但我不知道如何将它附加到我的CListCtrlExt上...你能帮助我吗?

0 个答案:

没有答案