从CStatic中派生自己的类,添加一个记录背景色的变量,根据它在OnPaint里填充,具体用的时候根据情况再设置它

解决方案 »

  1.   

    在控件颜色时对static 设为透明
    OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here

    if(nCtlColor==CTLCOLOR_STATIC)
    {
    pDC->SetBkMode(TRANSPARENT);
    pDC->SetTextColor(RGB(0,0,255));
    return HBRUSH(GetStockObject(HOLLOW_BRUSH));
    }

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

  2.   

    显示Text可以用CDC的TextOut
    如果要透明,再使用前先dc.SetBkMode( xx );
    xx有两个选择,你看msdn吧!我不记得了。反正一个是有背景颜色,一个透明。