⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qreport.pas

📁 delphi7报表打印控件源码 可以设计报表
💻 PAS
📖 第 1 页 / 共 2 页
字号:

procedure ShowAboutBox;
begin
  with TQRAboutBox.Create(Application) do
  try
    ShowModal;
  finally
    free;
  end;
end;

procedure MarkModified(Report: TQuickRep);
var
  Component: TComponent;
begin
  Component := Report;
  while Component <> nil do
    if Component is TForm then
    begin
      if TForm(Component).Designer <> nil then
        TForm(Component).Designer.Modified;
      Break;
    end
    else Component := Component.Owner;
end;

procedure ExecuteDesignVerb(Index: Integer; Report: TQuickRep);
begin
  case Index of
    3 : ShowAboutBox;
    4 : EditReport(Report);
    5 : Report.PreviewModal;
    7 : Report.Zoom:=Report.Zoom + 20;
    8 : Report.Zoom:=Report.Zoom - 20;
  end;
  if Index in [4, 7, 8] then MarkModified(Report);
end;

{ TQReportDesignModeMenu }

type
  TQReportDesignModeMenu = Class(TComponentEditor)
  protected
    FReport : TQuickRep;
  public
{$ifndef ver100}
    constructor Create(AComponent: TComponent; ADesigner: IDesigner); override;
{$else}
    constructor Create(AComponent: TComponent; ADesigner: TFormDesigner); override;
{$endif}
    procedure Edit; override;
    procedure ExecuteVerb(Index: integer); override;
    function GetVerb(Index: integer): string; override;
    function GetVerbCount : integer; override;
  end;

constructor TQReportDesignModeMenu.Create(AComponent: TComponent; ADesigner: IDesigner);
begin
  inherited Create(AComponent, ADesigner);
  FReport:=TQuickRep(aComponent);
end;

procedure TQReportDesignModeMenu.Edit;
begin
  EditReport(FReport);
end;

function TQReportDesignModeMenu.GetVerb(Index: integer): string;
begin
  case Index of
    0 : result := cQRName;
    1 : result := SqrCopyright;
    2 : result := '-';
    3 : result := SqrAboutQR;
    4 : result := SqrReportSettings;
    5 : result := SqrPreview;
    6 : result := '-';
    7 : result := SqrZoomIn;
    8 : result := SqrZoomOut;
    9 : result := '-';
    10 : result := SqrRotateBands;
    11 : result := SqrHideBands;
    12 : result := SqrResetBands;
  end
end;

function TQReportDesignModeMenu.GetVerbCount : integer;
begin
  Result:=13;
end;

procedure TQReportDesignModeMenu.ExecuteVerb(Index: integer);
begin
  case Index of
    0, 1, 3 : ShowAboutBox;
    4 : EditReport(FReport);
    5 : FReport.PreviewModal;
    7 : FReport.Zoom := FReport.Zoom + 20;
    8 : FReport.Zoom := FReport.Zoom - 20;
    10 : FReport.RotateBands := FReport.RotateBands + 1;
    11 : FReport.HideBands := true;
    12 : begin
           FReport.RotateBands := 0;
           FReport.HideBands := false;
         end;
  end;
  if Index in [4, 7, 8] then MarkModified(FReport);
end;

{ TQRGroupDesignModeMenu }

type
  TQRGroupDesignModeMenu = Class(TComponentEditor)
  protected
    FGroup : TQRGroup;
  public
    constructor Create(AComponent: TComponent; ADesigner: IDesigner); override;
    procedure ExecuteVerb(Index: integer); override;
    function GetVerb(Index: integer): string; override;
    function GetVerbCount : integer; override;
  end;

constructor TQRGroupDesignModeMenu.Create(AComponent: TComponent; ADesigner: IDesigner);
begin
  inherited Create(AComponent, ADesigner);
  FGroup:=TQRGroup(aComponent);
end;

