int nOffset = 6; // load IDB_BITMAP1 from our resources CBitmap bmp; if (bmp.LoadBitmap (IDB_BITMAP1)) { // Get the size of the bitmap BITMAP bmpInfo; bmp.GetBitmap (&bmpInfo);
// Create an in-memory DC compatible with the // display DC we''re using to paint CDC dcMemory; dcMemory.CreateCompatibleDC (&dc);
// Select the bitmap into the in-memory DC CBitmap* pOldBitmap = dcMemory.SelectObject (&bmp);
// Find a bottom-left point for the bitmap in the client area CRect rect; GetClientRect (&rect); int nX = rect.left + nOffset; int nY = rect.top + (rect.Height () - bmpInfo.bmHeight) - nOffset;
// Copy the bits from the in-memory DC into the on- // screen DC to actually do the painting. Use the centerpoint // we computed for the target offset. dc.BitBlt (nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
dcMemory.SelectObject (pOldBitmap); } // Do not call CPropertySheet::OnPaint() for painting messages }
void CMyPropSheet::OnPaint ()
{
CPaintDC dc(this); // device context for painting
int nOffset = 6;
// load IDB_BITMAP1 from our resources
CBitmap bmp;
if (bmp.LoadBitmap (IDB_BITMAP1))
{
// Get the size of the bitmap
BITMAP bmpInfo;
bmp.GetBitmap (&bmpInfo);
// Create an in-memory DC compatible with the
// display DC we''re using to paint
CDC dcMemory;
dcMemory.CreateCompatibleDC (&dc);
// Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject (&bmp);
// Find a bottom-left point for the bitmap in the client area
CRect rect;
GetClientRect (&rect);
int nX = rect.left + nOffset;
int nY = rect.top + (rect.Height () - bmpInfo.bmHeight) - nOffset;
// Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
dc.BitBlt (nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCCOPY);
dcMemory.SelectObject (pOldBitmap);
} // Do not call CPropertySheet::OnPaint() for painting messages
}