1个回答
展开全部
自己从CStatic派生一个子类
如果是对话框的话,可以给对话框添加WM_CTLCOLOR消息函数,并将其修改成:
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_LISTBOX)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(233,233,220));
HBRUSH b=CreateSolidBrush(RGB(233,233,220));
return b;
}
else if(nCtlColor==CTLCOLOR_SCROLLBAR)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(141,177,229));
HBRUSH b=CreateSolidBrush(RGB(141,177,229));
return b;
}
else if(nCtlColor==CTLCOLOR_EDIT)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,255));
pDC->SetBkColor(RGB(255,255,255));
HBRUSH b=CreateSolidBrush(RGB(255,255,255));
return b;
}
else if(nCtlColor==CTLCOLOR_STATIC) //A
{
pDC->SetTextColor(RGB(0,128,0));
pDC->SetBkColor(RGB(160,180,220));
HBRUSH b=CreateSolidBrush(RGB(160,180,220));
return b;
}
else if(nCtlColor==CTLCOLOR_DLG)
{
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(160,180,220));
HBRUSH b=CreateSolidBrush(RGB(160,180,220));
return b;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
A行即是修改静态文本背景色的一段代码,其他的自己分析(从名称就能看出来干什么用)
如果是对话框的话,可以给对话框添加WM_CTLCOLOR消息函数,并将其修改成:
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_LISTBOX)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(233,233,220));
HBRUSH b=CreateSolidBrush(RGB(233,233,220));
return b;
}
else if(nCtlColor==CTLCOLOR_SCROLLBAR)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(141,177,229));
HBRUSH b=CreateSolidBrush(RGB(141,177,229));
return b;
}
else if(nCtlColor==CTLCOLOR_EDIT)
{
//pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,255));
pDC->SetBkColor(RGB(255,255,255));
HBRUSH b=CreateSolidBrush(RGB(255,255,255));
return b;
}
else if(nCtlColor==CTLCOLOR_STATIC) //A
{
pDC->SetTextColor(RGB(0,128,0));
pDC->SetBkColor(RGB(160,180,220));
HBRUSH b=CreateSolidBrush(RGB(160,180,220));
return b;
}
else if(nCtlColor==CTLCOLOR_DLG)
{
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(160,180,220));
HBRUSH b=CreateSolidBrush(RGB(160,180,220));
return b;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
A行即是修改静态文本背景色的一段代码,其他的自己分析(从名称就能看出来干什么用)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
博思aippt
2024-07-20 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询