设置静态文本框背景透明

 

 

    方法步骤:

 

    为对话框添加消息WM_CTLCOLOR   

  

    处理其消息函数

 

HBRUSH C背景透明Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); CBrush m_brush(RGB(255,255,0)); CRect m_rect; GetClientRect(m_rect); pDC->SelectObject(&m_brush); pDC->FillRect(m_rect,&m_brush); // 将整个对话框背景设置为黄色 if (nCtlColor==CTLCOLOR_STATIC) { if (pWnd->GetDlgCtrlID()==IDC_STATIC1) { //将文本框IDC_STATIC1设置为透明 pDC->SetBkMode(TRANSPARENT); } } return m_brush; }

 

你可能感兴趣的:(c)