function TQRGroupDesignModeMenu.GetVerb(Index: integer): string;
begin
  case Index of
    0 : result := cQRName;
    1 : result := SqrCopyright;
    2 : result := '-';
    3 : result := SqrMoveGroupUp;
  end;
end;

function TQRGroupDesignModeMenu.GetVerbCount : integer;
begin
  Result:=4;
end;

procedure TQRGroupDesignModeMenu.ExecuteVerb(Index: integer);
var
  aOwner : TComponent;
  aParent : TWinControl;
  CompList : TList;
  I : integer;
  CurGroup : integer;
begin
  AOwner := FGroup.Owner;
  AParent := FGroup.Parent;
  CompList := nil;
  try
    CompList := TList.Create;
    for I := 0 to AOwner.ComponentCount - 1 do
      if (AOwner.Components[I] is TQRGroup) and
        (TQRGroup(AOwner.Components[I]).Master = FGroup.Master) then
        CompList.Add(AOwner.Components[I]);
    if CompList.Count > 1 then
    begin
      CurGroup := CompList.IndexOf(FGroup);
      case Index of
        3 : if CurGroup > 0 then CompList.Move(CurGroup, 0);
      end;
      for I := 0 to CompList.Count - 1 do
      begin
        AOwner.RemoveComponent(CompList[I]);
        TQRGroup(CompList[I]).Parent := nil;
      end;
      for I := 0 to CompList.Count - 1 do
      begin
        AOwner.InsertComponent(CompList[I]);
        TQRGroup(CompList[I]).Parent := AParent;
        TQRGroup(CompList[I]).Master := TQRGroup(CompList[I]).Master;
      end;
    end;
  finally
    CompList.Free;
  end;
end;

{ TQRSubDetailDesignModeMenu }

type
  TQRSubDetailDesignModeMenu = Class(TComponentEditor)
  protected
    FSubDetail : TQRSubDetail;
  public
    constructor Create(AComponent: TComponent; ADesigner: IDesigner); override;
    procedure ExecuteVerb(Index: integer); override;
    function GetVerb(Index: integer): string; override;
    function GetVerbCount : integer; override;
  end;

constructor TQRSubDetailDesignModeMenu.Create(AComponent: TComponent; ADesigner: IDesigner);
begin
  inherited Create(AComponent, ADesigner);
  FSubDetail:=TQRSubDetail(aComponent);
end;

function TQRSubDetailDesignModeMenu.GetVerb(Index: integer): string;
begin
  case Index of
    0 : result := cQRName;
    1 : result := SqrCopyright;
    2 : result := '-';
    3 : result := SqrMoveSubdetailUp;
  end;
end;

function TQRSubDetailDesignModeMenu.GetVerbCount : integer;
begin
  Result:=4;
end;

procedure TQRSubDetailDesignModeMenu.ExecuteVerb(Index: integer);
var
  aOwner : TComponent;
  aParent : TWinControl;
  CompList : TList;
  I : integer;
  CurSub : integer;
begin
  AOwner := FSubDetail.Owner;
  AParent := FSubDetail.Parent;
  if AParent is TQuickRep then
  begin
    CompList := TList.Create;
    try
      for I := 0 to AOwner.ComponentCount - 1 do
        if (AOwner.Components[I] is TQRSubDetail) and
          (TQRSubDetail(AOwner.Components[I]).Master = FSubDetail.Master) then
          CompList.Add(AOwner.Components[I]);
      if CompList.Count > 1 then
      begin
        CurSub := CompList.IndexOf(FSubDetail);
        if CurSub > - 1 then
        case Index of
          3 : if CurSub > 0 then CompList.Move(CurSub, 0);
        end;
        for I := 0 to CompList.Count - 1 do
        begin
          AOwner.RemoveComponent(CompList[I]);
          TQRSubDetail(CompList[I]).Parent := nil;
        end;
        for I := 0 to CompList.Count - 1 do
        begin
          AOwner.InsertComponent(CompList[I]);
          TQRSubDetail(CompList[I]).Parent := AParent;
          TQRSubDetail(CompList[I]).Master := TQRSubDetail(CompList[I]).Master;
        end;
      end;
    finally
      CompList.Free;
    end;
  end;
