首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

View类下动态创建的CStatic m_StaticCtrl怎么设置背景色

2013-09-29 
View类下动态创建的CStatic m_StaticCtrl如何设置背景色创建了单文档程序MyApp,在MyAppView类下,手动创建

View类下动态创建的CStatic m_StaticCtrl如何设置背景色
创建了单文档程序MyApp,在MyAppView类下,手动创建了CStatic m_StaticCtrl,请问如何设置m_StaticCtrl背景色

View类下动态创建的CStatic m_StaticCtrl怎么设置背景色
[解决办法]
响应 WM_CTLCOLOR 


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

  // TODO: Change any attributes of the DC here
  if(pWnd->GetDlgCtrlID() == m_StaticCtrl.GetDlgCtrlID())
  {
    pDC->SetBkMode(TRANSPARENT);
    pDC->SetTextColor(RGB(200, 0, 0));
    hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
  }
  
  // TODO: Return a different brush if the default is not desired
  return hbr;
}

热点排行