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

📄 rm_e_wmf.pas

📁 report machine 2.3 功能强大
💻 PAS
字号:
unit RM_E_WMF;

interface

{$I RM.INC}

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

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

  { TRMEMFExportForm }
  TRMWMFExportForm = 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}

{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ 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
    with TRMWMFExportForm.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;

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);
		CurReport.EMFPages.Draw(FPageNo, EMFCanvas,
			Rect(0, 0, FPageWidth, FPageHeight));
		EMFCanvas.Free;
		EMF.SaveToStream(Stream);
	finally
		EMF.Free;
	end;
	inherited OnEndPage;
end;

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

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

  Caption := RMLoadStr(rmRes + 1809);
  Label1.Caption := RMLoadStr(rmRes + 1806);
  btnCancel.Caption := RMLoadStr(SOk);
  btnCancel.Caption := RMLoadStr(SCancel);
end;

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

end.

⌨️ 快捷键说明

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