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

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.     Button1: TButton;
  26.     procedure m_butCloseClick(Sender: TObject);
  27.     procedure FileListBox1Click(Sender: TObject);
  28.     procedure ViewBtnClick(Sender: TObject);
  29.     procedure FileEditKeyPress(Sender: TObject; var Key: Char);
  30.     procedure FormActivate(Sender: TObject);
  31.     procedure ViewFormInit;
  32.     procedure Button1Click(Sender: TObject);
  33.   private
  34.     { Private-Deklarationen }
  35.   public
  36.     strSelectedDir : string;
  37.     strTempDir : string;
  38.     { Public-Deklarationen }
  39.   end;
  40. var
  41.   LoadForm: TLoadForm;
  42. implementation
  43. uses Viewwin, Imagewin;
  44. {$R *.DFM}
  45. procedure TLoadForm.m_butCloseClick(Sender: TObject);
  46. begin
  47.   Close;
  48. end;
  49. procedure TLoadForm.FileListBox1Click(Sender: TObject);
  50. var
  51.   FileExt: string[4];
  52.   strTmp1, strTmp2, strTmp3, strTmp4 : string;
  53. begin
  54.   FileExt := AnsiUpperCase(ExtractFileExt(FileListBox1.Filename));
  55.   if (FileExt = '.WMF') or (FileExt = '.EMF') then begin
  56.     Image1.Picture.LoadFromFile(FileListBox1.Filename);
  57.     Str(Image1.Picture.Metafile.Height, strTmp1);
  58.     Str(Image1.Picture.Metafile.Width, strTmp2);
  59.     Str(Image1.Picture.Metafile.MMHeight, strTmp3);
  60.     Str(Image1.Picture.Metafile.MMWidth, strTmp4);
  61.     LabelHeight.Caption := strTmp1;
  62.     LabelWidth.Caption := strTmp2;
  63.     LabelMMHeight.Caption := strTmp3;
  64.     LabelMMWidth.Caption := strTmp4;
  65.     LabelWidth.Repaint;
  66.     LabelHeight.Repaint;
  67.     LabelMMWidth.Repaint;
  68.     LabelMMHeight.Repaint;
  69.   end;
  70. end;
  71. procedure TLoadForm.ViewFormInit;
  72. begin
  73.   ViewForm.Image1.Picture.Metafile.Clear;
  74.   ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile;
  75.   ImageForm.nMetaWidth := Image1.Picture.Metafile.Width;
  76.   ImageForm.nMetaHeight := Image1.Picture.Metafile.Height;
  77.   ViewForm.HorzScrollBar.Range := Image1.Picture.Width;
  78.   ViewForm.VertScrollBar.Range := Image1.Picture.Height;
  79.   ViewForm.ClientHeight := Image1.Picture.Height;
  80.   ViewForm.ClientWidth := Image1.Picture.Width;
  81.   ViewForm.Caption := Caption;
  82.   ViewForm.Show;
  83. end;
  84. procedure TLoadForm.ViewBtnClick(Sender: TObject);
  85. begin
  86.   ViewFormInit;
  87.   if (ImageForm.m_ComboBoxZoom.Text <> '100') then ImageForm.Zoom;
  88. end;
  89. procedure TLoadForm.FileEditKeyPress(Sender: TObject; var Key: Char);
  90. begin
  91.   if Key = #13 then begin
  92.     FileListBox1.ApplyFilePath(FileEdit.Text);
  93.     Key := #0;
  94.   end;
  95. end;
  96. procedure TLoadForm.FormActivate(Sender: TObject);
  97. begin
  98.   {$I-}
  99.   DriveComboBox1.Drive := (ExpandFileName(strSelectedDir))[1];
  100.   DirectoryListBox1.Directory := strSelectedDir;
  101.   if IOResult <> 0 then
  102.     MessageDlg('Temp-Verzeichnis nicht vorhanden', mtError, [mbOk], 0);
  103.   {$I+}
  104.   LabelHeight.Caption := '';
  105.   LabelWidth.Caption := '';
  106.   LabelMMHeight.Caption := '';
  107.   LabelMMWidth.Caption := '';
  108. end;
  109. procedure TLoadForm.Button1Click(Sender: TObject);
  110. begin
  111.   strSelectedDir := DirectoryListBox1.Directory;
  112.   ImageForm.strSelectedDir := strSelectedDir;
  113.   ImageForm.m_DirectoryListBox.Directory := strSelectedDir;
  114.   ImageForm.m_DirectoryListBox.Update;
  115.   Close;
  116. end;
  117. end.