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
| LOGFONT lgfont;
Printer()->Orientation = poLandscape;
// Récupération des détails de la fonte dans la structure LogFont
GetObject(Chart1->Canvas->Font->Handle, sizeof(LOGFONT), &lgfont);
/* // Lister les imprimantes installées
ComboBox1->Items = Printer()->Printers;
// Definir l'imprimante par defaut
Printer()->PrinterIndex = ComboBox1->ItemIndex;*/
// Démarrage de l'impression
Printer()->BeginDoc();
// Tracé de la zone imprimable
TRect r = Rect(74, 74,Printer()->PageWidth-74, Printer()->PageHeight-74);
//Augmentons la taille de la fonte pour une meilleure visibilité
Printer()->Canvas->Font->Size = 12;
//L'impression d'un composant visuel (TForm, TDBGrid, TImage, etc ..) passe par l'obtention d'un Hdc sur ce composant avec l'API GetDC.
HWND hdc;
// Obtention d'un handle de device context sur l'écran
hdc = GetDC( NULL );
hdc = Chart1->Canvas->Handle;
r = Chart1->ClientRect;
// On utilise StretchBlt pour redimensionner la source à la taille de la destination
StretchBlt(Printer()->Canvas->Handle, 74, 74, Printer()->PageWidth-74, Printer()->PageHeight-74, hdc, 0, 0, Screen->Width, Screen->Height, SRCCOPY);
//Chart1->Print();
//PrinterSetupDialog1->Execute();
//Envoi des commandes à l'imprimante
Printer()->EndDoc();
//ne pas oublier de relacher le hdc
ReleaseDC(Handle, hdc);
} |
Partager