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.
拷贝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.
相关文章推荐
- zt:如何显示中文化的打印设置对话框?
- WinForm中 如何直接调用Excel的打印预览功能,但不显示Excel文件
- 如何显示打印预览窗口
- 如何解决打印CAD图纸时,打印预览空白不显示
- 在Windows7 64位和VS2008环境下,PrintDialog.ShowDialog不能显示打印对话框
- LODOP横向打印预览正向显示
- C#中如何对当前窗体进行打印预览
- 在打印或打印预览前如何获取报表页数
- 开源:.NET环境下有关打印页面设置、打印机设置、打印预览对话框的实现
- 如何显示Windows标准"运行"对话框
- 如何实现基于MFC对话框的PCL显示
- C# 使用printDocument1.Print打印时不显示 正在打印对话框
- VC++对话框程序打印及打印预览的实现
- 图形的绘制,如何使用自定义画笔(颜色,线宽,线形)。如何为程序中添加选项菜单和选项设置对话框,如何使用标准颜色对话框,如何使用字体对话框,在选项对话框中实现预览功能。实现选项对话框和窗口类中的数据交换。如何改变对话框和控件的背景色,如何改变控件的文本颜色,
- Win7/Win8系统如何取消任务栏预览效果只显示窗口名称文字提示
- C# 使用printDocument1.Print打印时不显示 正在打印对话框(里面还有一个讨厌的取消按钮)
- TIPTOP GP5打印报表时如何在水晶报表中显示服务器上的图片
- How to show a modal dialog and modeless dialog using C++ - 如何用C++显示一个模态对话框和一个非模态对话框
- 开源:.NET环境下有关打印页面设置、打印机设置、打印预览对话框的实现与应用(1)
- 如何隐藏显示在任务栏中的对话框程序