RAD Studio VCL Reference
|
Indicates the number of the page currently printing.
property PageNumber: Integer;
__property int PageNumber;
Use PageNumber to find the page number of the currently printing page.
PageNumber is incremented whenever the NewPage method is called. It is also incremented when a Text variable is written and a CR is encountered on the last line of the page.
C++ Examples:
/* This example uses a button and a status bar on a form. When the user clicks the button, one line of text is printed on six separate pages. As each page is printed, a message indicating the number of the page being printed appears on the status bar. Notice that the SimplePanel property of the status bar to must be set to true. */ void __fastcall TForm1::Button1Click(TObject *Sender) { StatusBar1->SimplePanel = True; // so that SimpleText will work Printer()->BeginDoc(); for (int i = 1;i < 7;i++) { Printer()->Canvas->TextOut(100, 100, "C++Builder rules!"); StatusBar1->SimpleText = AnsiString("Printing page ") + Printer()->PageNumber; Printer()->NewPage(); } Printer()->EndDoc(); }
Delphi Examples:
{ This example uses a button and a status bar on a form. When the user clicks the button, one line of text is printed on six separate pages. As each page is printed, a message indicating the number of the page being printed appears on the status bar. To run this example successfully, you must add Printers to the uses clause of your unit and set the SimplePanel property of the status bar to true. } uses Printers; procedure TForm1.Button1Click(Sender: TObject); var I: Integer; begin StatusBar1.SimplePanel := True; { so that SimpleText will work } Printer.BeginDoc; for I := 1 to 6 do begin Printer.Canvas.TextOut(100, 100, 'Object Pascal is great'); StatusBar1.SimpleText := 'Now printing page ' + IntToStr(Printer.PageNumber); Printer.NewPage; end; Printer.EndDoc; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|