使用Directorycombox,DirectoryListBox1,FileListBox1,image控件procedure TImageForm.FileListBox1Click(Sender: TObject); var FileExt: string[4]; begin FileExt := AnsiUpperCase(ExtractFileExt(FileListBox1.Filename)); if (FileExt = '.BMP') or (FileExt = '.ICO') or (FileExt = '.WMF') or (FileExt = '.EMF') then begin Image1.Picture.LoadFromFile(FileListBox1.Filename); Caption := FormCaption + ExtractFilename(FileListBox1.Filename); if (FileExt = '.BMP') then begin Caption := Caption + Format(' (%d x %d)', [Image1.Picture.Width, Image1.Picture.Height]); ViewForm.Image1.Picture := Image1.Picture; ViewForm.Caption := Caption; end else if FileExt = '.ICO' then begin Icon := Image1.Picture.Icon; ViewForm.Image1.Picture.Icon := Icon; end; if (FileExt = '.WMF') or (FileExt = '.EMF') then ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile; end; end;
var
FileExt: string[4];
begin
FileExt := AnsiUpperCase(ExtractFileExt(FileListBox1.Filename));
if (FileExt = '.BMP') or (FileExt = '.ICO') or (FileExt = '.WMF') or
(FileExt = '.EMF') then
begin
Image1.Picture.LoadFromFile(FileListBox1.Filename);
Caption := FormCaption + ExtractFilename(FileListBox1.Filename);
if (FileExt = '.BMP') then
begin
Caption := Caption +
Format(' (%d x %d)', [Image1.Picture.Width, Image1.Picture.Height]);
ViewForm.Image1.Picture := Image1.Picture;
ViewForm.Caption := Caption;
end
else
if FileExt = '.ICO' then
begin
Icon := Image1.Picture.Icon;
ViewForm.Image1.Picture.Icon := Icon;
end;
if (FileExt = '.WMF') or (FileExt = '.EMF') then
ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile;
end;
end;