张晓华的博客

        2005年,最后一场雪,还是下了,虽然凄凉了一些!
posts - 185, comments - 100, trackbacks - 8, articles - 1

MFC中静态文本框透明的方法

Posted on Saturday, June 21, 2008 3:08 PM
HBRUSH CMyUIDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
     if(   CTLCOLOR_STATIC   ==   nCtlColor   )  
  {
        //pDC->SetBkColor(RGB(255,0,0));  //需要指定背景色的时候用
         pDC->SetTextColor(RGB(255,   255,   255));    //文字前景色
  pDC->SetBkMode(TRANSPARENT);    //设置透明
  hbr=(HBRUSH)GetStockObject(NULL_BRUSH);  //获取画笔颜色混合后的画笔,完成透明
  }  
    return hbr;
}

Post Comment

Title  
Name  
Url
Comment   
Protected by Clearscreen.SharpHIPEnter the code you see: