• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

Porgress control has no background?

Thanks.

I wanted to change the background color of progress control.
In dialog, I overrided WM_CTLCOLOR.
The class wizard created a function called as OnCtlColor().
Below is my code.

HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlcolor)
{
     if (m_progress.GetSafeHwnd() == pWnd->GetSafeHwnd())
          return m_brush;                    // for example, red brush

     HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
     return hbr;
}

My progress control still has gray background.

***********

I have another question.
How can I remove or erase the "border" of  progress control?
The style of "border" is WM_EX_STATICEDGE.
I create new class. Base class is CProgressCtrl.
I overrided WM_PAINT message.
But, I can't erase the "border".

Best regards...
Thanks again. Good lucks!
0
hotheart
Asked:
hotheart
1 Solution
 
hotheartAuthor Commented:
Edited text of question
0
 
nbushmanCommented:
I had to change the background color of one of my CStatic controls, IDC_STATIC_STUDENT_NAME, in a CFormView...  Maybe what I did will help you with your code.  Maybe not.  Good luck!

HBRUSH CEvaluatorView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
  HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
      
  // TODO: Change any attributes of the DC here
  if (nCtlColor == CTLCOLOR_STATIC &&
      pWnd->GetDlgCtrlID() == IDC_STATIC_STUDENT_NAME)
  {
            
     pDC->SetTextColor(RGB(255, 255, 255));
     pDC->SetBkColor(GetSysColor(COLOR_INACTIVECAPTION));

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

  return hbr;
}
0
 
gelbertCommented:
Try process WM_ERASEBKGND. See VC++ help for Cwnd::OnEraseBkgnd
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now