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 42 43 44 45
| CDC SecondDC;
int xScrn, yScrn;
int nWidth, nHeight;
int nX, nY, nX2, nY2;
int oldMapMode = pDC->SetMapMode( MM_TEXT );
pDC->GetSafeHdc();
SecondDC.CreateCompatibleDC( pDC );
xScrn = pDC->GetDeviceCaps(HORZRES);
yScrn = pDC->GetDeviceCaps(VERTRES);
nX = VOPos.x;
nY = VOPos.y;
nX2 = VOPos.x + Size.cx;
nY2 = VOPos.y + Size.cy;
if (nX < 0) nX = 0;
if (nY < 0) nY = 0;
if (nX2 > xScrn) nX2 = xScrn;
if (nY2 > yScrn) nY2 = yScrn;
nWidth = nX2 - nX;
nHeight = nY2 - nY;
CBitmap *oldBM = SecondDC.SelectObject( &Bmp );
pDC->SetStretchBltMode(COLORONCOLOR );
if( !pDC->StretchBlt(
nX, nY,nWidth, nHeight,
&SecondDC,
0, 0, VOSize.cx, VOSize.cy,
SRCCOPY
) )
{
throw( xUnknown("Erreur StretchBlt") );
}
pDC->SetMapMode( oldMapMode );
SecondDC.SelectObject( oldBM );
SecondDC.DeleteDC(); |
Partager