trichview.support
Printing Page numbers |
Author |
Message |
Martyn |
Posted: 11/15/2003 10:14:10 Hi In a previous post, you gave a Delphi example of how to print page numbers: procedure TfrmPreview.RVPrint1PagePrepaint(Sender: TRVPrint; PageNo: Integer; Canvas: TCanvas; Preview: Boolean; PageRect, PrintAreaRect: TRect); (*************************************************************************** **** **************************************************************************** ***) var w,h: Integer; s: String; begin // This is a temporary solution for drawing page numbers and similalar stuff // This example outputs string just above RichView contents s := Format ('-- Page %d of %d --', [PageNo, Sender.PagesCount]); Canvas.Brush.Style := bsClear; Canvas.Font.Assign(form1.RVStyle1.TextStyles[0]); w := Canvas.TextWidth(s); h := Canvas.TextHeight(s); TextOut(Canvas.Handle, (PrintAreaRect.Right+PrintAreaRect.Left-w) div 2,PrintAreaRect.Top - h - 10, PChar(s), Length(s)); end; I've converted this for C++ Builder: void __fastcall TReportsFrm::RVPrintPagePrepaint(TRVPrint *Sender, int PageNo, TCanvas *Canvas, bool Preview, TRect &PageRect, TRect &PrintAreaRect) { int W, H; String Str; Str = "-- Page " + IntToStr(PageNo) + " of " + IntToStr(Sender->PagesCount) + " --"; Canvas->Brush->Style = bsClear; Canvas->Font->Assign(RVStyle->TextStyles->Items[0]); W = Canvas->TextWidth(Str); H = Canvas->TextHeight(Str); TextOut(Canvas->Handle, (PrintAreaRect.Right + PrintAreaRect.Left - W) / 2, PrintAreaRect.Top - H - 10, Str.c_str(), Str.Length() ); } The problem is that, although it gets called for every page and creates the correct string, it only actually prints that string on the first page. Any ideas? Regards Martyn |
Powered by ABC Amber Outlook Express Converter