end;

{ Register components and property editors }

procedure Register;
begin
  RegisterComponents(SqrPaletteQReport,[TQuickRep, (*TQuickLabelReport,*) TQuickAbstractRep, TQRSubDetail, TQRLoopBand, TQRStringsBand,
    TQRBand, TQRChildBand, TQRGroup, TQRLabel, TQRDBText, TQRExpr, TQRSysData, TQRMemo, TQRExprMemo,
    TQRRichText, TQRDBRichText, TQRShape, TQRImage, TQRDBImage, TQRCompositeReport,
    TQRPreview, TQRTextFilter, TQRCSVFilter, TQRPDFFilter, TQRHTMLFilter, TQRExcelFilter, TQRRTFFilter, TQRWMFFilter,
    TQREditor, TQRGrImage, TQrGrDBImage, TQRXMLSFilter, TQRPDFShape, TQRAbsTable, TQRHTMLLabel, TQRHRule]);
  RegisterPropertyEditor(TypeInfo(string), TQRDBRichText, 'DataField', TQRDataFieldProperty);
  RegisterPropertyEditor(TypeInfo(extended), TQRPage, '', TQRFloatProperty);
  RegisterPropertyEditor(TypeInfo(extended), TQRLabelSetup, '', TQRFloatProperty);
  RegisterPropertyEditor(TypeInfo(extended), TQRBandSize, '', TQRFloatProperty);
  RegisterPropertyEditor(TypeInfo(extended), TQRPrintableSize, '', TQRFloatProperty);
  RegisterPropertyEditor(TypeInfo(string), TQRCustomLabel, 'Caption', TQRCaptionProperty); {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(TComponent), TQRExpr, 'Master', TQRMasterProperty);      {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(TComponent), TQRGroup, 'Master', TQRMasterProperty);     {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(TComponent), TQRSubDetail, 'Master', TQRMasterProperty); {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(string), TQRDBText, 'DataField', TQRDataFieldProperty);  {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(string), TQRDBImage, 'DataField', TQRDataFieldProperty); {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(string), TQRExpr, 'Expression', TQRExprProperty);        {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(string), TQRGroup, 'Expression', TQRExprProperty);       {<-- do not resource }
  RegisterPropertyEditor(TypeInfo(TQREvEnvironment), TCustomQuickRep, 'Functions', TQREnvProperty);
  RegisterComponentEditor(TCustomQuickRep,TQReportDesignModeMenu);
  RegisterComponentEditor(TQRImage, TQRGraphicEditor);
  RegisterComponentEditor(TQRGroup, TQRGroupDesignModeMenu);
  RegisterComponentEditor(TQRSubDetail, TQRSubDetailDesignModeMenu);
  RegisterClasses([TQRDBCalc]);
  RegisterNonActiveX([TQuickRep, TQRSubDetail, TQRChildBand, TQRGroup,
    TQRDBText, TQRExpr, TQRSysData, TQRMemo, TQRDBRichText, TQRShape, TQRImage,
    TQRDBImage, TQRCompositeReport, TQRPreview,
    TQRBasePanel, TQRCustomBand, TQRCustomLabel, TQRCustomRichText, TQRBand,
    TQRControllerBand, TQRLabel, TQRPrintable, TQRRichText], axrIncludeDescendants);

  RegisterLibraryExpert(TQReportIDEWizard.Create);
  RegisterPropertiesInCategory('Localizable', TCustomQuickRep,    ['ReportTitle']);
  RegisterPropertiesInCategory('Localizable', TQRCompositeReport, ['ReportTitle']);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -