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 58 59 60 61 62 63
| int h,w;
Screen->Cursor = crHourGlass; // <-- nice detail }
PrinterSetupDialog1->Execute();
try {
Printer()->BeginDoc(); // <-- start printer job
try {
// now print some text on Printer()->canvas
Printer()->Canvas->Font->Name = "Arial";
Printer()->Canvas->Font->Size = 10; // <-- set the font size
Printer()->Canvas->Font->Style.Clear();
Printer()->Canvas->TextOut(60,60,"NetWork Guardian"); // <-- print some text
h = Printer()->PageHeight; // <-- get page height
w = Printer()->PageWidth; // <-- get page width
// And now print the chart component
/*DBChart1->PrintPartial( Rect(
w / 5, // <-- 20% left margin
h / 3 , // <-- 33% top margin
w - (w / 5), // <-- 20% right margin
h - (h / 5))); // <-- 20% bottom margin
*/
DBChart1->PrintPartial( Rect(
w/15 ,
h/5,
w-(w/15),
h/25));
DBChart2->PrintPartial( Rect(
w/15 ,
(h/5)*2,
w-(w/15),
h/5 + h/25));
DBChart3->PrintPartial( Rect(
w/15 ,
(h/5)*3,
w-(w/15),
2*(h/5) + (h/25)));
DBChart4->PrintPartial( Rect(
w/15 ,
(h/5)*4,
w-(w/15),
3*(h/5) + (h/25)));
// print more text
Printer()->Canvas->Font->Name = "Arial";
Printer()->Canvas->Font->Size = 12; // <-- set the font size
Printer()->Canvas->Font->Style = TFontStyles() << fsItalic;
Printer()->Canvas->TextOut(60,120,Now()); // <-- Date and time
Printer()->EndDoc(); // <-- end job and print !!
}
catch (...) {
// just in case an error happens
Printer()->Abort();
Printer()->EndDoc();
throw; // <-- rethrow the exception !!!
}
}
__finally {
Screen->Cursor = crDefault; // <-- restore cursor
} |
Partager