VC 设置静态文本框透明背

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

 // TODO:  在此更改 DC 的任何属性

 CBrush m_brush(RGB( 0,0,0));
 CRect m_rect;
 GetClientRect(m_rect);
 pDC->SelectObject(&m_brush);
 //pDC->FillRect(m_rect,&m_brush);  //DIY背景色

 if (nCtlColor==CTLCOLOR_STATIC)
 {
  if (pWnd->GetDlgCtrlID()==IDC_STATIC_MENU)
  {

   pDC->SetBkMode(TRANSPARENT); //将文本框IDC_STATIC_MENU设置为透明 
   pDC->SetTextColor(RGB( 255, 20, 20 ));//设置字体颜色

  }

  if( pWnd->GetDlgCtrlID() == IDC_STATIC_FIND )
  {
   pDC->SetBkMode( TRANSPARENT );
   pDC->SetTextColor( RGB( 29, 200, 50 ));
  }

  if( pWnd->GetDlgCtrlID() == IDC_EDIT_FIND )
  {
   pDC->SetBkMode( TRANSPARENT );
  }

  hbr=(HBRUSH)GetStockObject(NULL_BRUSH);

 }
 return hbr;
}

 

你可能感兴趣的:(null,menu)