home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 August / VPR9708A.ISO / D3TRIAL / INSTALL / DATA.Z / IMAGEWIN.PAS < prev    next >
Pascal/Delphi Source File  |  1997-04-24  |  4KB  |  142 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 := AnsiUpperCase(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.     else
  71.       GlyphCheck.Checked := False;
  72.     if FileExt = '.ICO' then Icon := Image1.Picture.Icon;
  73.     if (FileExt = '.WMF') or (FileExt = '.EMF') then 
  74.       ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile;
  75.   end;
  76. end;
  77.  
  78. procedure TImageForm.GlyphCheckClick(Sender: TObject);
  79. begin
  80.   ViewAsGlyph(AnsiUpperCase(ExtractFileExt(FileListBox1.Filename)));
  81. end;
  82.  
  83. procedure TImageForm.ViewAsGlyph(const FileExt: string);
  84. begin
  85.   if GlyphCheck.Checked and (FileExt = '.BMP') then 
  86.   begin
  87.     SpeedButton1.Glyph := Image1.Picture.Bitmap;
  88.     SpeedButton2.Glyph := Image1.Picture.Bitmap;
  89.     UpDown1.Position := SpeedButton1.NumGlyphs;
  90.     BitBtn1.Glyph := Image1.Picture.Bitmap;
  91.     BitBtn2.Glyph := Image1.Picture.Bitmap;
  92.     UpDown1.Enabled := True;
  93.     UpDownEdit.Enabled := True;
  94.     Label2.Enabled := True;
  95.   end
  96.   else begin
  97.     SpeedButton1.Glyph := nil;
  98.     SpeedButton2.Glyph := nil;
  99.     BitBtn1.Glyph := nil;
  100.     BitBtn2.Glyph := nil;
  101.     UpDown1.Enabled := False;
  102.     UpDownEdit.Enabled := False;
  103.     Label2.Enabled := False;
  104.   end;
  105. end;
  106.  
  107. procedure TImageForm.ViewBtnClick(Sender: TObject);
  108. begin
  109.   ViewForm.HorzScrollBar.Range := Image1.Picture.Width;
  110.   ViewForm.VertScrollBar.Range := Image1.Picture.Height;
  111.   ViewForm.Caption := Caption;
  112.   ViewForm.Show;
  113.   ViewForm.WindowState := wsNormal;
  114. end;
  115.  
  116. procedure TImageForm.UpDownEditChange(Sender: TObject);
  117. begin
  118.   SpeedButton1.NumGlyphs := UpDown1.Position;
  119.   SpeedButton2.NumGlyphs := UpDown1.Position;
  120. end;
  121.  
  122. procedure TImageForm.StretchCheckClick(Sender: TObject);
  123. begin
  124.   Image1.Stretch := StretchCheck.Checked;
  125. end;
  126.  
  127. procedure TImageForm.FileEditKeyPress(Sender: TObject; var Key: Char);
  128. begin
  129.   if Key = #13 then 
  130.   begin
  131.     FileListBox1.ApplyFilePath(FileEdit.Text);
  132.     Key := #0;
  133.   end;
  134. end;
  135.  
  136. procedure TImageForm.FormCreate(Sender: TObject);
  137. begin
  138.   FormCaption := Caption + ' - ';
  139. end;
  140.  
  141. end.
  142.