VC++ 透明背境

作者在 2007-02-12 17:55:00 发布以下内容

// 实现
protected:
 CBrush m_Brush;

BOOL CtestDlg::OnInitDialog()

CBitmap bm;
 bm.LoadBitmap(IDB_BITMAP2);
 m_Brush.CreatePatternBrush(&bm);

消息:ON_WM_CTLCOLOR()

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

 if(pWnd == this)
 {
  return m_Brush;
 }

 if (nCtlColor == CTLCOLOR_STATIC || nCtlColor == CTLCOLOR_BTN)
 {
  pDC->SetBkMode(TRANSPARENT);
  pDC->SetTextColor(
   GetSysColor(COLOR_WINDOWTEXT));
  return (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
 }
 
  /*
 switch (pWnd->GetDlgCtrlID())
    {
    case IDXX1:
        pDC->SetTextColor(RGB(255,0,0));
        pDC->SetBkMode(TRANSPARENT);
        break;
    case IDXX2:
        pDC->SetTextColor(RGB(XXX,XXX,XXX));
        pDC->SetBkMode(TRANSPARENT);
        break;
    }
 */


 return hbr;
}

(编程)Work | 阅读 2048 次
文章评论,共0条
游客请输入验证码
浏览318006次