RT,我有个自绘的从CWnd继承来控件,背景是一幅图片,我现在要在该图片上DrawText,但是文字的背景仍然还是图片。如何做呢??

解决方案 »

  1.   


    //1. 在对话框的头文件中加入 afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
    //在对话框的cpp文件中加入 BEGIN_MESSAGE_MAP(CtransparentDlg, CDialog)
         ON_WM_CTLCOLOR()
         //}}AFX_MSG_MAP
     END_MESSAGE_MAP()
     
     HBRUSH CtransparentDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
     {
         HBRUSH   hBrush   =   CDialog::OnCtlColor(pDC,   pWnd,   nCtlColor);   
     
         if(nCtlColor == CTLCOLOR_STATIC)
         {
             pDC->SetBkMode(TRANSPARENT);   
             return   (HBRUSH)::GetStockObject(NULL_BRUSH);   
         }
         return hBrush;
     }