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 46 47 48 49 50 51 52 53 54 55 56 57
| Cap := GetDeviceCaps(Printer.Handle, RASTERCAPS);
if (Cap and RC_BITMAP64) =0 then begin
showmessage ('Les capacités de l''imprimante ne permettent pas l''impression du plan.');
result := false;
exit;
end;
{
if (Cap and RC_BITBLT) <>0 then showmessage ('Capable of transferring bitmaps.');
if (Cap and RC_BANDING) <>0 then showmessage ('Requires banding support.');
if (Cap and RC_SCALING) <>0 then showmessage ('Capable of scaling.');
if (Cap and RC_BITMAP64) <>0 then showmessage ('Capable of supporting bitmaps larger than 64K.');
if (Cap and RC_GDI20_OUTPUT)<>0 then showmessage ('Capable of supporting features of Windows 2.0.');
if (Cap and RC_DI_BITMAP) <>0 then showmessage ('Capable of supporting the SetDIBits and GetDIBits functions.');
if (Cap and RC_PALETTE) <>0 then showmessage ('Specifies a palette-based device.');
if (Cap and RC_DIBTODEV) <>0 then showmessage ('Capable of supporting the SetDIBitsToDevice function.');
if (Cap and RC_STRETCHBLT) <>0 then showmessage ('Capable of performing the StretchBlt function.');
if (Cap and RC_FLOODFILL) <>0 then showmessage ('Capable of performing flood fills.');
if (Cap and RC_STRETCHDIB) <>0 then showmessage ('Capable of performing the StretchDIBits function.');
}
mmprWidth := GetDeviceCaps(Printer.Handle, HORZSIZE);// largeur imprimable en mm
pixprWidth := GetDeviceCaps(Printer.Handle, HORZRES); // largeur imprimable en pixels (Printer.PageWidth)
pixprHeight := GetDeviceCaps(Printer.Handle, VERTRES); // hauteur imprimable en pixels
procedure PrintPrinterWindow;
var
Bitmap : TBitMap; // BitMap intermédiaire
begin
Bitmap := TBitmap.Create;
// C'EST ICI:
Bitmap.HandleType:= bmDIB;
Bitmap.canvas.CopyMode := cmSrcCopy;
Bitmap.Width := pixprWidth; // taille de l'imprimante
Bitmap.Height := pixprHeight;
// Copie dans le bitmap intermédiaire
Bitmap.Canvas.CopyRect(
// Rectangle de destination: la fenètre visée sur l'imprimante
Rect(PixMargeGauche,PixMargeHaute,PixFenWidth+PixMargeGauche,PixFenHeight+PixMargeHaute),
//Rect(0,0,Bitmap.Width,Bitmap.Height),
// Canevas d'origine: (le raster)
PlanRaster.Bitmap.Canvas,
// Rectangle du canevas d'origine à tracer dans le rectangle de destination:
Rect(PrintVueLeft,PrintVueTop,PrintVueWidth+PrintVueLeft,PrintVueHeight+PrintVueTop));
Printer.orientation := poPortrait;
Printer.BeginDoc;
try
Printer.Canvas.Draw( 0,0,Bitmap);
finally
Printer.EndDoc;
Bitmap.Free;
end;
end; |
Partager