trichview.support.examples
Printing TRichViewEdit information with Nevrona RAVE |
Author |
Message |
Jonathan Allen |
Posted: 09/21/2004 18:46:17 All, Here is a code sample of using RAVE and TRichView components. This sample uses a TRVReportHelper, TRichViewEdit, TRVStyle, and TRvSystem componet. Hope this saves someone else some time! procedure TForm1.RvSystem1Print(Sender: TObject); var i : Integer; MF: TMetaFile; MFC: TMetaFileCanvas; R,RR: TRect; iPaperWidth: Integer; iPaperHeight: Integer; MyHDC : THandle; PageNo : Integer; Stream : TStream; Res : BOolean; begin Stream := TMemoryStream.Create; try ARichViewEdit.SaveRVFToStream(Stream,False); Stream.Position := 0; AReportHelper.RichView.LoadRVFFromStream(Stream); finally Stream.Free; end; with Sender as TBaseReport do begin SetFont('Arial',12); YPos := 1.0; //Print Some Stuff before the Rich View Edit for i:=1 to 40 do begin PrintLeft(StringOfChar('A',i),0.5); CrLf; end; NewPage; //Print TRichViewEdit Control Contents MF := TMetaFile.Create; MyHDC := GetDC(0); iPaperHeight := Trunc((PageHeight-1.0) * GetDeviceCaps(MyHdc,LOGPIXELSY)); iPaperWidth := Trunc((PageWidth-1.0) * GetDeviceCaps(MyHdc,LOGPIXELSX)); ReleaseDC(0,MyHDC); AReportHelper.Init(Self.Canvas, iPaperWidth); PageNo := 1; repeat if PageNo > 1 then Newpage; if AReportHelper.FormatNextPage(iPaperHeight) then begin MF.Height := iPaperHeight; MF.Width := iPaperWidth; MFC := TMetafileCanvas.Create(MF,0); try AReportHelper.DrawPage(PageNo,MFC,True,iPaperHeight); finally MFC.Free; end; RR := CreateRect(0.5,0.5,PageWidth-1.0,(PageHeight-1.0) ); StretchDraw(RR,MF); Inc(PageNo); end else break; until False; // Now Print trailing code page YPos := 1.0; for i:=1 to 40 do begin PrintLeft(StringOfChar('B',i),0.5); CrLf; end; end; end; |
Powered by ABC Amber Outlook Express Converter