home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 February / DPPCPRO0299.ISO / February / Delphi / Install / DATA.Z / IMAGEWIN.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-11  |  3.8 KB  |  140 lines

  1. unit ImageWin;
  2.  
  3. interface
  4.  
  5. uses Windows, Classes, Graphics, Forms, Controls,
  6.   FileCtrl, StdCtrls, ExtCtrls, Buttons, Spin, ComCtrls;
  7.  
  8. type
  9.   TImageForm = class(TForm)
  10.     DirectoryListBox1: TDirectoryListBox;
  11.     DriveComboBox1: TDriveComboBox;
  12.     FileEdit: TEdit;
  13.     UpDownGroup: TGroupBox;
  14.     SpeedButton1: TSpeedButton;
  15.     BitBtn1: TBitBtn;
  16.     DisabledGrp: TGroupBox;
  17.     SpeedButton2: TSpeedButton;
  18.     BitBtn2: TBitBtn;
  19.     Panel1: TPanel;
  20.     Image1: TImage;
  21.     FileListBox1: TFileListBox;
  22.     Label2: TLabel;
  23.     ViewBtn: TBitBtn;
  24.     Bevel1: TBevel;
  25.     Bevel2: TBevel;
  26.     FilterComboBox1: TFilterComboBox;
  27.     GlyphCheck: TCheckBox;
  28.     StretchCheck: TCheckBox;
  29.     UpDownEdit: TEdit;
  30.     UpDown1: TUpDown;
  31.     procedure FileListBox1Click(Sender: TObject);
  32.     procedure ViewBtnClick(Sender: TObject);
  33.     procedure ViewAsGlyph(const FileExt: string);
  34.     procedure GlyphCheckClick(Sender: TObject);
  35.     procedure StretchCheckClick(Sender: TObject);
  36.     procedure FileEditKeyPress(Sender: TObject; var Key: Char);
  37.     procedure UpDownEditChange(Sender: TObject);
  38.     procedure FormCreate(Sender: TObject);
  39.   private
  40.     FormCaption: string;    
  41.   end;
  42.  
  43. var
  44.   ImageForm: TImageForm;
  45.  
  46. implementation
  47.  
  48. uses ViewWin, SysUtils;
  49.  
  50. {$R *.DFM}
  51.  
  52. procedure TImageForm.FileListBox1Click(Sender: TObject);
  53. var
  54.   FileExt: string[4];
  55. begin
  56.   FileExt := UpperCase(ExtractFileExt(FileListBox1.Filename));
  57.   if (FileExt = '.BMP') or (FileExt = '.ICO') or (FileExt = '.WMF') or
  58.     (FileExt = '.EMF') then
  59.   begin
  60.     Image1.Picture.LoadFromFile(FileListBox1.Filename);
  61.     Caption := FormCaption + ExtractFilename(FileListBox1.Filename);
  62.     if (FileExt = '.BMP') then
  63.     begin
  64.       Caption := Caption + 
  65.         Format(' (%d x %d)', [Image1.Picture.Width, Image1.Picture.Height]);
  66.       ViewForm.Image1.Picture := Image1.Picture;
  67.       ViewForm.Caption := Caption;
  68.       if GlyphCheck.Checked then ViewAsGlyph(FileExt);
  69.     end;
  70.     if FileExt = '.ICO' then Icon := Image1.Picture.Icon;
  71.     if (FileExt = '.WMF') or (FileExt = '.EMF') then 
  72.       ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile;
  73.   end;
  74. end;
  75.  
  76. procedure TImageForm.GlyphCheckClick(Sender: TObject);
  77. begin
  78.   ViewAsGlyph(UpperCase(ExtractFileExt(FileListBox1.Filename)));
  79. end;
  80.  
  81. procedure TImageForm.ViewAsGlyph(const FileExt: string);
  82. begin
  83.   if GlyphCheck.Checked and (FileExt = '.BMP') then 
  84.   begin
  85.     SpeedButton1.Glyph := Image1.Picture.Bitmap;
  86.     SpeedButton2.Glyph := Image1.Picture.Bitmap;
  87.     UpDown1.Position := SpeedButton1.NumGlyphs;
  88.     BitBtn1.Glyph := Image1.Picture.Bitmap;
  89.     BitBtn2.Glyph := Image1.Picture.Bitmap;
  90.     UpDown1.Enabled := True;
  91.     UpDownEdit.Enabled := True;
  92.     Label2.Enabled := True;
  93.   end
  94.   else begin
  95.     SpeedButton1.Glyph := nil;
  96.     SpeedButton2.Glyph := nil;
  97.     BitBtn1.Glyph := nil;
  98.     BitBtn2.Glyph := nil;
  99.     UpDown1.Enabled := False;
  100.     UpDownEdit.Enabled := False;
  101.     Label2.Enabled := False;
  102.   end;
  103. end;
  104.  
  105. procedure TImageForm.ViewBtnClick(Sender: TObject);
  106. begin
  107.   ViewForm.HorzScrollBar.Range := Image1.Picture.Width;
  108.   ViewForm.VertScrollBar.Range := Image1.Picture.Height;
  109.   ViewForm.Caption := Caption;
  110.   ViewForm.Show;
  111.   ViewForm.WindowState := wsNormal;
  112. end;
  113.  
  114. procedure TImageForm.UpDownEditChange(Sender: TObject);
  115. begin
  116.   SpeedButton1.NumGlyphs := UpDown1.Position;
  117.   SpeedButton2.NumGlyphs := UpDown1.Position;
  118. end;
  119.  
  120. procedure TImageForm.StretchCheckClick(Sender: TObject);
  121. begin
  122.   Image1.Stretch := StretchCheck.Checked;
  123. end;
  124.  
  125. procedure TImageForm.FileEditKeyPress(Sender: TObject; var Key: Char);
  126. begin
  127.   if Key = #13 then 
  128.   begin
  129.     FileListBox1.ApplyFilePath(FileEdit.Text);
  130.     Key := #0;
  131.   end;
  132. end;
  133.  
  134. procedure TImageForm.FormCreate(Sender: TObject);
  135. begin
  136.   FormCaption := Caption + ' - ';
  137. end;
  138.  
  139. end.
  140.