trichview.com

trichview.support




Re: storing page properties in document


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/28/2004 23:41:05


How to save RVPrint's margins in RVF files (not RTF):



1) Include rvfoSaveDocProperties and rvfoLoadDocProperties in

RichViewEdit1.RVFOptions

2) Write two procedures for saving and loading margins in

RichViewEdit1.DocProperties:


procedure TForm3.DocPropToRVPrint;

var s: String;

begin

s := RichViewEdit1.DocProperties.Values['LeftMarginMM'];

RVPrint1.LeftMarginMM := StrToIntDef(s, 20);

s := RichViewEdit1.DocProperties.Values['TopMarginMM'];

RVPrint1.TopMarginMM := StrToIntDef(s, 20);

s := RichViewEdit1.DocProperties.Values['RightMarginMM'];

RVPrint1.RightMarginMM := StrToIntDef(s, 20);

s := RichViewEdit1.DocProperties.Values['BottomMarginMM'];

RVPrint1.BottomMarginMM := StrToIntDef(s, 20);

end;


procedure TForm3.RVPrintToDocProp;

begin

RichViewEdit1.DocProperties.Clear;

RichViewEdit1.DocProperties.Add('LeftMarginMM='+IntToStr(RVPrint1.LeftMargi

nMM));

RichViewEdit1.DocProperties.Add('TopMarginMM='+IntToStr(RVPrint1.TopMarginM

M));


RichViewEdit1.DocProperties.Add('RightMarginMM='+IntToStr(RVPrint1.RightMarg

inMM));


RichViewEdit1.DocProperties.Add('BottomMarginMM='+IntToStr(RVPrint1.BottomMa

rginMM))

;

end;


3) Process rvActionPageSetup.OnExecute.

First call default Execure (showing dialog), then save changes in

RIchViewEdit1.DocProperties:


procedure TForm3.rvActionPageSetupExecute(Sender: TObject);

begin

(Sender as TrvActionPageSetup).OnExecute := nil;

(Sender as TrvActionPageSetup).Execute;

(Sender as TrvActionPageSetup).OnExecute := rvActionPageSetupExecute;

RichViewEdit1.Change;

RVPrintToDocProp;

end;


4) Process rvActionSave.OnDocumentFileChange

(this event is already processed in the ActionTest demo)

Add the code reading margins to RVPrint from DocProperties.


procedure TForm3.rvActionSave1DocumentFileChange(Sender: TObject;

Editor: TCustomRichViewEdit; const FileName: String;

FileFormat: TrvFileSaveFilter; IsNew: Boolean);

begin

....

DocPropToRVPrint;

end;





Powered by ABC Amber Outlook Express Converter