请大侠们给出实例,谢谢,比如我添加一个LABEL的ID为:IDC_LABEL1,如何把其灰色设置成背景色,谢谢!
8 个解决方案
#1
父窗口的WM_CTLCOLOR中pDC->SetBkMode(TRANSPARENT);
#2
void CMystk::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rt;
GetClientRect(rt);
dc.FillRect(&rt,&CBrush(RGB(255,0,0)));
// Do not call CStatic::OnPaint() for painting messages
}
CMystk是继承自CStatic的类,控件关联CMystk对象
#3
二楼正解
#4
HBRUSH CDlgExport::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CBCGPDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(HOLLOW_BRUSH);
default:
return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
#5
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = ClxDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何属性
int nID = pWnd->GetDlgCtrlID();
if (nID == IDC_STATIC_VISION)
{
//pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkMode(TRANSPARENT);
return m_brush;
}
return hbr;
}
#6
To:wuwen1030
谢谢!厉害,以后多多向你请教!
谢谢!厉害,以后多多向你请教!
#7
我测试过了,非常好~
#8
我试过了,用OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
能让static透明,不过Edit一旦超过他的一行范围,就重叠起来,黑乎乎的一片
不知怎么修改!
能让static透明,不过Edit一旦超过他的一行范围,就重叠起来,黑乎乎的一片
不知怎么修改!
#1
父窗口的WM_CTLCOLOR中pDC->SetBkMode(TRANSPARENT);
#2
void CMystk::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rt;
GetClientRect(rt);
dc.FillRect(&rt,&CBrush(RGB(255,0,0)));
// Do not call CStatic::OnPaint() for painting messages
}
CMystk是继承自CStatic的类,控件关联CMystk对象
#3
二楼正解
#4
HBRUSH CDlgExport::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CBCGPDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(HOLLOW_BRUSH);
default:
return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
#5
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = ClxDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何属性
int nID = pWnd->GetDlgCtrlID();
if (nID == IDC_STATIC_VISION)
{
//pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkMode(TRANSPARENT);
return m_brush;
}
return hbr;
}
#6
To:wuwen1030
谢谢!厉害,以后多多向你请教!
谢谢!厉害,以后多多向你请教!
#7
我测试过了,非常好~
#8
我试过了,用OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
能让static透明,不过Edit一旦超过他的一行范围,就重叠起来,黑乎乎的一片
不知怎么修改!
能让static透明,不过Edit一旦超过他的一行范围,就重叠起来,黑乎乎的一片
不知怎么修改!