LoadWin.pas
上传用户:yuandong
上传日期:2022-08-08
资源大小:954k
文件大小:3k
源码类别:

Delphi控件源码

开发平台:

C++ Builder

  1. unit LoadWin;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   StdCtrls, Buttons, ExtCtrls, FileCtrl;
  6. type
  7.   TLoadForm = class(TForm)
  8.     DirectoryListBox1: TDirectoryListBox;
  9.     DriveComboBox1: TDriveComboBox;
  10.     FileEdit: TEdit;
  11.     FileListBox1: TFileListBox;
  12.     FilterComboBox1: TFilterComboBox;
  13.     Panel1: TPanel;
  14.     Image1: TImage;
  15.     m_butClose: TButton;
  16.     ViewBtn: TBitBtn;
  17.     LabelHeight: TLabel;
  18.     LabelWidth: TLabel;
  19.     LabelMMHeight: TLabel;
  20.     LabelMMWidth: TLabel;
  21.     Label1: TLabel;
  22.     Label2: TLabel;
  23.     Label3: TLabel;
  24.     Label4: TLabel;
  25.     procedure m_butCloseClick(Sender: TObject);
  26.     procedure FileListBox1Click(Sender: TObject);
  27.     procedure ViewBtnClick(Sender: TObject);
  28.     procedure FileEditKeyPress(Sender: TObject; var Key: Char);
  29.     procedure FormActivate(Sender: TObject);
  30.     procedure ViewFormInit;
  31.   private
  32.     { Private-Deklarationen }
  33.   public
  34.     strTempDir : string;
  35.     { Public-Deklarationen }
  36.   end;
  37. var
  38.   LoadForm: TLoadForm;
  39. implementation
  40. uses Viewwin, Imagewin;
  41. {$R *.DFM}
  42. procedure TLoadForm.m_butCloseClick(Sender: TObject);
  43. begin
  44.   Close;
  45. end;
  46. procedure TLoadForm.FileListBox1Click(Sender: TObject);
  47. var
  48.   FileExt: string[4];
  49.   strTmp1, strTmp2, strTmp3, strTmp4 : string;
  50. begin
  51.   FileExt := AnsiUpperCase(ExtractFileExt(FileListBox1.Filename));
  52.   if (FileExt = '.WMF') or (FileExt = '.EMF') then begin
  53.     Image1.Picture.LoadFromFile(FileListBox1.Filename);
  54.     Str(Image1.Picture.Metafile.Height, strTmp1);
  55.     Str(Image1.Picture.Metafile.Width, strTmp2);
  56.     Str(Image1.Picture.Metafile.MMHeight, strTmp3);
  57.     Str(Image1.Picture.Metafile.MMWidth, strTmp4);
  58.     LabelHeight.Caption := strTmp1;
  59.     LabelWidth.Caption := strTmp2;
  60.     LabelMMHeight.Caption := strTmp3;
  61.     LabelMMWidth.Caption := strTmp4;
  62.     LabelWidth.Repaint;
  63.     LabelHeight.Repaint;
  64.     LabelMMWidth.Repaint;
  65.     LabelMMHeight.Repaint;
  66.   end;
  67. end;
  68. procedure TLoadForm.ViewFormInit;
  69. begin
  70.   ViewForm.Image1.Picture.Metafile.Clear;
  71.   ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile;
  72.   ImageForm.nMetaWidth := Image1.Picture.Metafile.Width;
  73.   ImageForm.nMetaHeight := Image1.Picture.Metafile.Height;
  74.   ImageForm.m_labelFileName.Caption := Copy(ExtractFileName(FileListBox1.Filename), 1, Pos('.', ExtractFileName(FileListBox1.Filename))-1);
  75.   ImageForm.m_labelFileName.Refresh;
  76.   ViewForm.HorzScrollBar.Range := Image1.Picture.Width;
  77.   ViewForm.VertScrollBar.Range := Image1.Picture.Height;
  78.   ViewForm.ClientHeight := Image1.Picture.Height;
  79.   ViewForm.ClientWidth := Image1.Picture.Width;
  80.   ViewForm.Caption := Caption;
  81.   ViewForm.Show;
  82. end;
  83. procedure TLoadForm.ViewBtnClick(Sender: TObject);
  84. begin
  85.   ViewFormInit;
  86.   if (ImageForm.m_ComboBoxZoom.Text <> '100') then ImageForm.Zoom;
  87. end;
  88. procedure TLoadForm.FileEditKeyPress(Sender: TObject; var Key: Char);
  89. begin
  90.   if Key = #13 then begin
  91.     FileListBox1.ApplyFilePath(FileEdit.Text);
  92.     Key := #0;
  93.   end;
  94. end;
  95. procedure TLoadForm.FormActivate(Sender: TObject);
  96. begin
  97.   {$I-}
  98.   DriveComboBox1.Drive := (ExpandFileName(strTempDir))[1];
  99.   DirectoryListBox1.Directory := strTempDir;
  100.   if IOResult <> 0 then
  101.     MessageDlg('Temp-Verzeichnis nicht vorhanden', mtError, [mbOk], 0);
  102.   {$I+}
  103.   LabelHeight.Caption := '';
  104.   LabelWidth.Caption := '';
  105.   LabelMMHeight.Caption := '';
  106.   LabelMMWidth.Caption := '';
  107. end;
  108. end.