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

📄 qm_pmemo.pas

📁 商品销售管理系统-毕业设计有代码和论文,可以做毕业设计
💻 PAS
字号:
{*******************************************************}
{                                                       }
{                   QReportMaker 2.0                    }
{                TQMPrintMemo Component                 }
{                                                       }
{            Copyright (c) 2003,2004 by Zwm.            }
{                                                       }
{*******************************************************}

unit QM_PMemo;

interface


uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls,
  QM_RConsole;

type
  { TQMPrintMemo }
  TQMPrintMemo = class(TQMReportConsole)
  private
    FMemo: TMemo;
    FLines: TStrings;
    FFitToPageWidth: Boolean;
    procedure SetMemo(const Value: TMemo);
    procedure SetLines(const Value: TStrings);
  protected
    procedure DrawReport; override;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure LoadLines;
    procedure ApplyParams;
  published
    property Memo: TMemo read FMemo write SetMemo;
    property FitToPageWidth: Boolean read FFitToPageWidth write FFitToPageWidth default false;
    property Lines: TStrings read FLines write SetLines;
  end;

implementation

uses QuickRpt, QRCtrls, QM_DCtrl, QRPrntr, QM_Utils, QM_QRFuns;

{ TQMPrintMemo }

procedure TQMPrintMemo.ApplyParams;
var
  i: Integer;
  bWordWrap: Boolean;
begin
  if Memo = nil then exit;
  bWordWrap := Memo.WordWrap;
  Memo.WordWrap := False;
  for i := 0 to Memo.Lines.Count - 1 do
    Memo.Lines[i] := QM_GetQMString(self, Memo.Lines[i]);
  Memo.WordWrap := bWordWrap;
end;

constructor TQMPrintMemo.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FLines := TStringList.Create;
end;

destructor TQMPrintMemo.Destroy;
begin
  FLines.Free;
  inherited Destroy;
end;

procedure TQMPrintMemo.DrawReport;
var
  RepWidth: Integer;
  QRMemo: TQRMemo;
  QRBand: TQRBand;
begin
  if Assigned(OnBeforeDraw) then OnBeforeDraw(self);
  if FitToPageWidth or (Memo = nil) then RepWidth := 0
  else RepWidth := Memo.Width;
  FormatReport(RepWidth);
  inherited DrawReport;
  if Memo = nil then exit;
  QRBand := QM_FindBand(rbTitle, BGColor);
  if QRBand.Tag = 1 then
    QRBand.Height := 20
  else QRBand.Height := QRBand.Height + 20;
  QRMemo := TQRMemo.Create(QROwner);
  QRMemo.Parent := QRBand;
  with QRMemo do
  begin
    AutoStretch := True;
    AutoSize := False;
    if (rcBodyFont in Options) or (Memo = nil) then
      Font.Assign(Font)
    else Font.Assign(Memo.Font);
    Lines.AddStrings(Memo.Lines);
    Alignment := Memo.Alignment;
    Color := QM_PrintColor(self, Memo.Color);
    Left := LftMargin;
    Top := QRBand.Height - 20;
    Height := 20;
    if FitToPageWidth then Width := QRBand.Width
    else Width := Memo.Width;
    Width := Round(Width * ScaleWL);
    if NeedName then
      Name := QM_UniqueName(QROwner, 'QRMemo');
  end;
end;

procedure TQMPrintMemo.LoadLines;
begin
  if Memo = nil then exit;
  Memo.Lines.AddStrings(Lines);
  ApplyParams();
end;

procedure TQMPrintMemo.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (AComponent = FMemo) then FMemo := nil;
end;

procedure TQMPrintMemo.SetLines(const Value: TStrings);
begin
  FLines.AddStrings(Value);
end;

procedure TQMPrintMemo.SetMemo(const Value: TMemo);
begin
  FMemo := Value;
  if Value <> nil then Value.FreeNotification(Self);
end;

end.

⌨️ 快捷键说明

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