常州市润邦电子科技有限公司

热保护器测试专业供应商

 

真彩色图像作为对话框的背景图像

void   CDlg::OnPaint()  
{

CPaintDC   dc(this);   //   device   context   for   painting
    HBITMAP   hbm     =(HBITMAP)::LoadImage(AfxGetInstanceHandle(), "TMKPTZ.bmp ",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
    m_bmp.Attach(hbm);
    CDC   mem;
    mem.CreateCompatibleDC(&dc);
    BITMAP   bm;
    m_bmp.GetBitmap(&bm);
    CBitmap*   pOld   =(CBitmap*   )mem.SelectObject(&m_bmp);
    CRect   rc;
    GetWindowRect(rc);
    dc.StretchBlt(0,0,rc.Width(),rc.Height(),&mem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
    mem.SelectObject(pOld);
//     CDialog::OnPaint();
    delete   hbm;
    delete   mem;
    delete   pOld;
    free(dc);

}

在.h中加入一条  
  CBitmap   m_bmp;

posted on 2011-02-23 09:45  常州市润邦电子科技  阅读(186)  评论(0编辑  收藏  举报

导航