vc对话框添加图片背景
2006-12-12 11:19
453 查看
方法一:
void About::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CPaintDC dcc(this);
CRect rect;
GetClientRect(&rect);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BITMAP1);
//IDB_BITMAP是你自己的图对应的ID
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);
// Do not call CDialog::OnPaint() for painting messages
}
方法二:
响应OnEraseBkgnd消息,然后在这个消息函数里面显示图片!
BOOL CxxDlg::OnEraseBkgnd(CDC* pDC)
{
BITMAP bm;
m_bmp.GetBitmap(&bm);
m_pbmCurrent = &m_bmp;
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = dcMem.SelectObject(m_pbmCurrent);
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dcMem,0,0,SRCCOPY);
dcMem.SelectObject(pOldBitmap);
}
void About::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CPaintDC dcc(this);
CRect rect;
GetClientRect(&rect);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BITMAP1);
//IDB_BITMAP是你自己的图对应的ID
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);
// Do not call CDialog::OnPaint() for painting messages
}
方法二:
响应OnEraseBkgnd消息,然后在这个消息函数里面显示图片!
BOOL CxxDlg::OnEraseBkgnd(CDC* pDC)
{
BITMAP bm;
m_bmp.GetBitmap(&bm);
m_pbmCurrent = &m_bmp;
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = dcMem.SelectObject(m_pbmCurrent);
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dcMem,0,0,SRCCOPY);
dcMem.SelectObject(pOldBitmap);
}
相关文章推荐
- vc对话框添加图片背景及改变背景颜色
- VC++MFC对话框程序中给对话添加背景图片
- vc对话框添加图片背景及改变背景颜色
- 用VC给对话框添加背景图片
- vc为对话框添加背景图片
- VC中为对话框添加背景图片
- VC++对话框(CDialog)添加背景图片
- vc为对话框添加背景图片
- VC++对话框(CDialog)添加背景图片
- VC 改变对话框背景(添加背景图片)
- vc++如何给窗体添加背景图片
- MFC对话框添加背景图片
- [转]MFC 对话框添加背景图片
- VC 对话框设置背景颜色和图片
- VC中添加背景图片,防止遮挡其他控件
- VC设置对话框背景图片 MFC显示背景图片方法
- MFC中设置对话框颜色、添加背景图片、添加音乐的方法
- VC对话框加载图片、改变背景颜色、画图、显示隐藏控件
- VC中为SDI添加背景图片总结
- VC对话框如何添加WM_ERASEBKGND消息(OnEraseBkgnd函数)及对话框使用位图背景并透明