如何显示中文化的打印预览对话框
拷贝C:/Rave5/Source目录中的RpFormPreview.pas和RpFormPreview.dfm到对应的项目目录中。
把RpFormPreview.pas加入到对应的项目文件中,把对应窗体的名字从RavePreviewForm更改为SCRavePreviewForm;将文件RpFormPreview.pas另存为SCFormPreview.pas。
把窗体SCRavePreviewForm中的对应文字从英文更改为中文。
在主窗体上加上 RvProject和 RvSystem部件,通过设定RvProject.Engine为RvSystem部件来把两者挂接。
设置RvSystem部件的OverridePreview事件过程为以下代码:
procedure TForm1.RvSystem1OverridePreview(ReportSystem: TRvSystem;
OverrideMode: TOverrideMode;
var OverrideForm: TForm);
begin
Case OverrideMode Of
omCreate:
begin
OverrideForm := TSCRavePreviewForm.Create(self);
//OverrideForm.Caption := ReportSystem.TitlePreview;
OverrideForm.Width := ReportSystem.SystemPreview.FormWidth;
OverrideForm.Height := ReportSystem.SystemPreview.FormHeight;
OverrideForm.WindowState := ReportSystem.SystemPreview.FormState;
(OverrideForm As TSCRavePreviewForm).ReportSystem := ReportSystem;
end;
omShow:
begin
ReportSystem.SystemPreview.InitPreview((OverrideForm As TSCRavePreviewForm).RvRenderPreview);
If Assigned(ReportSystem.OnPreviewSetup) then
begin
ReportSystem.OnPreviewSetup((OverrideForm As TSCRavePreviewForm).RvRenderPreview);
end;
{ if }
(OverrideForm As TSCRavePreviewForm).InputFileName := ReportSystem.SystemFiler.Filename;
(OverrideForm As TSCRavePreviewForm).InputStream := ReportSystem.SystemFiler.Stream;
(OverrideForm As TSCRavePreviewForm).InitFromRPSystem;
(* *)
If soPreviewModal In ReportSystem.SystemOptions then
begin
OverrideForm.ShowModal;
End
else
begin
OverrideForm.Show;
end;
{ else
}
end;
omWait:
begin
If Not (soPreviewModal In ReportSystem.SystemOptions) then
begin
// Wait for close
Repeat
Sleep(250);
Application.ProcessMessages;
Until Not OverrideForm.Visible;
end;
{ if }
end;
omFree:
begin
If (ReportSystem.SystemFiler.StreamMode In [smTempFile, smFile]) then
begin
(OverrideForm As TSCRavePreviewForm).RvRenderPreview.NDRStream.Free;
(OverrideForm As TSCRavePreviewForm).RvRenderPreview.NDRStream := Nil;
end;
{ if }
FreeAndNil(OverrideForm);
end;
end;
{ case }
end;
编译运行这个项目,其打印预览窗口就会变成中文的了!
备注:这种方式进行中文化不会受到RAVE版本升级的影响!