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

📄 rm_e_emf.pas

📁 进销存·完整的·有数据库的·非常完整·只得参考
💻 PAS
字号:
unit RM_e_emf;

interface

{$I RM.INC}

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, RM_Class, RM_E_Graphic;

type
 { TRMEMFExport }
  TRMEMFExport = class(TRMGraphicExport)
  public
    constructor Create(AOwner: TComponent); override;
    function ShowModal: Word; override;
    procedure OnEndPage; override;
  end;

 { TRMWMFExport }
  TRMWMFExport = class(TRMGraphicExport)
  public
    constructor Create(AOwner: TComponent); override;
    function ShowModal: Word; override;
    procedure OnEndPage; override;
  end;

  { TRMEMFExportForm }
  TRMEMFExportForm = class(TForm)
    gbBMP: TGroupBox;
    btnOK: TButton;
    btnCancel: TButton;
    Label1: TLabel;
    Label2: TLabel;
    edScaleX: TEdit;
    Label3: TLabel;
    edScaleY: TEdit;
    procedure FormCreate(Sender: TObject);
  private
    procedure Localize;
  protected
  public
  end;

implementation

uses RM_CmpReg, RM_Const, RM_Utils;

{$R *.DFM}

{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMEMFExport}

constructor TRMEMFExport.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FFileExtension := 'emf';
  RMRegisterExportFilter(Self, RMLoadStr(SEMFFile), '*.emf');
end;

function TRMEMFExport.ShowModal: Word;
begin
  if not ShowDialog then
    Result := mrOk
  else
  begin
    with TRMEMFExportForm.Create(nil) do
    begin
      try
        edScaleX.Text := FloatToStr(Self.ScaleX);
        edScaleY.Text := FloatToStr(Self.ScaleY);
        Result := ShowModal;
        if Result = mrOK then
        begin
          Self.ScaleX := StrToFloat(edScaleX.Text);
          Self.ScaleY := StrToFloat(edScaleY.Text);
        end;
      finally
        Free;
      end;
    end;
  end;
end;

procedure TRMEMFExport.OnEndPage;
var
  EMF: TMetafile;
  EMFCanvas: TMetafileCanvas;
  R: TRect;
begin
  EMF := TMetafile.Create;
  R := Rect(0, 0, FPageWidth + 1, FPageHeight + 1);
  try
    EMF.Enhanced := True;
    EMF.Transparent := False;
    EMF.Width := FPageWidth;
    EMF.Height := FPageHeight;
    EMFCanvas := TMetafileCanvas.Create(EMF, 0);

    EMFCanvas.Brush.Color := clWhite;
    EMFCanvas.Brush.Style := bsSolid;
    EMFCanvas.FillRect(R);

		DrawbkPicture(EMFCanvas);
    CurReport.EMFPages.Draw(FPageNo, EMFCanvas, Rect(0, 0, FPageWidth, FPageHeight));
    EMFCanvas.Free;
    EMF.SaveToStream(Stream);
  finally
    EMF.Free;
  end;
  inherited OnEndPage;
end;

{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMWMFExport}

constructor TRMWMFExport.Create(AOwner: TComponent);
begin
  inherited;
  FFileExtension := 'wmf';
  RMRegisterExportFilter(Self, RMLoadStr(SWMFFile), '*.wmf');
end;

function TRMWMFExport.ShowModal: Word;
begin
  if not ShowDialog then
    Result := mrOk
  else
  begin
    with TRMEMFExportForm.Create(nil) do
    begin
      try
        edScaleX.Text := FloatToStr(Self.ScaleX);
        edScaleY.Text := FloatToStr(Self.ScaleY);
        Result := ShowModal;
        if Result = mrOK then
        begin
          Self.ScaleX := StrToFloat(edScaleX.Text);
          Self.ScaleY := StrToFloat(edScaleY.Text);
        end;
      finally
        Free;
      end;
    end;
  end;
end;

procedure TRMWMFExport.OnEndPage;
var
  EMF: TMetafile;
  EMFCanvas: TMetafileCanvas;
begin
  EMF := TMetafile.Create;
  try
    EMF.Enhanced := False;
    EMF.Transparent := False;
    EMF.Width := FPageWidth;
    EMF.Height := FPageHeight;
    EMFCanvas := TMetafileCanvas.Create(EMF, 0);
		DrawbkPicture(EMFCanvas);
    CurReport.EMFPages.Draw(FPageNo, EMFCanvas, Rect(0, 0, FPageWidth, FPageHeight));
    EMFCanvas.Free;
    EMF.SaveToStream(Stream);
  finally
    EMF.Free;
  end;
  inherited OnEndPage;
end;

{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMEMFExportForm}

procedure TRMEMFExportForm.Localize;
begin
  Font.Name := RMLoadStr(SRMDefaultFontName);
  Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
  Font.Charset := StrToInt(RMLoadStr(SCharset));

  RMSetStrProp(Self, 'Caption', rmRes + 1809);
  RMSetStrProp(Label1, 'Caption', rmRes + 1806);

  btnCancel.Caption := RMLoadStr(SOk);
  btnCancel.Caption := RMLoadStr(SCancel);
end;

procedure TRMEMFExportForm.FormCreate(Sender: TObject);
begin
  Localize;
end;

end.

⌨️ 快捷键说明

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