Bonjour,
Il y a forcément quelque chose que je n'ai pas encore bien compris concernant l'utilisation des devices contextes et des bitmaps.
Pourquoi ma solution 1 fonctionne et pourquoi ma solution 2 ne marche pas (j'édite une page blanche) ?
Merci
****************************************
********** Solution 1 (qui marche): ********** (prd.hDc est le device contexte de l'imprimante)
larg=GetDeviceCaps(prd.hDC, HORZRES);
haut=GetDeviceCaps(prd.hDC, VERTRES);
SetRect(&rect,larg*marges,haut*marges,larg-(larg*marges*2),haut-(haut*marges*2));
if ( StartDoc( prd.hDC, &di ) > 0 )
{
StartPage( prd.hDC );
Ellipse(prd.hDC,0,0,larg,haut);
DrawText(prd.hDC,"Ceci est une page de test",-1,&rect,DT_SINGLELINE | DT_VCENTER | DT_CENTER);
EndPage( prd.hDC );
EndDoc( prd.hDC );
}
******************************************
********** Solution 2 (qui ne marche pas): ****************
larg=GetDeviceCaps(prd.hDC, HORZRES);
haut=GetDeviceCaps(prd.hDC, VERTRES);
SetRect(&rect,larg*marges,haut*marges,larg-(larg*marges*2),haut-(haut*marges*2));
hDCmem = CreateCompatibleDC(prd.hDC);
Ellipse(hDCmem,rect.left,rect.top,rect.right,rect.bottom);
DrawText(hDCmem,"Ceci est une page de test",-1,&rect,DT_SINGLELINE | DT_VCENTER | DT_CENTER);
if ( StartDoc( prd.hDC, &di ) > 0 )
{
StartPage( prd.hDC );
BitBlt(prd.hDC,0,0,larg,haut,hDCmem,0,0,SRCCOPY); // copy hdcMemoire -> prd.hDC
EndPage( prd.hDC );
EndDoc( prd.hDC );
}
DeleteDC( hDCmem );