vc 控件背景透明文字背景透明

VC 控件背景透明文字背景透明
    Visual C++  开发实战宝典
功能:位图上显示文字,背景透明。
void CP400Dlg::OnPaint()
{
。。。。
CBitmap bmp;
bmp.LoadBitmap(IDB_YCH);
BITMAP bmInfo;
bmp.GetBitmap(&bmInfo);
int nBmpWidth,nBmpHeight;
nBmpWidth = bmInfo.bmWidth;
nBmpHeight = bmInfo.bmHeight;
CRect clientRC;
GetClientRect(clientRC);
CDC *pDC = GetDC();
CDC memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SelectObject(&bmp);
pDC->StretchBlt(0,0,clientRC.Width(),clientRC.Height(),&memDC,0,0,nBmpWidth,nBmpHeight,SRCCOPY);
memDC.DeleteDC();
bmp.DeleteObject();
pDC->SetBkMode(TRANSPARENT);
CFont font;
font.CreatePointFont(350,"华文行楷",pDC);
pDC->SelectObject(&font);
pDC->SetTextColor(RGB(0,0,255));
马弗罐pDC->SetBkColor(RGB(255,0,0));
pDC->TextOut(10,20,"。");
pDC->TextOut(10,90,"引无数英雄竞折腰。");
}功能:静态文本框去除背景,透明。
HBRUSH CP400Dlg::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_STATIC)
{
if (pWnd == GetDlgItem(IDC_STATIC1))
{
尼龙包胶线
豆袋弹 pDC->SetBkColor(RGB(125,255,0));
    //文字背景
pDC->SetTextColor(RGB(255,0,0));    //文字颜
  pDC->SetBkMode(TRANSPARENT);      //不显示文字背景
汽车水箱除垢剂
            hbr = (HBRUSH)::GetStockObject(NULL_BRUSH); //编辑框背景。注意:和文字背景不是一个意思。
}
}
// TODO: Return a different brush if the default is not desired
return hbr;
}效果:

本文发布于:2024-09-22 16:52:13,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/1/214873.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:背景   文字   透明   显示
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议