?? rm_reg.pas
字號:
{*****************************************}
{ }
{ Report Machine v2.0 }
{ Registration unit }
{ }
{*****************************************}
unit RM_reg;
interface
{$I RM.inc}
procedure Register;
implementation
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
DB, Dialogs, Printers,
{$IFDEF Delphi6}
DesignIntf, DesignEditors,
{$ELSE}
DsgnIntf,
{$ENDIF}
RM_Prntr, RM_Pgopt, RM_Class, RM_DSet, RM_Utils, RM_Const,
RM_DBSet, RM_OLE, RM_Rich, RM_ChBox, RM_Shape, RM_BarC, RM_Desgn, RM_View,
RM_RRect, RM_AngLbl, RM_Cross,
RM_e_txt, RM_e_csv, RM_e_rtf, RM_e_htm, RM_e_bmp, RM_e_emf, RM_e_pdf
{$IFDEF RXGIF}, RM_e_gif{$ENDIF}{$IFDEF JPEG}, RM_e_jpeg{$ENDIF}
, RM_DCtrl, RMD_RptExp, RM_FormReport
{$IFDEF EHLib}, RM_PEHGrid{$ENDIF}
{$IFDEF DecisionGrid}, RM_PdcsGrid{$ENDIF}
{$IFDEF TeeChart}, RM_Chart{$ENDIF}
{$IFDEF RX}, RM_RxRTF, RM_PRxCtls{$ENDIF}
{$IFDEF InfoPower}, RM_PwwGrid, RM_wwrtf{$ENDIF}
, RMD_BDE
{$IFDEF DM_ADO}, RMD_ADO{$ENDIF}
{$IFDEF DM_IBX}, RMD_IBX{$ENDIF}
{$IFDEF DM_DBX}, RMD_DBX{$ENDIF}
{$IFDEF DM_Diamond}, RMD_Diamond{$ENDIF}
{$IFDEF DM_HALCYON}, RMD_Halcyon{$ENDIF}
{$IFDEF DM_DBISAM}, RMD_Dbisam{$ENDIF};
{-----------------------------------------------------------------------}
type
TRMPageLayoutProperty = class(TClassProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
TRMRepEditor = class(TComponentEditor)
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
procedure DoDesign;
end;
TRMPrintTblEditor = class(TComponentEditor)
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
procedure DoShow;
end;
{ TRMFieldProperty }
TRMFieldProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValueList(List: TStrings);
procedure GetValues(Proc: TGetStrProc); override;
end;
{ TRMRichEditStrings }
TRMRichEditStrings = class(TClassProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure Edit; override;
end;
{-----------------------------------------------------------------------}
{-----------------------------------------------------------------------}
{ TRMPageLayoutProperty }
function TRMPageLayoutProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
procedure TRMPageLayoutProperty.Edit;
var
tmpForm: TRMPageSetupForm;
tmp: TRMPageLayout;
begin
tmp := TRMPageLayout(GetOrdValue);
tmpForm := TRMPageSetupForm.Create(Application);
try
with tmpForm do
begin
PageSetting.PrintToDefault := tmp.PrintToDefault;
PageSetting.DoublePass := tmp.DoublePass;
PageSetting.UseMargins := True;
PageSetting.PageOr := tmp.pgOr;
PageSetting.MarginLeft := RMRound(RMConvertFromPixels(tmp.LeftMargin, rmsuMM) / 10, 1);
PageSetting.MarginTop := RMRound(RMConvertFromPixels(tmp.TopMargin, rmsuMM) / 10, 1);
PageSetting.MarginRight := RMRound(RMConvertFromPixels(tmp.RightMargin, rmsuMM) / 10, 1);
PageSetting.MarginBottom := RMRound(RMConvertFromPixels(tmp.BottomMargin, rmsuMM) / 10, 1);
PageSetting.ColCount := tmp.Columns;
PageSetting.ColGap := RMRound(RMConvertFromPixels(tmp.ColumnSpace, rmsuMM) / 10, 1);
PageSetting.PageWidth := tmp.Width;
PageSetting.PageHeight := tmp.Height;
PageSetting.PageSize := tmp.pgSize;
PageSetting.PageBin := tmp.pgBin;
PageSetting.PrinterName := tmp.PrinterName;
if ShowModal = mrOk then
begin
tmp.PrinterName := PageSetting.PrinterName;
tmp.PrintToDefault := PageSetting.PrintToDefault;
tmp.DoublePass := PageSetting.DoublePass;
tmp.pgOr := PageSetting.PageOr;
tmp.Columns := PageSetting.ColCount;
tmp.ColumnSpace := Round(RMConvertToPixels(PageSetting.ColGap * 10, rmsuMM));
tmp.LeftMargin := Round(RMConvertToPixels(PageSetting.MarginLeft * 10, rmsuMM));
tmp.TopMargin := Round(RMConvertToPixels(PageSetting.MarginTop * 10, rmsuMM));
tmp.RightMargin := Round(RMConvertToPixels(PageSetting.MarginRight * 10, rmsuMM));
tmp.BottomMargin := Round(RMConvertToPixels(PageSetting.MarginBottom * 10, rmsuMM));
tmp.Width := PageSetting.PageWidth;
tmp.Height := PageSetting.PageHeight;
tmp.pgBin := PageSetting.PageBin;
tmp.pgSize := PageSetting.PageSize;
Modified;
// SetOrdValue(Longint(tmp));
end;
end;
finally
tmpForm.Free;
end;
end;
{-----------------------------------------------------------------------}
{-----------------------------------------------------------------------}
{ TRMRepEditor }
procedure TRMRepEditor.ExecuteVerb(Index: Integer);
begin
DoDesign;
end;
function TRMRepEditor.GetVerb(Index: Integer): string;
begin
Result := RMLoadStr(SDesignReport);
end;
function TRMRepEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
procedure TRMRepEditor.DoDesign;
begin
TRMReport(Component).DesignReport;
if TRMReport(Component).StoreInDFM then
begin
if TRMReport(Component).ComponentModified then
Designer.Modified;
end;
end;
{----------------------------------------------------------------------------}
{----------------------------------------------------------------------------}
procedure TRMPrintTblEditor.ExecuteVerb(Index: Integer);
begin
DoShow;
end;
function TRMPrintTblEditor.GetVerb(Index: Integer): string;
begin
Result := RMLoadStr(SPreview);
end;
function TRMPrintTblEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
procedure TRMPrintTblEditor.DoShow;
begin
TRMCustomGridReport(Component).PreviewReport;
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMFieldProperty}
function TRMFieldProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect];
end;
procedure TRMFieldProperty.GetValueList(List: TStrings);
var
liReport: TRMCustomGridReport;
begin
if (GetComponent(0) = nil) then Exit;
liReport := nil;
if (GetComponent(0) is TRMGroupItem) then
liReport := (GetComponent(0) as TRMGroupItem).Report;
if liReport <> nil then
begin
if liReport.DataSet <> nil then
liReport.DataSet.GetFieldNames(List)
else if (liReport.DataSource <> nil) and (liReport.DataSource.DataSet <> nil) then
liReport.DataSource.DataSet.GetFieldNames(List);
end;
end;
procedure TRMFieldProperty.GetValues(Proc: TGetStrProc);
var
i: Integer;
Values: TStringList;
begin
Values := TStringList.Create;
try
GetValueList(Values);
for i := 0 to Values.Count - 1 do Proc(Values[i]);
finally
Values.Free;
end;
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMRichEditStrings}
type
THackRMPageHeaderFooter = class(TRMPageHeaderFooter)
end;
function TRMRichEditStrings.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog] - [paSubProperties];
end;
procedure TRMRichEditStrings.Edit;
var
Stream: TStringStream;
begin
if RMDesignerClass <> nil then
begin
CurReport := THackRMPageHeaderFooter(GetComponent(0)).ParentFormReport.Report;
RMDesigner := TRMReportDesigner(RMDesignerClass.NewInstance);
RMDesigner.CreateDesigner(True);
end;
{$IFDEF InfoPower}
with TRMwwRichForm.Create(Application) do
{$ELSE}
{$IFDEF RX}
with TRMRxRichForm.Create(Application) do
{$ELSE}
with TRMRichForm.Create(Application) do
{$ENDIF}
{$ENDIF}
try
Stream := TStringStream.Create('');
TStrings(GetOrdValue).SaveToStream(Stream);
Stream.Position := 0;
Editor.Lines.LoadFromStream(Stream);
case ShowModal of
mrOk:
begin
Stream.Position := 0;
Editor.Lines.SaveToStream(Stream);
Stream.Position := 0;
TStrings(GetOrdValue).LoadFromStream(Stream);
Modified;
end;
end;
Stream.Free;
finally
if RMDesignerClass <> nil then
begin
RMDesigner.Free;
RMDesigner := nil;
end;
Free;
end;
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
procedure Register;
begin
RegisterComponents('Report Machine',
[TRMReport, TRMCompositeReport, TRMDBDataSet, TRMUserDataset, TRMOLEObject,
TRMRichObject, TRMCheckBoxObject, TRMShapeObject, TRMBarCodeObject, TRMRoundRectObject,
TRMAngledLabelObject, TRMCrossObject,
{$IFDEF TeeChart}TRMChartObject, {$ENDIF}
{$IFDEF RX}TRMRxRichObject, {$ENDIF}
{$IFDEF InfoPower}TRMwwRichObject, {$ENDIF}
TRMPreview, TRMTextExport, TRMRTFExport, TRMCSVExport, TRMHTMExport, TRMEMFExport,
TRMWMFExport, TRMBMPExport
{$IFDEF RXGIF}, TRMGIFExport{$ENDIF}{$IFDEF JPEG}, TRMJPEGExport{$ENDIF}, TRMPDFExport,
TRMDialogControls]);
RegisterComponents('RM Designer', [TRMDesigner, TRMReportExplorer
{$IFDEF DM_BDE}, TRMDBDEComponents{$ENDIF}
{$IFDEF DM_ADO}, TRMDADOComponents{$ENDIF}
{$IFDEF DM_IBX}, TRMDIBXComponents{$ENDIF}
{$IFDEF DM_DBX}, TRMDDBXComponents{$ENDIF}
{$IFDEF DM_Diamond}, TRMDDiamondComponents{$ENDIF}
{$IFDEF DM_Halcyon}, TRMDHalcyonComponents{$ENDIF}
{$IFDEF DM_DBISAM}, TRMDDBISAMComponents{$ENDIF}
//{$IFDEF DecisionGrid}, TRMDecisionGridReport{$ENDIF}
, TRMFormReport
{$IFDEF InfoPower}, TRMwwGridReport{$ENDIF}
{$IFDEF RX}, TRMPrintRxControls{$ENDIF}
{$IFDEF EHLib}, TRMPrintEHLib{$ENDIF}
{$IFDEF DecisionGrid}, TRMPrintDecision{$ENDIF}
]);
RegisterPropertyEditor(TypeInfo(TRMPageLayout), TRMCustomGridReport, 'PageLayout', TRMPageLayoutProperty);
RegisterPropertyEditor(TypeInfo(string), TRMGroupItem, 'GroupFieldName', TRMFieldProperty);
RegisterComponentEditor(TRMReport, TRMRepEditor);
RegisterComponentEditor(TRMCustomGridReport, TRMPrintTblEditor);
RegisterPropertyEditor(TypeInfo(TStrings), TRMPageHeaderFooter, 'Caption', TRMRichEditStrings);
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -