Click to See Complete Forum and Search --> : bitmap on background Dialog
cristian.muller
August 12th, 2005, 07:06 AM
Hello,
i spend my last hours trying to make out something out of the online documentation in Codeguru.
I want a simple simple way to put a bitmap in my background on a Dialog window.With what function or what message do i have to deal?
If you have some code please let me know,
thanks!
ovidiucucu
August 12th, 2005, 08:20 AM
Handle WM_ERASEBKGND.
See few examples in THIS THREAD (http://www.codeguru.com/forum/showthread.php?t=258991) and THESE ARTICLES (http://www.codeguru.com/Cpp/W-D/dislog/).
cristian.muller
August 12th, 2005, 08:53 AM
Thanks Ovidiucucu for this good thread,
with a few association with another thread i have made it work:
BOOL CAppDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
// BITMAP bm;
// m_Bitmap.GetBitmap(&bm);
CBitmap bm; // Creates a CBitmap object.
bm.LoadBitmap(MAKEINTRESOURCE(IDB_FUNDAL));
CDC memDc;
memDc.CreateCompatibleDC(pDC);
CBitmap *pOldBmp;
pOldBmp = memDc.SelectObject(&bm);
pDC->BitBlt(0, 0, ???,???, &memDc, 0, 0, SRCCOPY);
memDc.SelectObject(pOldBmp);
return TRUE;
// return CDialog::OnEraseBkgnd(pDC);
}
with a little problem:
where the ???,??? i must put the dimension of the bitmap and i don't know how to get them from a CBitmap(i guess it's pretty easy),otherwise it works.
Regards,
Cristian Müller
cristian.muller
August 12th, 2005, 08:58 AM
i found it:
CSize sz=bm.GetBitmapDimension();
and the ???,??? should be replaced with sz.cx and sz.cy
ovidiucucu
August 12th, 2005, 08:58 AM
with a little problem:
where the ???,??? i must put the dimension of the bitmap and i don't know how to get them from a CBitmap(i guess it's pretty easy),otherwise it works.
Regards,
Cristian Müller
Quite easy. Call CBitmap::GetBitmap like in the next example.
BITMAP bmp;
bitmap.GetBitmap(&bmp);
const int nWidth = bmp.bmWidth;
const int nHeight = bmp.bmHeight;
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.