如何 将动态创建的 static text 控件设置成透明的?

解决方案 »

  1.   

    什么叫透明?  不可见? ShowWindow(FALSE);
      

  2.   


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

    // TODO: Change any attributes of the DC here // TODO: Return a different brush if the default is not desired
        int id = pWnd->GetDlgCtrlID();   
    if(nCtlColor== CTLCOLOR_STATIC )     
    {   
    switch(id) 

    case IDC_COL1: //your static text ID
    pDC->SetBkMode(TRANSPARENT); 
    pDC->SetTextColor(RGB(255,0,0)); //Text Color
    hbr=(HBRUSH)GetStockObject(HOLLOW_BRUSH); 
    default: 
    break; 

    } return hbr;
    }
      

  3.   

    设置背景模式
    HBRUSH CXXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
     
      if(nCtlColor == CTLCOLOR_STATIC)
      {
        pDC->SetBkMode(TRANSPARENT);
      }  return hbr;
    }