unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons, ExtDlgs;
type
TForm1 =
class
(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Image1: TImage;
OpenPictureDialog1: TOpenPictureDialog;
SavePictureDialog1: TSavePictureDialog;
procedure
FormCreate(Sender: TObject);
procedure
SpeedButton1Click(Sender: TObject);
procedure
SpeedButton3Click(Sender: TObject);
procedure
SpeedButton2Click(Sender: TObject);
private
public
end
;
var
aPath:
string
;
aSearchRec : TSearchRec;
Pictures : TStringList;
n:
integer
;
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1
.
FormCreate(Sender: TObject);
begin
Pictures := TStringList
.
Create;
SpeedButton2
.
Enabled :=
False
;
SpeedButton3
.
Enabled :=
False
;
with
OpenPictureDialog1
do
begin
Options := Options + [ofPathMustExist, ofFileMustExist];
InitialDir := ExtractFilePath(Application
.
ExeName);
end
;
with
SavePictureDialog1
do
begin
InitialDir := ExtractFilePath(Application
.
ExeName);
end
;
end
;
procedure
TForm1
.
SpeedButton1Click(Sender: TObject);
begin
if
OpenPictureDialog1
.
Execute
then
begin
Form1
.
Caption := OpenPictureDialog1
.
FileName;
Image1
.
Picture
.
LoadFromFile(OpenPictureDialog1
.
FileName);
end
;
if
Pictures
.
Count >
1
then
SpeedButton3
.
Enabled :=
True
;
n :=
0
;
try
Form1
.
Image1
.
Picture
.
LoadFromFile(aPath + Pictures[n]);
except
on
EInvalidGraphic
do
Form1
.
Image1
.
Picture
.
Graphic :=
nil
;
end
;
if
Pictures
.
Count =
1
then
SpeedButton3
.
Enabled :=
False
;
end
;
procedure
TForm1
.
SpeedButton3Click(Sender: TObject);
begin
n := n+
1
;
try
Form1
.
Image1
.
Picture
.
LoadFromFile(aPath + Pictures[n]);
except
on
EInvalidGraphic
do
Form1
.
Image1
.
Picture
.
Graphic :=
nil
;
end
;
if
n = Pictures
.
Count-
1
then
SpeedButton2
.
Enabled :=
False
;
if
(n >
0
)
and
SpeedButton3
.
Enabled =
False
then
SpeedButton3
.
Enabled :=
True
;
end
;
procedure
TForm1
.
SpeedButton2Click(Sender: TObject);
begin
n := n-
1
;
try
Form1
.
Image1
.
Picture
.
LoadFromFile(aPath + Pictures[n]);
except
on
EInvalidGraphic
do
Form1
.
Image1
.
Picture
.
Graphic :=
nil
;
end
;
if
n =
0
then
SpeedButton3
.
Enabled :=
False
;
if
(n < Pictures
.
Count)
and
SpeedButton2
.
Enabled =
False
then
SpeedButton2
.
Enabled :=
True
;
end
;
end
.