RichView RichEdit SRichViewEdit PageSize 页面快捷设置
建立一个RichView RichEdit SRichViewEdit PageSize 页面快捷设置界面:
可以快速对RichView进行Page的参数,进行设置:
例如竖页:
切换横页:
一键切换。
按键代码:
procedure TRichView_11_Frm.sButton7Click(Sender: TObject);
var sPage,sMargin:string;
begin
sPage:=sComboBox1.text;
sMargin:=sComboBox2.text;
// 切换 poPortrait poLandscape
if sRadioButton1.Checked
then SetDBSRichViewEditPageSize(SRichViewEdit1,sPage,sMargin,poPortrait)
else SetDBSRichViewEditPageSize(SRichViewEdit1,sPage,sMargin,poLandscape);
SRichViewEdit1.RichViewEdit.Format;
SRichViewEdit1.RichViewEdit.SetFocus;
end;
实现上述操作,关键是,要建立一个设置页面的函数:
procedure SetDBSRichViewEditPageSize(RV: TDBSRichViewEdit;sPage,sMargin:string;PrinterOrientation:TPrinterOrientation);
var iLong,iSort:Integer;
begin
if sPage='A3' then
begin
RV.RichViewEdit.DocParameters.Units := rvuMillimeters;
// TRVUnits = (rvuInches, rvuCentimeters, rvuMillimeters, rvuPicas, rvuPixels, rvuPoints);
RV.PageProperty.Orientation:=PrinterOrientation; // 页面方向 poPortrait poLandscape
iLong:=420;
iSort:=297;
if PrinterOrientation=poPortrait then
begin
RV.PageProperty.PageWidth := iSort;
RV.PageProperty.PageHeight := iLong;
end
else begin
RV.PageProperty.PageWidth := iLong;
RV.PageProperty.PageHeight := iSort;
end;
end;
if sPage='A4' then
begin
RV.RichViewEdit.DocParameters.Units := rvuMillimeters;
// TRVUnits = (rvuInches, rvuCentimeters, rvuMillimeters, rvuPicas, rvuPixels, rvuPoints);
RV.PageProperty.Orientation:=PrinterOrientation; // 页面方向 poPortrait poLandscape
iLong:=297;
iSort:=210;
if PrinterOrientation=poPortrait then
begin
RV.PageProperty.PageWidth := iSort;
RV.PageProperty.PageHeight := iLong;
end
else begin
RV.PageProperty.PageWidth := iLong;
RV.PageProperty.PageHeight := iSort;
end;
end;
if sPage='A5' then
begin
RV.RichViewEdit.DocParameters.Units := rvuMillimeters;
// RV.PageProperty :=RV.PagePropertyMain.PageProperty;
RV.PageProperty.Orientation:=PrinterOrientation; // 页面方向 poPortrait poLandscape
iLong:=210;
iSort:=148;
if PrinterOrientation=poPortrait then
begin
RV.PageProperty.PageWidth := iSort;
RV.PageProperty.PageHeight := iLong;
end
else begin
RV.PageProperty.PageWidth := iLong;
RV.PageProperty.PageHeight := iSort;
end;
end;
if sMargin='国际标准' then
begin
RV.PageProperty.TopMargin := 25.4;
RV.PageProperty.BottomMargin := 25.4;
RV.PageProperty.LeftMargin := 31.75;
RV.PageProperty.RightMargin := 31.75;
RV.PageProperty.HeaderY := 12.7;
RV.PageProperty.FooterY := 12.7;
end;
if sMargin='标准1' then
begin
RV.PageProperty.TopMargin := 25.4;
RV.PageProperty.BottomMargin := 25.4;
RV.PageProperty.LeftMargin := 30;
RV.PageProperty.RightMargin := 20;
RV.PageProperty.HeaderY := 12.7;
RV.PageProperty.FooterY := 12.7;
end;
if sMargin='标准2' then
begin
RV.PageProperty.TopMargin := 20;
RV.PageProperty.BottomMargin := 20;
RV.PageProperty.LeftMargin := 25;
RV.PageProperty.RightMargin := 15;
RV.PageProperty.HeaderY := 10;
RV.PageProperty.FooterY := 10;
end;
if sMargin='标准3' then
begin
RV.PageProperty.TopMargin := 10;
RV.PageProperty.BottomMargin := 10;
RV.PageProperty.LeftMargin := 20;
RV.PageProperty.RightMargin := 10;
RV.PageProperty.HeaderY := 8;
RV.PageProperty.FooterY := 8;
end;
if sMargin='最小边缘' then
begin
RV.PageProperty.TopMargin := 5;
RV.PageProperty.BottomMargin := 5;
RV.PageProperty.LeftMargin := 5;
RV.PageProperty.RightMargin := 5;
RV.PageProperty.HeaderY := 0;
RV.PageProperty.FooterY := 0;
end;
end;