rt

解决方案 »

  1.   

    响应WM_CTLCOLOR的消息
    HBRUSH xxx::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = ...;
    pDC->SetBkMode(TRANSPARENT);
    if(nCtlColor == CTLCOLOR_EDIT)
    {
    // 对于编辑框,使用空心刷子
    }
    return hbr;
    }
    对于按钮等一些控件,则需要自己处理透明的问题了
      

  2.   

    HBRUSH CViewOper::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
         switch(nCtlColor) {
         case CTLCOLOR_STATIC:
    // The Slider Control has CTLCOLOR_STATIC, but doesn't let
    // the background shine through,
    TCHAR lpszClassName[255];
    GetClassName(pWnd->m_hWnd, lpszClassName, 255);
    if(_tcscmp(lpszClassName, TRACKBAR_CLASS) == 0)
          return CFormView::OnCtlColor(pDC, pWnd, nCtlColor);     case CTLCOLOR_BTN:
    // let static controls shine through
    pDC->SetBkMode(TRANSPARENT);
    return HBRUSH(m_HollowBrush);
         default:
    break;
         }
         // if we reach this line, we haven't set a brush so far
         return CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
    }
    这是示例,具体的控件要自己处理了