您的位置:首页 > 其它

zt:如何显示中文化的打印预览对话框

2004-07-14 16:05 351 查看
如何显示中文化的打印预览对话框
拷贝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版本升级的影响!

------------------------------------------------------------------------------------------
参考资料一

This is the recommended method for those that have Rave Reports source code (BEX customers). This method shows how to override the built-in preview system. This approach is more flexible and therefore, more desirable. In simple terms, you copy the existing preview source (RpFormPreview) to a different name (say MyPreview). Then you use the RpSystem source to see how the OverridePreviewProc is structured and copy appropriate parts to your RvSystem component overridepreview event. Now here are the steps.

PART 1

1. Copy RpFormPreview.PAS and RpFormPreview.DFM to new files, let's call them MyPreview.PAS and MyPreview.DFM.

2. Open MyPreview.PAS inside Delphi (preferably with your project already open) and rename the unit heading to MyPreview.

3. Rename the form associated with MyPreview.PAS to MyPreviewForm in the Object Inspector.

4. Add the unit MyPreview to your project using the project manager.

PART 2

5. Open the file RPSYSTEM.PAS from the source subdirectory and go to the procedure OverridePreviewProc. This block of code will be used in the next step.

6. Go to one of your ReportSystem components and open event tab. Then create (double-click) on the OverridePreview event. In OverridePreview code area copy the corresponding code from the RPSYSTEM.PAS OverridePreviewProc block of code.

7. Replace all occurrences of TRPPreviewForm (standard preview) with TMyPreviewForm (your custom preview) throughout the new OverridePreview procedure.

8. Make some simple change to your MyPreview source. For example, change the caption to read "New Custom Preview".

9. Recompile your project using Build All.

Run your program and generate a report that uses the modified ReportSystem component. If you see your "New Custom Preview", then you are well on your way. Now, you can modify your custom preview form as you wish.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