1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
void CPrint::DrawBitmap ( CDC &Dc, CRect &Rc ) //dessin
{
CBitmap bmp;
int ret;
if(bmp.LoadBitmap(IDB_LOGO))
{
BITMAP bmpInfo;
if(bmp.GetBitmap(&bmpInfo))
{
ret=true;
}
CDC dcMemory;
ret=dcMemory.CreateCompatibleDC(&Dc);
if(ret==false)
{
ret=false;
}
CBitmap* pOldBitmap;
if( pOldBitmap = dcMemory.SelectObject(&bmp))
{
ret=true;
}
//Crect rect;
//GetClientRect(&rect);
int nX = Rc.left + (Rc.Width() - bmpInfo.bmWidth) / 2;
int nY = Rc.top + (Rc.Height() - bmpInfo.bmHeight) / 2;
ret=Dc.BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
ret=true;
}
else
ret=false;
} |
Partager