熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Delphi編程 >> 正文

Delphi 7 中使用RAVE報表(六)

2022-06-13   來源: Delphi編程 
    作為《Delphi 中使用RAVE報表》的最後整理一些技巧給大家

  .設計好的Rave報表文件如何打包到EXE文件中?

   在Rvproject的屬性中有一個StoreRav只要load對應的rav文件即可!同時最好把對應rvproject的ProjectFile屬性清空

  .如何顯示中文化的打印預覽對話框?

  )拷貝C:\Rave\Source目錄中的RpFormPreviewpas和RpFormPreviewdfm到對應的項
目目錄中

  )把RpFormPreviewpas加入到對應的項目文件中把對應窗體的名字從
RavePreviewForm更改為SCRavePreviewForm將文件RpFormPreviewpas另存為
SCFormPreviewpas

  3)把窗體SCRavePreviewForm中的對應文字從英文更改為中文

  4)在主窗體上加上 RvProject和 RvSystem部件通過設定RvProjectEngine為
RvSystem部件來把兩者掛接

  5)設置RvSystem部件的OverridePreview事件過程為以下代碼

procedure TFormRvSystemOverridePreview(ReportSystem: TRvSystem;
OverrideMode: TOverrideMode; var OverrideForm: TForm);
begin
Case OverrideMode Of
omCreate:
Begin
OverrideForm := TSCRavePreviewFormCreate(self);
//OverrideFormCaption := ReportSystemTitlePreview;
OverrideFormWidth := ReportSystemSystemPreviewFormWidth;
OverrideFormHeight := ReportSystemSystemPreviewFormHeight;
OverrideFormWindowState := ReportSystemSystemPreviewFormState;
(OverrideForm As TSCRavePreviewForm)ReportSystem := ReportSystem;
End;
omShow:
Begin
ReportSystemSystemPreviewInitPreview((OverrideForm As
TSCRavePreviewForm)RvRenderPreview);
If Assigned(ReportSystemOnPreviewSetup) Then
Begin
ReportSystemOnPreviewSetup((OverrideForm As
TSCRavePreviewForm)RvRenderPreview);
End; { if }
(OverrideForm As TSCRavePreviewForm)InputFileName :=
ReportSystemSystemFilerFilename;
(OverrideForm As TSCRavePreviewForm)InputStream :=
ReportSystemSystemFilerStream;
(OverrideForm As TSCRavePreviewForm)InitFromRPSystem;
(* *)
If soPreviewModal In ReportSystemSystemOptions Then
Begin
OverrideFormShowModal;
End
Else
Begin
OverrideFormShow;
End; { else }
End;
omWait:
Begin
If Not (soPreviewModal In ReportSystemSystemOptions) Then
Begin
// Wait for close
Repeat
Sleep();
ApplicationProcessMessages;
Until Not OverrideFormVisible;
End; { if }
End;
omFree:
Begin
If (ReportSystemSystemFilerStreamMode In [smTempFile smFile]) Then
Begin
(OverrideForm As TSCRavePreviewForm)RvRenderPreviewNDRStreamFree;
(OverrideForm As TSCRavePreviewForm)RvRenderPreviewNDRStream :=
Nil;
End; { if }
FreeAndNil(OverrideForm);
End;
End; { case }
end;

  6)編譯運行這個項目其打印預覽窗口就會變成中文的了

  備注這種方式進行中文化不會受到RAVE版本升級的影響

  .如何顯示中文化的打印設置對話框?

  1)拷貝C:\Rave\Source目錄中的RpFormSetuppas和RpFormSetupdfm到對應的項目目
錄中

  2)把RpFormSetuppas加入到對應的項目文件中把對應窗體的名字從RPSetupForm更改
為SCSetupForm將文件RpFormSetuppas另存為SCFormSetuppas

  3)把窗體SCSetupForm中的對應文字從英文更改為中文

  4)在主窗體上加上 RvProject和 RvSystem部件通過設定RvProjectEngine為
RvSystem 部件來把兩者掛接

  5)設置RvSystem部件的OverrideSetup事件過程為以下代碼

procedure TFormRvSystemOverrideSetup(ReportSystem: TRvSystem;
OverrideMode: TOverrideMode; var OverrideForm: TForm);
begin
case
OverrideMode of
omCreate:
begin
OverrideForm := TSCSetupFormCreate(nil);
//OverrideFormCaption := RvSystemTitleSetup;
(OverrideForm as TSCSetupForm)ReportSystem := ReportSystem;
end;
omShow:
begin
with OverrideForm as TSCSetupForm ReportSystem do
begin
PreviewSetup := False;
Aborted := ShowModal = mrCancel;
end;
end;
omWait:
begin
{because showModal: no wait necessary!}
end;
omFree:
begin
OverrideFormFree;
end;
end;
end;

  6)編譯運行這個項目其打印設置對話框就會變成中文的了!

  這種方式進行中文化不會受到RAVE版本升級的影響!對於其它對話框應該可以同法炮制吧!

  .如何自已做預覽窗口?

  1)創建一個窗口在上面放RvProject組件RvNDRWriter組件RvRenderPreview組件和ScrollBox組件設定以下幾個部件間的聯系關系

RvProjectEngine:=RvNDRWriter;
RvRenderPreviewScrollBox:=ScrollBox;

  2)設定RvNDRWriterfilename為 demondr 進行預覽的代碼為

var
NDRStream:TMemoryStream;
begin
//建立內存流
NDRStream:=TMemoryStreamCreate
//輸出報表數據
RvProjectExecute
//將報表數據調入內存流中供預覽
NDRStreamLoadFromFile(demondr);
//預覽相應的報表使用的是相應的內存流
RvRenderPreviewRender(NDRStream);
ShowButton();
end;
<![if !supportEmptyParas]> <![endif]>

  要想在你的項目中很好的應用RAVE做好報表更多的內容參考\Rave\Docs\下的RAVE手冊
<![if !supportEmptyParas]> <![endif]>
<![if !supportEmptyParas]> <![endif]>
<![if !supportEmptyParas]> <![endif]>
From:http://tw.wingwit.com/Article/program/Delphi/201311/24719.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.