0

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...

enter image description here

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();
}
NJMR
  • 1,886
  • 1
  • 27
  • 46
  • By using CPaintDC you are validating the dialog's invalid region, then CDialogEx::OnPaint does not get the proper invalidated region. Try using CClientDC instead. – ScottMcP-MVP Nov 20 '14 at 14:09

1 Answers1

1

I don't think you need a OnPaint() handler, try returning a brush with the same background color in OnCtlColor(), like in my SO Answer to a similar question.

Community
  • 1
  • 1
Edward Clements
  • 5,040
  • 2
  • 21
  • 27