简体   繁体   中英

Chaning the background color of SysLink Control - MFC

I am having problem in setting the background color of a SysLink Control.

I have a group box and also couple of SysLink Controls. When I change the back color of group box and also the syslink control, this is what it looks like...

在此处输入图片说明

A small white color line appears at the end. It doesn't go even after adjusting the width of the control.

Here is my code:

HBRUSH PanelDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
        pDC->SetBkColor(RGB(0, 0, 255));//RGB(223, 233, 247)
        pDC->SetTextColor(RGB(0, 0, 0));
        return (HBRUSH)GetStockObject(NULL_BRUSH);
}

and OnPaint...

void PanelDlg::OnPaint()
{
    CRect rect1;
    GetDlgItem(IDC_MENU_GROUP_BOX)->GetWindowRect(&rect1);
    ScreenToClient(&rect1);
    CPaintDC dc(this);
    dc.FillSolidRect(&rect1, RGB(0, 0, 255));// RGB(223, 233, 247)); //247
    CDialogEx::OnPaint();
}

我认为您不需要OnPaint()处理程序,请尝试在OnCtlColor()返回具有相同背景颜色的OnCtlColor() ,就像在对类似问题的SO中那样。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM