Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1589392
  • 博文数量: 441
  • 博客积分: 20087
  • 博客等级: 上将
  • 技术积分: 3562
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-19 15:35
文章分类

全部博文(441)

文章存档

2014年(1)

2012年(1)

2011年(8)

2010年(16)

2009年(15)

2008年(152)

2007年(178)

2006年(70)

分类: C/C++

2006-12-26 09:03:49

    给对话框贴上背景图,一般的方法就是在对话框的OnPaint中加载位图(bmp),下面给出一个实例:

    CPaintDC dc(this); // device context for painting
   
    CRect rect;
    GetClientRect(&rect);//得到窗体的大小
    CDC dcMem;
    dcMem.CreateCompatibleDC(&dc);
    CBitmap bmpBackground;
    bmpBackground.LoadBitmap(IDB_BK);//加载背景图片
    BITMAP bitMap;
    bmpBackground.GetBitmap(&bitMap);
    CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground);
    dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,             bitMap.bmHeight,SRCCOPY);//该函数给对话框贴上位图
    ////------------下面的代码给对话框添上文字
    dc.SetBkMode(TRANSPARENT);
    dc.SetTextColor(RGB(0, 0, 255));
    CString str;
    BYTE *pIP = (BYTE*)&m_dwIP;
    str.Format("%d.%d.%d.%d:%d  -- %s", pIP[3], pIP[2], pIP[1], pIP[0], m_dwPort,     m_strName);
    dc.DrawText(_T(str), &CRect(50, 50, 450, 100), DT_SINGLELINE | DT_CENTER );

阅读(2420) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~