Вы находитесь на странице: 1из 129

DELPHI

2008

.........................................3
........................................................21
y................................................45
............................................................46
....................46
................................................46
..................................46


y , :

Delphi y : y
y ( ), y
. ( ,
Windows) y y y .

,
() y .
. :
o
Label ;
o
Edit / ;
o
Button y y;
o
CheckBox y y ;
o
RadioButton y y ;
o
ListBox ;
o
ComboBox .

,
() (
, ).

y y y (
, ).

y y /
( Edit), ( ListBox)
( ComboBox).
CheckBox RadioButton.

y ( Label)
(y MessageDlg).

, /,
y y strToint, y strToFioat.
, , y y
y IntToStr, y FloatToStr FloatToStrF.
1.

y,

" yy"
" ". y
. 1.1.
//
Procedure TForm1.Button1Click(Sender:TObject);
Var
ms: integer; // /
kmh: real; // /
begin
//
ms := StrToInt(Edit1.Text);
kmh := ms * 3.6; //
. 1.1.
// y
Label3.Caption := IntToStr(ms) + ' / ' +FloatToStr(kmh) + ' /'
end;

2. y, " yy"
" ". y . 1.1.
,
.
//
procedure TForm1.Button1Click(Sender: TObject);
var
ms: integer; // /
kmh: real; // /
begin
// Edit1 y, y StrToInt .

4
// , Edit1
If Length(Edit1.Text) = 0
Then begin
ShowMessage(' ');
exit; // y
end;
ms := StrToInt(Edit1.Text); //
kmh := ms * 3.6; //
// y
Label3.Caption :=IntToStr(ms) + ' / - ' + FloatToStr(kmh) + ' / '
end;
// Edit1
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
{ (Edit1) . y ,
y. , y. y
. Key , y
}
If Not ((Key >= '0') And (Key <='9') or (Key = #8)) then Key := Chr(0);
end;
3. y, " yy"
" ". y . 1.1.
,
.
y , <Enter>
.
// / /
procedure WindSpeed;
var
ms: integer; // /
kmh: real;
// /
begin
// Edit1 y, y StrToInt .
// , Edit1
If Length(Form1.Edit1.Text) = 0
then
begin
ShowMessage(' ');
exit; // y
end;
ms := StrToInt(Form1.Edit1.Text); //
kmh := ms * 3.6; //
// y
Form1.Label3.Caption :=IntToStr(ms) + ' / - ' +FloatToStr(kmh) + ' /'
end;
//
procedure TForm1.Button1Click(Sender: TObject);
begin
WindSpeed;//
end;
// Edit1
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
// Key #8 <Backspace> #13 <Enter>
case Key of
'0'..'9',#8:; // <Backspace>
#13 : WindSpeed; //
else Key := Chr(0); //
end;
end;

5
4. y, y y (1 y =
409,5 ). y . 1.2.
, y
y,

.
.

1.2.

y-

//
procedure
TForm1.Button1Click(Sender:TObject);
var
funt: real; // y
kg: real; //
begin
{ y y, Edit1 . y
.}
funt := StrToFloat(Edit1.Text);
kg := funt * 0.4095;
Label2.Caption:= FloatToStrF(funt,ffGeneral,5,2) +' '
+ FloatToStrF(kg, ffGeneral, 5,2) + ' ';
end;
// Edit1
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
case Key of
'0'..'9', #8:; // <Backspace>
{ y "y".
y y DecimalSeparator-, y
}
'.',',' : Begin
Key := DecimalSeparator;
// , y Edit
If pos(DecimalSeparator,Edit1.Text) <> 0 then Key := Char(0);
end;
else Key := Char(0); //
end;
end;
// Edit1
procedure TForm1.Edit1Change(Sender: TObject);
begin
// , Edit1
If Length(Edit1.Text) = 0
then Button1.Enabled:=False // y
else Button1.Enabled:=True; // y
end;
// onCreate , ,
//
procedure TForm1.FormCreate(Sender: TObject);
begin
{ . . Edit1 y ( ),
y y )}
Button1.Enabled := False;
end;
5. y, y y (1 y =
409,5 ). y . 1.2.
,
( ).
//
procedure TForm1.Button1Click(Sender: TObject);
var funt: real; // y
kg : real; //
begin

6
If Length(Edit1.Text) = 0 // Edit1
then begin
ShowMessage(' y. ');
exit;
end;
funt := StrToFloat(Edit1.Text); kg := funt * 0.4095;
Label2.Caption := FloatToStrF(funt,ffGeneral,5,2)+' - '
+ FloatToStrF(kg, ffGeneral, 5, 2) + ' ';
end;
// Edit
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
case Key of
'0'..'9', #8 :; // <Backspace>
{y "y".
y y DedmalSeparator , y
. Windows.}
',','.':
Begin
Key := DecimalSeparator;
// , y Edit
If pos(DecimalSeparator,Edit1.Text) <>0 then Key := Char (0)
end;
else Key := Char(0); //
end;
end;
6. y,
(/),

y
-
. y
. 1.3. y
, y .
{Key , y .
y, y
0. y
y
, y
.}
//
. 1.3.
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);

Begin
case Key of
'0'..'9' : ; //
#8
: ; // <Backspace>
#13
: Edit2.SetFocus;
// <Enter> y
// :y
else Key :=Chr(0); //
end;
end;
// :y
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
case Key of
'0'..'9' : ;
#8 : ; // <Backspace>
#13 : Edit3.SetFocus; // <Enter> y
// :y
else Key :=Chr(0); //
end;
end;

7
// :y
procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
case Key of
'0'..'9' : ;
',','.' : //
Begin
Key := DecimalSeparator;
If Pos(DecimalSeparator,Edit3.Text) <>0 then Key := Char(0);
end;
#8 : ; // <Backspace>
#13 : Button1.SetFocus; // <Enter> y
else Key :=Chr(0); //
end;
end;
//
procedure TForm1.Button1Click(Sender: TObject);
var
dist : integer; // ,
min : integer; // , y
sek : real;
// , y
v
: real;
//
begin
// y
dist := StrToInt(Edit1.Text);
min := StrToInt(Edit2.Text);
sek := StrToFloat(Edit3.Text);
// y
If (dist = 0) or ((min = 0) And (sek = 0))
Then Begin ShowMessage(' . '); exit; end;
v := (dist/1000) / ((min*60 + sek)/3600); //
Label5.Caption := ': '+ Edit1.Text + ' ' + #13 // y
+': ' + IntToStr(min) + ' ' +FloatToStrF(sek, ffGeneral,4,2) + ' '
+ #13 + ': ' +FloatToStrF(v,ffFixed,4,2) + ' /';
end;
7.

y,

.
y

.
1.4.

, y
y, y .

8. y, y . y . y
. 1.5.

. 1.4.

. 1.5.

8
9. y, y y . 1
% , y y 300 y, 2 % y
500 y, 3 % y 1 000.
( ) . y
. 1.6.
10.

.
11.

y, y.
.
. y . 1.7. (.
.)

1.6. y

. 1.7.
y

y, y.
.
, y
y y yy. y
. 1.8.

//
procedure TForm1.Button1Click(Sender:
TObject);
var
sum : real; // y
pr
: real; //
srok : integer; //
dohod: real;
// y
buf : real;
I
: integer;
begin
// y
. 1.8. y
sum := StrToFloat(Edit1.Text);
pr
:= StrToFloat(Edit2.Text);
srok := StrToInt(Edit3.Text);
If RadioButton1.Checked //
then dohod := sum * (pr/100) * (srok/365)
else // . . y , RadioButton1,
// RadioButton2
Begin
buf:= sum;
for i:=1 to srok Do buf:= buf + buf * (pr/100);
// buf y
dohod := buf sum;
end;
sum := sum + Dohod;
Label4.Caption := ': ' + FloatToStrF(dohod,ffGeneral,9,2) + #13 +

9
' y c : ' +FloatToStrF(sum, ffGeneral,9,2),
end;
//
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
Label2.Caption := ' ()';
Label4.Caption := '';
end;
//
procedure TForm1.RadioButton2Click(Sender: TObject),
begin
Label2.Caption := ' (.)';
Label4.Caption := '';
end;
12.

y,

,
y -. y
. y
. 1.9.
1 000 , y
.
//
procedure TForm1.Button1Click
(Sender: TObject);
var r1,r2: real; //
r: real; //
begin
. 1.9.
// y

R1 := StrToFloat(Edit1.Text);
r2 := StrToFloat(Edit2.Text);
If (r1 = 0) And (r2 = 0)
then begin
ShowMessage(' y ');
exit;
end;
{ RadioButton1 RadioButton2 , y
y }
If RadioButton1.Checked
then r:= r1+r2
//
else r:= (r1*r2)/(r1+r2); //
Label4.Caption := ' ' + FloatToStrF(r,ffGeneral,9,2)
end;

10
13.

y, y .
y . y
. y . 1.10.

14. y, , y
.
1.11. ,
, ,
.

. 1.10.

, y ,
y .
y ,
,

. 1.11.

// ,
procedure Calculate;
var I,U,R: real; // , ,
Begin
If Form1.RadioButton1.Checked //
then begin
U := StrToFloat(Form1.Edit1.Text) ;
R := StrToFloat(Form1.Edit2.Text);
If (R <> 0)
Then begin
I := U/R;
Form1.Label3.Caption := ': ' +
FloatToStrF(I,ffFixed,4,2) + ' a';
End
else ShowMessage(' y.');
exit;
end;
If Form1.RadioButton2.Checked //
then Begin
I := StrToFloat(Form1.Edit1.Text);
R := StrToFloat(Form1.Edit2.Text);
U := I*R;
Form1.Label3.Caption := ': ' +FloatToStrF(U,ffFixed,4,2);
exit;
end;
If Form1.RadioButton3.Checked //
then begin
U:= StrToFloat(Form1.Edit1.Text);
I:= StrToFloat(Form1.Edit2.Text);
If (I <> 0)
then begin
R := U/I;
Form1.Label3.Caption:=': ' +
FloatToStrF(R,ffFixed,4,2)+ ' ';
End
else ShowMessage(' y.');
end;
end;
//
procedure TForm1.RadioButton1Click(Sender: TObject);
begin

11
Label1.Caption := ' ()';
Label2.Caption := ' ()';
Labe13.Caption := '';
end;
//
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
Label1.Caption := ' ()';
Label2.Caption := ' ()';
Label3.Caption := '' ;
end;
//
procedure TForm1.RadioButton3Click(Sender: TObject);
begin
Label1.Caption := ' () ';
Label2.Caption := ' ()';
Label3.Caption := '';
end;
// Edit1
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key:Char);
begin
case Key of
'0'..'9',#8: ; // <Backspase>
#13
:Edit2.SetFocus; // <Enter>
'.',','
:
Begin
//
If Key ='.' then Key :=#42;
If s(',',Edit1.Text) <> 0 then Key := Chr(0);
end
else Key := Chr(0);
end;
end;
// Edit2
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key:Char);
begin
case Key of
'0'..'9',#8 : ;
#13 : Calculate; // <Enter>
'.',','
: Begin
If Key = '.' then Key := ',' ;
//
If Pos(',',Edit2.Text) <> 0 then Key := Chr(0);
end
else Key := Chr(0);
end;
end;
//
procedure TForm1.Button1Click(Sender: TObject);
begin
If (Edit1.Text <> '') and (Edit2.Text <>'')
then Calculate // ,
else ShowMessage('
');
end;
15.

y,

,
,

y.
y . 1.12.
y EditKeyPress

12
, . yy
OnKeyPress Edit1, y yy
OnKeyPres Edit2 Edit3. , y Tag Edit1, Edit2
Edit3 1, 2 3. Tag y
y EditKeyPress . }
Implementation
. 1.12.
{$R *.dfm}
y
procedure TForm1.EditKeyPress(Sender: TObject; var Key: Char);
var Edit: TEdit;
begin
Edit := Sender as TEdit;
// Edit
case Key of
'0'..'9' : ; //
#8
: ; // <Backspace>
'.',',' : begin
Key := DecimalSeparator;
If Pos(DecimalSeparator,Edit.Text) <> 0 then Key := #0;
end;
#13 : case Edit.Tag of // <Enter>
1 : Edit2.SetFocus;
2 : Edit3.SetFocus;
3 : Button1.SetFocus;
end;
else Key := Chr(0)
end;
end;
//
procedure TForm1.Button1Click(Sender: TObject);
var
rast : real; //
cena : real; //
potr : real; // 100
summ : real; // y
mes : string;
begin
// EConvertError y,
//
Try
rast := StrToFloat(Edit1.Text);
cena := StrToFloat(Edit2.Text);
potr := StrToFloat(Edit3.Text);
except
on EConvertError Do
begin ShowMessage(' ! ');
// y
If Length(Edit1.Text) = 0
then Edit1.SetFocus
else If Length(Edit2.Text) = 0
then Edit2.SetFocus
else Edit3.SetFocus;
exit
end;
end;
summ := (rast / 100) * potr * cena;
mes := ' y';
If CheckBox1.Checked
Then begin
summ := summ * 2;
mes := mes + ' ';
end;
mes := mes+' ' +#13+ FloatToStrF (summ, ffGeneral, 4, 2)+' y.';
Label4.Caption := mes;

13
end;
End.
16. y-y, . y . 1.13.
- .
y
onclick.
onclick y,
.
{
1.

Onclick

y.}
Implementation
. 1.13. {$R *.dfm}
y
var
accum: real; // yy
oper: integer;
// : 1 '+'; 2 '-'; 0 "" ( "=")
f: integer; { f = 0 y y , ,
, y. f = 1 . }
// 0
procedure TForm1.Button0Click(Sender: TObject);
begin
If f = 0 //
then begin Edit1.Text := '0'; f := 1; end //
else
If Edit1.Text <>'0'{ y }
then Edit1.Text := Edit1.Text + '0,';
end;
// 1
procedure TForm1.Button1Click(Sender: TObject);
begin
If f = 0 //
then begin Edit1.Text := '1'; f := 1; End //
else Edit1.Text := Edit1.Text + '1';
end;
// 2
procedure TForm1 .Button2Click(Sender: TObject);
begin
If (f = 0) //
then begin Edit1.Text := '2'; f := 1; End //
else Edit1.Text := Edit1.Text + '2';
end;
// 3
procedure TForm1.Button3Click(Sender: TObject);
begin
If f = 0
then begin Edit1.Text := '3'; f := 1; end
else Edit1.Text := Edit1.Text + '3';
end;
// 4
procedure TForm1.Button4Click(Sender: TObject);
begin
If f = 0
then begin Edit1.Text := '4'; f := 1; end
else Edit1.Text := Edit1.Text + '4';
end;
// 5
procedure TForm1.ButtonSClick(Sender: TObject);
begin
If (f = 0)
then begin Edit1.Text := '5'; f := 1; end

14
else Edit1.Text := Edit1.Text + '5';
end;
// 6
procedure TForm1.Button6Click(Sender: TObject);
begin
If f = 0
then begin Edit1.Text := '6'; f := 1; end
else Edit1.Text := Edit1.Text + '6';
end;
// 7
procedure TForm1.Button7Click(Sender: TObject);
begin
If f = 0
then begin Edit1.Text := '7' ; f := 1; end
else Edit1.Text := Edit1.Text + '7';
end;
// 8
procedure TForm1.Button8Click(Sender: TObject);
begin
If f = 0
then begin Edit1.Text := '8'; f := 1; end
else Edit1.Text := Edit1.Text + '8';
end;
// 9
procedure TForm1.Button9Click(Sender: TObject);
begin
If f = 0
then begin Edit1.Text := '9' ; f := 1; end
else Edit1.Text := Edit1.Text + '9';
end;
//
procedure TForm1.ButtonClick(Sender: TObject);
begin
Edit1.Text := '0'; accura := 0; oper := 0;
f := 0; // y y
end;
// Edit1
procedure TForm1.Edit1Change(Sender: TObject; var Key: Char);
begin
Key := Chr(0); //
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
oper := 0; Edit1.SetFocus;
end;
End.
{ 2. Onclick y}
{ 1. y Tag
, , y.
2. y y OnClick
, "1", ,
OnClick y.
y , y
y Events.}
Implementation
{$R *.dfm}
var
accum: real; // yy
oper: integer;// : 1 '+'; 2 '-'; "" ( "=")

15
f: integer;
{ f = 0 y y , , ,
y. f = 1 . }
// "0" "9"
procedure TForm1.DigitBtnClick(Sender: TObject);
var
Btn: TButton;
ch: Char;
begin
Btn := Sender as TButton;
ch := Chr(48+Btn.Tag); // chr(48) = '0'; chr(49) = 4' . .
// :
ch := Btn.Caption;
case Btn.Tag of
1..9: // "1" - "9"
If f = 0 //
then begin Edit1.Text := ch; f := 1; end //
else Edit1.Text := Edit1.Text + ch;
0: // "0"
If Edit1.Text = '0' // 0
// y
then Edit1.Text := Edit1.Text + '0,';
end;
end;
//
procedure TForm1.Button2Click(Sender: TObject);
begin
If Edit1.Text = '0' Then begin Edit1.Text := '0,'; f := 1; end;
If Pos (',',Edit1.Text) = 0 then Edit1.Text := Edit1.Text + ',';
end;
//
procedure DoOper;
var numb: real; //
begin
{ accum y y , r , y
. .}
numb := StrToFloat(Form1.Edit1.Text);
case oper of
0: accum := numb;
1: accum := accum + numb;
2: accum := accum numb;
end;
Form1.Edit1.Text := FloatToStr(accum);
end;
// "+", "-" "="
procedure TForm1.OpBtnClick(Sender: TObject);
{ yy , y ,
yy y . }
Var Btn: TButton;
Begin
Btn := Sender as TButton;
If f = 0 // y y, y
Then
// Tag
oper := Btn.Tag
//
else
begin
DoOper;
// yy
oper := Btn.Tag; // yy
f1
:= 0;
// y y
end;
end;
// ""

16
procedure TForm1.ButtonCClick(Sender: TObject);
begin
Edit1.Text := '0';
accum := 0;
oper := 0;
f := 0; // y y
end;
// Edit1
procedure TForm1.Edit1Change(Sender: TObject; var Key:Char);
begin
Key := Chr(0); //
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
oper := 0;
end;
End.
17.

y " ",
,

y (. 1.14).

Unit eclock_;
interface
Uses
. 1.14.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
Tipe
TForm1 = class(TForm)
Timer1 : TTimer;
Label1: TLabel;
procedure FormPaint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
// y ShowTime yy ,
// y y y
procedure ShowTime;
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
($R *.dfm}
// y
procedure TForm1.ShowTime;
var Time: TDateTime; // y
Begin
Time := Now(); // y
Label1.Caption := FormatDateTime('hh:mm:ss',Time);
end;
// Paint
procedure TForm1.FormPaint(Sender: TObject);
begin
ShowTime; //
end;
/
procedure TForm1.Timer1Timer(Sender: TObject);
Begin
ShowTime; //
end;

17
procedure TForm1.FormCreate(Sender: TObject);
begin // y
imer1.Interval := 1000; // 1
Timer1.Enabled := True; // y
end;
End.
18. y " ",
y
(. 1.15).
Unit eclock_2_;
interface
Uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics,Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
. 1.15.
Tipe
y
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Shape1: TShape;
procedure FormPaint(Sender: TObject);
procedure TimerITimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
// y ShowTime yy.
// , y y y
procedure ShowTime;
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
// y
procedure TForm1.ShowTime;
Var Time: TDateTime; // y
begin
Time := Now(); // y
Label1.Caption := FormatDateTime('hh:mm:ss',Time);
end;
// Paint
procedure TForm1.FormPaint(Sender: TObject);
begin
ShowTime; //
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
ShowTime; //
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label2.Caption := FormatDateTime('dd.mm.yyyy',Now());
// y
Timer1.Interval := 1000; // 1
Timer1.Enabled := True; // y
end;
End.

18
19. y " ",
y ,
(. 1.16).
Unit eclock_3_;
interface
Uses Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
Tipe
TForm1 = class(TForm)
. 1.16.
Timer1: TTimer;
y ,
Label1: TLabel; //
Label2: TLabel; //
procedure FormPaint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
// y ShowTime yy.
// , y y y
procedure ShowTime;
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm)
Const stDay : array[1..7] of string[11] = ('', '', '',
'', '', '', 'y');
stMonth : array[1..12] of string[8] = ('', '', '', '',
'', '', '', 'y', '', '', '', '');
// y
procedure TForm1.ShowTime;
var Time: TDateTime; // y
begin
Time := Now(); // y
Label1.Caption := FormatDateTime('hh:mm:ss',Time);
end;
// Paint
procedure TForm1.FormPaint(Sender: TObject);
begin
ShowTime; //
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
ShowTime; //
end;
// OnCreate
procedure TForm1.FormCreate(Sender: TObject);
var
Present
: TDateTime; // y
Year, Month, Day : Word; // , ,
begin
Present := Now; // y yy y
DecodeDate(Present, Year, Month, Day);
Label2.Caption := ' '+IntToStr(Day)+ ' ' + stMonth[Month] + ' '+
IntToStr(Year)+ ' , '+ stDay[DayOfWeek(Present)];
// y
Timer1.Interval := 1000; // 1
Timer1.Enabled := True; // y
end;

19
End.
20.

y "".
. 1.17

implementation
($R *.dfm}
. 1.17.
{ y Visible Label3
False}
var
min: integer; // y
sec: integer; // y
// ,
procedure ShowTime;
var buf: string[20];
begin
// y y y
If min < 10 then buf := '0' + IntToStr(min) + ':'
else buf := IntToStr(min) + ':';
If sec < 10 then buf := buf + '0' + IntToStr(sec)
else buf := buf + IntToStr(sec);
Form1.Label3.Caption := buf;
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
sec := sec 1;
ShowTime; // ,
If (min = 0) And (sec = 0) //
then Begin
Timer1.Enabled := False; //
ShowMessage(' !');
Button1.Caption := 'y';
Label3.Visible := False; //
//
Label1.Visible := True;
Edit1.Visible := True;
Label2.Visible := True;
Edit2.Visible := True;
exit;
end;
If (sec = 0) And (min > 0)
Then begin
sec : = 60;
min := min 1;
end;
end;
// y/
procedure TForm1.Button1Click(Sender: TObject);
begin
If Form1.Timer1.Enabled // ,
then Begin
Timer1.Enabled := False; //
Button1.Caption := 'y';
Label3.Visible := False; //
//
Label1.Visible := True;
Edit1.Visible := True;
Label2.Visible := True;
Edit2.Visible := True;

20

end;
21.

end
else Begin// , y
min := StrToInt(Edit1.Text);
sec := StrToInt(Edit2.Text);
If (sec = 0) And (min = 0)
Then begin ShowMessage(' !'); exit; end;
Timer1.Enabled:= True; // y
//
Label1.Visible:= False;
Edit1.Visible:= False;
Label2.Visible:= False;
Edit2.Visible:= False;
Label3.Visible:= True;
Button1.Caption := '';
ShowTime;
end;
Yy y "" , y
y , ,
y Windows.

implementation
{$R *.dfm)
Const SOUND = 'tada.wav';
Var
MediaPlayer : TMediaPlayer; // y
//
min: integer; // y
sec: integer; // y
// ,
procedure ShowTime;
var buf: string[20];
begin
// y y y
If min < 10 then buf := '0' + IntToStr(min) + ':'
else buf := IntToStr(min) + ':';
If sec < 10 then buf := buf + '0' + intToStr(sec)
else buf := buf + IntToStr(sec);
Form1.Label3.Caption := buf;
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
sec := sec 1;
ShowTime; // ,
If (min = 0) And (sec = 0) //
then Begin
Timer1.Enabled := False; //
// *** y ****
. . , WAV- y
// (. FormCreate), y
Try
MediaPlayer.Play; // y
Except on EMCIDeviceError Do;
end;
ShowMessage(' !');
Button1.Caption := 'y';
Label3.Visible := False; //
//
Label1.Visible := True; Edit1.Visible := True;
Label2.Visible := True; Edit2.Visible := True;
exit;
end;

21
If (sec = 0) And (min > 0)
Then begin
sec := 60;
min := min 1;
end;
end;
// y/
procedure TForm1.Button1Click(Sender: TObject);
begin
If Form1.Timer1.Enabled // ,
then Begin
Timer1.Enabled:= False; //
Button1.Caption :='y';
Label3.Visible:= False; //
//
Label1.Visible:= True; Edit1.Visible:= True;
Label2.Visible:= True; Edit2.Visible:=True;
end
Else Begin // , y
min := StrToInt(Edit1.Text);
sec := StrToInt(Edit2.Text);
If (sec = 0) And (min = 0)
Then begin
ShowMessage(' !');
exit;
end;
Timer1.Enabled := True; // y
//
Label1.Visible:= False; Edit1.Visible :=False;
Label2.Visible:= False; Edit2.Visible:= False;
Label3.Visible:= True; Button1.Caption := '';
ShowTime;
end;
end;
// MediaPlayer y WAV-
procedure TForm1.FormCreate(Sender: TObject);
var
pWinDir: PChar; // y nul-terminated-y
sWinDir: String[80];
begin
// MediaPlayer
MediaPlayer : = TMediaPlayer.Create(self);
MediaPlayer.ParentWindow := Form1.Handle;
MediaPlayer.Visible := False;
{ WAV- Media,
, y Windows? . y
Windows, y API-y GetWindowsDirectory. ,
API-y, nul-terminated-. y Windows }
GetMem(pWinDir,80); //
GetWindowsDirectory(pWinDir,80); // y Windows
sWinDir := pWindir;
// WAV-
MediaPlayer.FileName := sWinDir + '\media\' + SOUND;
Try
MediaPlayer.Open;
Except
on EMCIDeviceError Do;
end;
end;
End.

22
22.

y
"".

y upDown. y
. 1.18.

{ UpDown Edit,
y Associate UpDown
y Edit.
. }
Var
min: integer; // y
sec: integer; // y
// ,
procedure ShowTime;
var buf: string[20];
begin
buf := ' ';
// y y y
If min < 10 then buf := buf + '0' + IntToStr(min) + ' : '
else buf := buf + IntToStr(min) + ' : ';
If sec < 10 then buf := buf + '0' + IntToStr(sec)
else buf := buf + IntToStr(sec);
Form1.Caption := buf;
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
sec := sec - 1;
If (min = 0) And {sec = 0) //
then Begin
Timer1.Enabled := False; //
UpDoun1.Enabled := True; UpDown2.Enabled := True;
Edit1.Enabled := True;
Edit2.Enabled := True;
Button1.Caption := 'y';
ShowMessage(' !');
exit;
end;
If (sec = 0) And (min > 0)
Then begin sec := 60; min := min 1; end;
ShowTime; // ,
end;
// y/
procedure TForm1.Button1Click(Sender: TObject);
begin
If Form1.Timer1.Enabled // ,
then Begin
Timer1.Enabled := False; //
Form1.Caption := '';
Button1.Caption := 'y';
//
UpDoun1.Enabled:= True; UpDown2.Enabled:= True;
Edit1.Enabled := True; Edit2.Enabled := True;
End
Else Begin // , y
min := UpDoun1.Position;
sec := UpDown2.Position;
If (sec = 0) And (min = 0)
Then begin
ShowMessage(' !');
exit;
end;
Edit1.Enabled := False; Edit2.Enabled := False;
UpDoun1.Enabled:= False; UpDown2.Enabled:= False;
Button1.Caption := '';

. 1.18.

23

end;
End.

Timer1.Enabled := True; // y
ShowTime;
end;

24

y , :

y (
image), y Canvas.

(,
y, y . .) , y
Canvas y .

, y , Line, Ellipse, Rectangle


. ., Canvas.

y y,
Line, Ellipse, Rectangle . ., Brush canvas.

, Textout,
Font canvas.

y y y y
onPaint.
23.

y,
y (. 1.19).
// y
procedure TForm1.FormPaint(Sender: TObject);
begin
With Canvas Do
begin
//
Canvas.Pen.Width := 1;
Canvas.Pen.Color := clBlack;
Canvas.Brush.Color := clCream;
Rectangle(30,30,150,115);
//
Pen.Width := 2;
Brush.Style := bsClear;
// y y
Pen.Color := clBlue;
Ellipse(40,40,80,80);
Pen.Color := clBlack;
Ellipse(70,40,110,80);
Pen.Color := clRed;
Ellipse(100,40,140,80);
Pen.Color := clYellow; Ellipse(55,65,95,105);
Pen.Color := clGreen;
Ellipse(85,65,125,105);
end;
end;

. 1.19.

24. y,
y y .
{ OnPaint y y
y }
procedure TForm1.FormPaint(Sender: TObject);
Var
L: Integer; // ()
H: Integer; //
,y: integer; // y
begin
L:= Round(Form1.ClientHeight/3);
H := Form1.ClientWidth;
. 1.20. y
:= 1;
y := 1;
With Canvas Do
begin
{ y y ,
}

25
Brush.Color := clRed; //
Pen.Color
:= clRed; //
Rectangle(,y,x+L,y+H);
Brush.Color := clYellow;
Pen.Color
:= clYellow;
Rectangle(x+L,y,x+2*L,y+H);
Brush.Color := clBlue;
Pen.Color
:= clBlue;
Rectangle(x+2*L,y,x+3*L,y+H) ; // y
Pen.Color
:= clBlack;
Brush.Style := bsClear; // ""
Font.Size := 24;
Font.Name := 'Times New Roman';
Font.Color := clWhite; TextOut(round(l/2),H,' M o l d o v a');
Font.Color := clBlack; TextOut(round(l/2)+1,H+1,' M o l d o v a');
end;
end;
25.

y,

, y
(. 1.21).
Unit Stars_;
interface
Uses
Windows, Messages, SysUtils, Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs, StdCtris;
Type
TForm1= class (TForm)
procedure FormMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
private
{ Private declarations }
. 1.21.
Public
{ Public declarations }
procedure StarLine(x0,y0,r: integer); // y y
end;
var Form1: TForm1;
implementation
{$R *.dfm}
// y y
procedure TForm1.StarLine(x0, y0, r: integer);
// x0, y0 ; r y
var // y
: array[1..11] of TPoint;
a: integer; // y y , y
i: integer;
begin
:= 18; // . y
for i:=1 to 10
Do begin
If (i mod 2=0)
Then begin //
p[i].x:=x0+Round(r/3*cos(a*2*pi/360)) ;
p[i].y:=y0-Round(r/3*sin(a*2*pi/360)) ;
end
else begin // y
p[i].x:=x0+Round(r*cos(a*2*pi/360)) ;
p[i].y:=y0-Round(r*sin(a*2*pi/360)) ;

26
end;
a := a+36;
end;
p[11].X := p[1].X; // y y
[11].Y := [1].Y;
Canvas.Polyline(p); // y
end;
//
procedure
TForm1.Form1MouseDown(Sender:
TObject;
TShiftState; X, Y: Integer);
begin
If Button = mbLeft // ?
then Canvas.Pen.Color := clBlack
else Canvas.Pen.Color := clRed;
StarLine(x, y, 30);
end;
End.

Button:

TMouseButton;

Shift:

26. y ,
y
() ,

.

10
(. 1.22).
Unit tir_;
Interface
Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
. 1.22. 10
StdCtrls, ExtCtrls;
Type
TForm1 =class(TForm)
Timer: TTimer;
Label1: TLabel;
Button1: TButton;
procedure TimerTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Form1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
{ y , y y ,
y}
procedure PaintFace(x,y: integer); // y y
procedure EraseFace(x,y: integer); // y
end;
var
Form1: TForm1;
fx,fy: integer; //
n: integer; //
: integer; //
implementation
{$R *.dfm}
// y y
procedure TForm1.PaintFace(x,y: integer);
begin
Canvas.Pen.Color := clBlack; //
Canvas.Brush.Color := clYellow; //
// y y

27
Canvas.Ellipse(,y,x+30,Y+30); //
Canvas.Ellipse(x+9,y+10,x+11,y+13); //
Canvas.Ellipse(x+19,y+10,x+21,y+13); //
Canvas.Arc(x+4,y+4,x+26,y+26,x,y+20,x+30,y+20); // y
end;
// y
procedure TForm1.EraseFace(x,y: integer);
begin
{ , .
y - clBtnFace (. Object Inspector)}
Canvas.Pen.Color := clBtnFace; // y
Canvas.Brush.Color := clBtnFace; //
Canvas.Ellipse(x,y,x+30,y+30) ;
end;
procedure TForm1.TimerTimer(Sender: TObject);
begin
EraseFace(fx,fy);
//
fx:= Random(ClientWidth-30); // 30 -
fy:= Random(ClientHeight-30);
PaintFace(fx,fy);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//
fx:=100; fy:=100;
Timer1.Enabled:=False;
Randomize; // y
end;
//
procedure
TForm1.Form1MouseDown(Sender:
TObject;
Button:
TMouseButton;
Shift:
ShiftState; X, Y: Integer);
begin
inc(n); // -
If (x>fx) And (x<fx+30) And (y>fy) And (y<fy+30) then inc(p);//
If n = 10 //
Then begin
Timer1.Enabled := False; //
ShowMessage(': 10. : ' +IntToStr(p)+'.');
EraseFace(fx,fy);
Label1.Visible := True; //
Button1.Visible := True;
end;
end;
// Ok
procedure TForm1.Button1Click(Sender: TObject);
begin
n:=0; p:=0;
Label1.Visible := False; //
Button1.Visible := False; // y
Timer1.Enabled := True; // y
end;
End.
27. y, y
: , b, d.
(. 1.23). . 1.24.

28

. 1.23.

Var

: integer =5; //
u: integer =7; //
{ y y. }
. 1.24.
procedure a(i:integer; canvas: TCanvas); forward;

procedure b(i:integer; canvas: TCanvas); forward;
procedure c(i:integer; canvas: TCanvas); forward;
procedure d(i:integer; canvas: TCanvas); forward;
//
procedure a(i: integer; canvas: TCanvas);
begin
If i > 0
then begin
d(i-1, canvas); canvas.LineTo(canvas.PenPos.X+u, canvas.PenPos.Y);
a(i-1, canvas); canvas.LineTo(canvas.PenPos.X,
canvas.PenPos.Y+u);
a(i-1, canvas); canvas.LineTo(canvas.PenPos.X-u, canvas.PenPos.Y);
(i-1, canvas);
end;
end;
procedure b(i: integer; canvas: TCanvas);
begin
If i > 0
then begin
(i-1, canvas); canvas.LineTo(canvas.PenPos.X-u, canvas.PenPos.Y);
b(i-1, canvas); canvas.LineTo(canvas.PenPos.X,
canvas.PenPos.Y-u);
b(i-1, canvas); canvas.LineTo(canvas.PenPos.X+u, canvas.PenPos.Y);
d(i-1, canvas);
end;
end;
procedure c(i: integer; canvas: TCanvas);
begin
If i > 0
then begin
b(i-1, canvas); canvas.LineTo(canvas.PenPos.X, canvas.PenPos.Y-u);
(i-1, canvas); canvas.LineTo(canvas.PenPos.X-u,canvas.PenPos.Y);
(i-1, canvas);canvas.LineTo(canvas.PenPos.X,
canvas.PenPos.Y+u);
a(i-1, canvas);
end;
end;
procedure d(i: integer; canvas: TCanvas);
begin
If i > 0
then begin
a(i-1, canvas); canvas.LineTo(canvas.PenPos.X, canvas.PenPos.Y+u);
d(i-1, canvas); canvas.LineTo(canvas.PenPos.X+u,canvas.PenPos.Y);
d(i-1, canvas); canvas.LineTo(canvas.PenPos.X, canvas.PenPos.Y-u);
b(i-1, canvas);

29
end;
end;
// OnPaint
procedure TForm1.FormPaint(Sender: TObject);
begin
Form1.Canvas.MoveTo(u,u);
a(5,Form1.Canvas); // y
end;
28.

y,

(. 1.25).

// OnPaint
procedure TForm1.FormPaint
(Sender: TObject);
var
x0,y0 :integer; //
//
dx,dy :integer; //
// ( )
h,w
:integer; //
//
,y
:integer;
lx,ly :real; // ()
// X Y
dlx,dly:real; //
//() X Y
. 1.25.
cross :integer; //
dcross :integer; // y
begin
0:=30; y0:=220; // (40,250)
dx:=40; dy:=40; // 40
dcross:=1; // X: 1 y; 2 y; 3 - ;
dlx:=0.5; // X
dly:=1.0; // Y, yy: 1,2,3 . .
h:=200; w:=300;
With Form1.Canvas
Do begin
cross:=dcross ;
MoveTo(x0, y0); LineTo(x0, y0-h); // X
MoveTo(x0, y0); LineTo(x0+w,y0);
// Y , X
x:=x0+dx;
lx:=dlx;
Repeat
MoveTo(x,y0-3); LineTo(x,y0+3) ; //
cross:=cross-1;
If cross = 0 //
then begin
TextOut(x-8,y0+5,FloatToStr(lx)) ;
cross:=dcross;
end;
Pen.Style:=psDot;
MoveTo(x,y0-3); LineTo(x,y0-h); //
Pen.Style:=psSolid;
lx:=lx+dlx;
x:=x+dx;
Until (x>x0+w);
// , Y
y:=y0-dy;

30
ly:=dly;
Repeat
MoveTo(x0-3, y); LineTo(x0+3,y); //
TextOut(x0-20,y,FloatToStr(ly)); //
Pen.Style:=psDot;
MoveTo(x0+3,y); LineTo(x0+w,y); //
Pen.Style:=psSolid;
y:=y-dy;
ly:=ly+dly;
Until (y<y0-h);
end;
29.

end;

y,

y, 2 sin(x) e(x/5).

. 1.26.

// y,
Function f(x:real):real;
Begin
f:=2*Sin(x)*exp(x/5);
end;
// y
procedure GrOfFunc;
var
. 1.26.
x1,x2 : real; // y y
y1,y2 : real; // y
x
: real; // y y
y
: real; // y
dx
: real; // y
l,b
: integer; // y
w,h
: integer; //
mx,my : real;
// X Y
x0,y0 : integer; //
begin
//
L := 10; // X y
B := Form1.ClientHeight-20; // Y y
H := Form1.ClientHeight-40; //
W := Form1.Width-40; //
x1:= 0; // y
2:= 25; // y
dx:= 0.01; // y
// y [x1,x2]
y1:= f(x1); // y
y2:= f(x1); //y
:=x1;
Repeat
y := f(x);
If y < y1 then y1:=y;
If y > y2 then y2:=y;
x:=x+dx;
Until (x>=x2);
//
my:=h/abs(y2-y1); // Y
mx:=w/abs(x2-x1); // X
//
0:=1;
Y0:=b-Abs(Round(y1*my));

31
With Form1.Canvas
Do begin //
MoveTo(l,b);LineTo(l,b-h);
MoveTo(x0, y0);LineTo(x0+w, y0) ;
TextOut(l+5,b-h,FloatToStrF(y2,ffGeneral,6,3) ) ;
TextOut(l+5,b, FloatToStrF(y1,ffGeneral,6,3) ) ;
//
x:=x1;
Repeat
y:=f(x);
Pixels[x0+Round(x*mx),y0-Round(y*my)]:=clRed;
x:=x+dx;
Until (x>=x2);
end;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
GrOfFunc;
end;
//
procedure TForm1.FormResize(Sender: TObject);
begin // y
Form1.Canvas.FillRect(Rect(0,0,ClientWidth,ClientHeight));
GrOfFunc; //
end;
30. y,
y, ,
y

.

. 1.27.
implementation
{$R *.dfm}
Const
NR = 4; // -
Var
n: array[1..NR]
of real; //
p: array[1..NR] of real;
// y
h: array[1..NR] of integer;
//
. 1.27.
//
BarColor:array[1..4] of TColor=(clRed,clGreen,clBlue,clYellow);//
// , Obr = TRUE
function Obr : boolean;
var
sum: real; // y
m: integer; // ,
i: integer;
begin
obr := FALSE; // y .
// y
for i:=l to NR
// () ,
//
Do Begin
Try
n[i] := StrToFloat(Form1.StringGrid1.Cells[1,i]);
except
on EConvertError Do

32
begin
ShowMessage(' ' + #13
+ ' .');
exit;
end;

end;
end;
// yy (- )
sum := 0;
for i:=l to NR Do sum := sum + n [ i ]; //
for i:=l to NR Do p[i] := n[i] / sum; //
m := 1;
for i := 2 to NR Do
If n[i] > n[m] then m:=i; // y y y
// Image1.Height-20 y
for i :=1 to NR Do h[i] := Round((Form1.Image1.Height - 20) *n[i] /n[m]) ;
// y
obr := TRUE;
end;
//
procedure diagr;
Const
WR = 25; //
DP = 10; // y
Var
,y: integer; // y
i: integer;
begin
With Form1. Image1
Do begin
x:=10;
y:=Height;
Canvas.Brush.Color := clWindow;
Canvas.Rectangle(0,0,Width,Height);
// *** y ***
for i:=1 to 4
Do begin
Canvas.Brush.Color := BarColor[i]; //
Canvas.Rectangle(x,y,x+WR,y-h[i]); //
Canvas.Brush.Color := clWindow; //
// ( )
Canvas.TextOut(x,y-h[i]-15, FloatToStrF(p[i]*100,
ffGeneral,3,2)+'%');
x := x + WR + DR;
end; // *** ***
//
:= + 20;
y:=20; // 20 Image1
for i:=l to 4
Do begin
Canvas.Brush.Color := BarColor[i]; // y
Canvas.Rectangle(x,y,x+25,y+14); // y
Canvas.Brush.Color := clWindow;
Canvas.TextOut(x+WR+10,y, Form1.StringGrid1.Cells[0,i]);
y := y + 20;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//
StringGrid1.Cells[0,0] := '';

33
StringGrid1.Cells[1,0] := '-';
StringGrid1.Width :=StringGrid1.ColWidths[0] + StringGrid1.ColWidths[1]+5;
end;
// ( StringGrid) y
// <Enter> y yy y
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
// Col, Row , y (y y).
// ColCount RowCount -
If Key = #13
then begin
// <Enter>
If StringGrid1.Col<StringGrid1.ColCount1//
Then StringGrid1.Col := StringGrid1.Col + 1 // . y
Else //
If ( StringGrid1.Row < StringGrid1.RowCount 1)
then begin
// y
StringGrid1.Col :=0;
StringGrid1.Row := StringGrid1.Row +1;
End
else Button1.SetFocus;
exit;
// y y
If StringGrid1.Col = 1 then
//
case Key of
'0' .. '9', # 8 :;
'.',',': Begin
Key := DecimalSeparator;
If Pos(DecimalSeparator, StringGrid1.Cells[StringGrid1.Row,
StringGrid1.Col]) <> 0 then Key := Char(0);
end
else Key := Char(0);
end;
end;
//
procedure TForm1.Button1Click(Sender: TObject);
begin
If Obr //
then diagr; // y
end;
End.
31. y, - yy y,
y, , (. 1.28).
32.

y, y. y
, y,
-y y. y
. 1.29. , - ,
. 1.30.

34

. 1.28. y ,

. 1.29.

. 1.30. , y

35
// y
Unit grafik01;
interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids;
Type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Label1: TLabel;
Button1: TButton;
CheckBox1: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
// yy gr y onPaint Form2,
// y y.
// y y Interface.
procedure gr; // yy y y
implementation
Uses grafik02;
{$R *.dfm}
{ y StringGrid: FixedRows := 0;
RowCount := 2; Options. goEdit ing := True; Options. goTab := True;}
Const COLCOUNT = 15;
var
// y y
: array[1..COLCOUNT] of real;
y: array[1..COLCOUNT] of real;
// y ,y
procedure gr;
var
i: integer;
x1,x2:real; // y y
y1,y2:real; // y
l,b:integer; // y
w,h: integer; //
mx,my:real; // X Y
x0,y0:integer; //
,y: integer; //
np: integer; // -
begin
Form2.Canvas.Rectangle(0,0,Form2.ClientWidth,Form2.ClientHeight);
//
l:=10; // X y
b:=Form2.ClientHeight-20; //Y y
h:=Form2.ClientHeight-40; //
w:=Form2.Width-40; //
{ y ( X
y )}
x1:=x[1];
i:=1;
While (x[i+1] > x[i]) And (i < COLCOUNT)
Do Begin
i:=i+1;
x2:= x[i]; //x[COLCOUNT-1];
np:=i; //

36
If np < 2
then begin
ShowMessage(' y');
exit;
end;
// y
y1:=0; //y[1]; // y
y2:=0; //y[1]; // y
for i: =1 to np
Do begin
If y[i] < y1 then y1:=y[i];
If y[i] > y2 then y2:=y[i];
end;
//
my:=h/abs(y2-y1); // Y
mx:=w/abs(x2-x1); // X
//
x0:=l+Abs(Round(x1*mx));
y0:=b-Abs(Round(y1*my));
With form2.Canvas
Do begin
MoveTo(x0,b); LineTo(x0,b-h); // Y
MoveTo(l,y0); LineTo(l+w,y0); // X
TextOut(l+5,b-h,FloatToStrF(y2,ffGeneral,6,3));
TextOut(l+2,b+2,FloatToStrF(y1,ffGeneral,6,3));
End;
//
for i :=1 to np
Do begin
px := x0+Round(x[i]*mx);
py := y0-Round(y[i]*my);
Form2.Canvas.Pen.Color := clRed;
Rectangle(px-2,py-2,px+2,py+2); //
If Form1.CheckBox1.Checked then
//
If i = 1 then MoveTo(px,py) else LineTo(px,py);
Form2.Canvas.Pen.Color := clBlack;
// y y
TextOut(px-5,py-15,FloatToStr(y[i]));
TextOut(px-5,y0+2, FloatToStr(x[i]));
MoveTo(px,py); // y y , y, . .
//TextOut
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
StringGrid1.ColCount := COLCOUNT;
StringGrid1.Cells[0,0] := 'X';
StringGrid1.Cells[0,1] := 'Y';
for i:=1 to COLCOUNT
// : y
Do begin
StringGrid1.Cells[i,0] := IntToStr(i-1);
StringGrid1.Cells[i,1] := IntToStr(i-1);
end;
end;
//
procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
// y y

37
for i:=1 to COLCOUNT-1
Do begin
x[i] := StrToFloat(Form1.StringGrid1.Cells[i,0]);
y[i] := StrToFloat(Form1.StringGrid1.Cells[i,1]);
end;
// y y OnPaint Form2
If Not Form2.Showing
then Form2.Show // Form2
else Form2.Repaint;
end;
End.
// y ,
Unit grafik02;
interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
Grafik01; // *** yy!
Type
TForm2 = class(TForm)
procedure FormPaint(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form2: TForm2;
implementation
{$R *.dfm}
// nint ,
//
procedure TForm2.FormPaint(Sender: TObject);
begin
gr; //
end;
// OnResize ,
procedure TForm2.FormResize{Sender: TObject);
begin
gr; //
end;
End.
33. y, ,
(. 1.31). . 1.32.

. 1.31.

Unit ship_;
interface
Uses
Windows, Messages,

. 1.32. y, y

38
SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
Type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.DFM}
Var x,y: integer; // ( )
//
procedure Parohod(x,y: integer; mode: boolean);
// x,y
// mode: True , False
Const
// y ,
//
dx = 5; // X
dy = 5; // Y
var
// y y y Polygon
p1: array[1..7] of TPoint; // y
2: array[1..8] of TPoint; //
pc, bc: TColor; // y
begin
If Not mode
then begin
//
Form1.Canvas.Brush.Color := clNavy;
Form1.Canvas.Pen.Color
:= ClNavy;
Form1.Canvas.Rectangle(x,y+1,x+17*dx,y-10*dy);
Form1.Canvas.Brush.Color := clNavy;
//
If y-10*dy < 80
then begin
//
Form1.Canvas.Pen.Color := clSkyBlue;
Form1.Canvas.Brush.Color := ClSkyBlue;
Form1.Canvas.Rectangle(x,y-10*dy,x+17*dx,80);
end;
exit;
end;
// y
With Form1.Canvas
Do begin
pc := Pen.Color; // y
bc := Brush.Color; //
Pen.Color := clBlack; // y y
Brush.Color := clWhite;
// y y
p1[1]. := ;
p1[1].y := y;
p1[2]. := ;
p1[2].y := y-2 *dy;
p1[3]. := x+10*dx; p1[3].y := y-2 *dy;
p1[4].x := x+11*dx; p1[4].y := y-3 *dy;
p1[5].x := x+17*dx; p1[5].y := y-3 *dy;

39
1[].x := x+14*dx; p1[6].y := y;
p1[7].x := x;
p1[7].y := y;
Polygon(p1);
//
p2[1].x := x+3*dx;
p2[1].y := y-2*dy;
p2[2].x := x+4*dx;
p2[2].y := y-3*dy;
2[3]. := x+4*dx;
p2[3].y := y-4*dy;
2[4].x := x+13*dx; p2[4].y := y-4*dy;
2[5]. := x+13*dx; p2[5].y := y-3*dy;
2[6]. := x+11*dx; p2[6].y := y-3*dy;
2[7]. := x+10*dx; p2[7].y := y-2*dy;
2[8]. := x+3*dx;
p2[8].y: = y-2*dy;
Polygon(p2);
MoveTo(x+5*dx,y-3*dy); LineTo(x+9*dx,y-3*dy);
Rectangle(x+8*dx,y-4*dy,x+11*dx,y-5*dy); //
Rectangle(x+7*dx,y-4*dy,x+ 8*dx,y-7*dy); // y
Ellipse(x+11*dx,y-2*dy,x+12*dx,y-1*dy); //
Ellipse(x+13*dx,y-2*dy,x+14*dx,y-1*dy);
MoveTo(x+10*dx,y-5*dy); LineTo(x+10*dx,y-10*dy); //
Pen.Color := clwhite; //
MoveTo(x+17*dx,y-3*dy); LineTo(x+10*dx,y-10*dy); LineTo(x,y-2*dy);
Pen.Color := pc; //
end;
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Parohod(x,y, False); // y
If x < Form1.ClientWidth
then x := x+2
else begin //
x := 0;
y := Random(50) + 100;
end;
Parohod(x,y,True); //
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
//
Canvas.Brush.Color := clSkyBlue;
Canvas.Pen.Color := clSkyBlue;
Canvas.Rectangle(0,0,ClientWidth, 80) ;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
x:=0; y:=80; //
Form1.Color:=clNavy; //
Timer1.Interval := 50; // 50
end;
End.

40
34.

y,

-
y ,
y

- .
1.33.

Unit clock_;
interface
Uses
Windows, Messages,
SysUtils, Variants,
Classes, Graphics,
Controls, Forms,
. 1.33.
Dialogs, ExtCtrls;
Type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
// yy
procedure Vector(x0,y0,a,l: integer);
procedure DrawClock;
private
{ Private declarations )
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
Uses DateUtils; // y SecondOf, MinuteOf HourOf
Const R = 75; // y
Var
x0, y0: integer; //
ahr,amin,asec: integer; // (y)
//
procedure TForm1.FormCreate(Sender: TObject);
var t: TDateTime;
begin
//
ClientHeight := (R+10)*2;
ClientWidth := (R+10)*2;
0 := R+10;
Y0 := R+10;
t := Now();
//
ahr := 90 - HourOf(t)*30-(MinuteOf(Today)div 12)*6;
amin := 90 - MinuteOf(t)*6;
asec := 90 - SecondOf(Today)*6;
Timer1.Interval := 1000; // 1
Timer1.Enabled := True; // y
end;
// (0,y0)
procedure TForm1.Vector(x0,y0: integer; a, l: integer);
// 0,y0 ; y y ; l
Const GRAD = 0.0174532; // y y

41
var ,y: integer; //
begin
Canvas.MoveTo(0, y0) ;
:= Round(0 + l*cos(a*GRAD));
y := Round(y0 - l*sin(a*GRAD));
Canvas.LineTo(x, y);
end;
// y
procedure TForm1.DrawClock;
var t: TDateTime;
begin
// y y 6 y, 30.
//
Canvas.Pen.Color := clBtnFace; Canvas.Pen.Width :=3;
Vector(x0, y0, ahr, R-20); // y
Vector(x0, y0, amin, R-15); // yy
Vector(x0, y0, asec, R-7); // yy
t := Now(); //
ahr := 90 - HourOf(t)* 30-(MinuteOf(t)div 12) *6;
amin := 90 - MinuteOf(t)* 6;
asec := 90 - SecondOf(t)* 6; //
Canvas.Pen.Width := 3; //
Canvas.Pen.Color := clBlack;
Vector(x0,y0, ahr, R-20); // y
Canvas.Pen.Width := 2;
Canvas.Pen.Color := clBlack;
Vector(x0, y0, amin, R-15); . // y
Canvas.Pen.Width := 1;
Canvas.Pen.Color := clYellow;
Vector(x0, y0, asec, R-7);
end;
//
procedure TForm1.FormPaint(Sender: TObject);
var
x,y: integer; //
a: integer; // y y (0,y0) (,y)
: TColor; //
pw: integer; //
begin
:= Canvas.Pen.Color;
pw := Canvas.Pen.Width;
Canvas.Pen.Width := 1;
Canvas.Pen.Color := clBlack;
a:=0;
// 3- ,
//
While a < 360
Do begin
x:=x0+Round( R * cos(a*2*pi/360)) ;
y:=x0-Round( R * sin(a*2*pi/360));
Form1.Canvas.MoveTo(x,y);
If (a mod 30) = 0
then Canvas.Ellipse(x-2,y-2,x+3,y+3)
else Canvas.Ellipse(x-1,y-1,x+1,y+1);
a:=a+6; // 1 yy 6 y
end;
// -
Canvas.Pen.Width := pw;
Canvas.Pen.Color := pc;
DrawClock;
end;
// y

42
procedure TForm1.Timer1Timer(Sender: TObject);
begin
DrawClock;
end;
End.
35.

y,
y ,
y y (. 1.34).

Unit clock2_;
interface
Uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics, Controls, Forms, Dialo.gs, ExtCtrls;
Type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
. 1.34.
// yy
procedure Vector(x0, y0, a, l: integer);
procedure DrawClock;
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
Uses DateUtils; // y SecondOf, MinuteOf HourOf
Const R = 75; // y
Var
x0, y0: integer; //
ahr,amin,asec: integer; // (y)
//
procedure TForm1.FormCreate(Sender: TObject);
var
t: TDateTime;
begin
//
ClientHeight := (R+30)*2;
ClientWidth := (R+30)*2;
x0 := R+30;
y0 := R+30;
t := Now();
//
ahr := 90 - HourOf(t)*30-(MinuteOf(Today)div 12)*6;
amin := 90 - MinuteOf(t)*6;
asec := 90 - SecondOf(Today)*6;
Timer1.Interval := 1000; // 1
Timer1.Enabled := True; // y
end;
// (0,y0)
procedure Tform1.Vector(x0,y0: integer; a, l: integer);
// 0,y0 ; y y ; l
Const GRAD = 0.0174532; // y y
var
,y: integer; //
begin
Canvas.MoveTo(x0, y0) ;
:= Round(x0 + l*cos(a*GRAD));
y := Round(y0 - l*sin(a*GRAD));
Canvas.LineTo(x,y);

43
end;
// y
procedure TForm1.DrawClock;
var t: TDateTime;
begin
// y y 6 y, 30.
//
Canvas.Pen.Color := clBtnFace;
Canvas.Pen.Width :=3;
Vector(x0, y0, ahr, R-20); // y
Vector(x0, y0, amin, R-15); // yy
Vector(x0, y0, asec, R-7); // yy
t := Now();
//
ahr := 90 - HourOf(t)*30-(MinuteOf(t)div 12)*6;
amin := 90 - MinuteOf(t)*6;
asec := 90 - SecondOf(t)*6;
//
//
Canvas.Pen.Width := 3; Canvas.Pen.Color := clBlack; Vector(x0,y0, ahr, R-20);
// y
Canvas.Pen.Width := 2; Canvas.Pen.Color := clBlack; Vector(x0,y0, amin, R-15);
// y
Canvas.Pen.Width := 1; Canvas.Pen.Color := clYellow; Vector(x0,y0, asec, R-7);
end;
//
procedure TForm1.FormPaint(Sender: TObject);
var
x,y: integer;
//
a: integer;
// y y (0,y0) (,y)
h: integer;
//
bs: TBrushStyle; //
: TColor;
//
pw: integer;
//
begin
bs := Canvas.Brush.Style;
pc := Canvas.Pen.Color;
pw := Canvas.Pen.Width;
Canvas.Brush.Style := bsClear;
Canvas.Pen.Width := 1;
Canvas.Pen.Color := clBlack;
a:=0; // 3- ,
h:=3; // y 0 y 3
//
While a < 360
Do begin
X := x0+Round( R * cos(a*2*pi/360));
Y := x0-Round( R * sin(a*2*pi/360));
Form1.Canvas.MoveTo(x,y);
If (a mod 30) = 0
then begin
Canvas.Ellipse(x-2,y-2,x+3, y+3);
// y yy
X := x0+Round((R+15) * cos(a*2*pi/360));
Y := x0-Round((R+15) * sin(a*2*pi/360));
Canvas.TextOut(x-5,y-7,IntToStr(h));
dec(h);
If h = 0 then h:=12;
end
else Canvas.Ellipse(x-1,y-1,x+1,y+1);
a:=a+6; // 1 y 6 y
end;

44
// -
Canvas.Brush.Style := bs;
Canvas.Pen.Width := pw;
Canvas.Pen.Color := pc;
DrawClock;
end;
// y
procedure TForm1.Timer1Timer(Sender: TObject);
begin
DrawClock;
end;
End.
36.

y, (.
1.35). y (. 1.36)
y .

. 1.35.

. 1.36. y

Unit aplane_;
interface
Uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons;
Type
TForm1 = class (TForm)
Timer1: TTimer;
Image1: TImage;
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.DFM}
Var
Back, Picture: TBitMap; //
,y:integer;
// y
W,H: integer;
//
BackRct : TRect; // , .
procedure TForm1.FormCreate(Sender: TObject);
begin
{ y AutoSize False.

45
. Image1.AutoSize := False; }
//
Back := TBitmap.Create; //
Picture := TBitmap.Create; //
Back.LoadFromFile('factory.bmp'); // y
Image1.Width := Back:Width;
Image1.Height:= Back.Height;
Image1.Canvas.Draw(0,0,Back);
Picture.LoadFromFile('aplane.bmp'); // y y, y
W := Picture.Width; H := Picture.Height;
Picture.Transparent := True; // ""
//
Picture.TransParentColor := Picture.Canvas.Pixels[1,1];
:= 20; y := 20; //
BackRct:=Bounds(,y,W,); // y
end;
//
procedure TForm1.Timer1Timer(Sender: TObj ect);
begin
// y y
Image1.Canvas.CopyRect(BackRct,Back.Canvas, BackRct); x:=x+2;
If x > Image1.Width then x:=-W;
BackRct:=Bounds(x,y,W,H); // y
Image1.Canvas.Draw(x,y,Picture); // y
end;
//
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Back.Free; // , y
Picture.Free;
end;
End.
37. y, "y", y .
. 1.36, y (,
BMP-) .
1.37.
implementation
{$R *.DFM}
Const
FILMFILE = 'delphi.bmp'; // - BMP-
N_KADR=12; // (
)
Var
Film: TBitMap;
//
WKadr, HKadr: integer; //

. 1.36.
y Delphi

. 1.37. "y" -

CKadr: integer;
// y
RectKadr: TRect;
//
RectScr : Trect;
//
//
procedure TForm1.FormCreate(Sender: TObject);
begin
Film := TBitMap.Create;
// TBitMap
Film.LoadFromFile(FILMFILE); // y ""

46
WKadr := Round(Film.Width/N_Kadr);
HKadr := Film.Height;
RectScr := Bounds(10,10,WKadr,HKadr);
Ckadr:=0;
Timer1.Interval := 150;
// 0.15
Timer1.Enabled:=True;
// y
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
// y
RectKadr:=Bounds(WKadr*CKadr,0,WKadr,HKadr);
Form1.Canvas.CopyRect(RectScr,Film.Canvas,RectKadr); //
CKadr := CKadr+1;
// y y
If CKadr = N_KADR then Ckadr :=0;
end;
End.
38.

y,

y ,
. y
, y
. y
. 1.39.

Implementation
{$R *.dfm}
Const
HB = 58; //
//
HR = 274; //
{ y
y .
. 1.39.
y (
) HB+HR.}
Var
pic :TBitMap; // y
sRect,dRect: TRect; // -
t: integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
pic := TBitMap.Create;
pic.LoadFromFile('baner.bmp'); // y y
dRect := Bounds(10,10,pic.Width,HB); //
// , y
sRect := Rect(0,0,pic.Width,HB); //
t:=0;
end;
//
procedure Tform1.Timer1Timer(Sender: TObject);
begin
Canvas.CopyRect(dRect,pic.Canvas,sRect);
//
inc(t) ;
If t = HR then t:=0; //
sRect := Bounds (0,t,pic.Width,HB) ; // y
end;
// OK
procedure TFonnl.Button1Click(Sender: TObject);
begin
Form1.Close;
end;
End.

47
39. y,

y (.
1.40).

y y
( y
y Image Editor).
Unit hscroll_;
interface
Uses
Windows,
Messages,
SysUtils,
Variants, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls;
Type
TForm1 = class(TForm)
Timer: TTimer;
. 1.40. y y
Button1: TButton;
. y y.
procedure FormCreate(Sender: TObject);
procedure TimerTimer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
Var Form1: TForm1;
Implementation
{$R *.dfm}
{$R hbaner.res} { y, ,
Image Editor y 32
}
Const WB = 350; //
= 573; // y y
Var
pic :TBitMap; // y
sRect,dRect: TRect; // - -
t: integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
pic := TBitMap.Create;
pic.LoadFromResourceName(HInstance,'BANER2');
//
y y
dRect := Bounds(0,0,WB,pic.Height); // ,
,
sRect := Rect(0,0,TP,pic.Height); //
y
t:=0;
end;
//
procedure TForm1.TimerTimer(Sender: TObject);
begin
Canvas.CopyRect(dRect,pic.Canvas,sRect);
//
inc(t);
If t = TP then t:=0;//
sRect := Bounds(t,0,WB,pic.Height) ; // y

end;
// OK
procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Close;
end;
End.

48
40. y, y y ,
. . 1.41.
{ }
Unit shpic_;
Interface
Uses Windows, Messages, SysUtils, Classes, Graphics, Controls,Forms, Dialogs,
ExtCtrls, StdCtrls, Menus;
Type
TForm1 = class(TForm)
Image1: TImage; //
Button1: TButton; //
Label1: TLabel;
Edit1: TEdit;
// : BMP
RadioButton1: TRadioButton;
// : JPG -
RadioButton2: TRadioButton;
GroupBox1: TGroupBox;
procedure Button1Click(Sender: TObject);
. 1.41.
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
// yy
procedure FirstPicture; // y
procedure NextPicture; // yy
procedure ScaleImage; // y y
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
iw,ih: integer; // Image
implementation
{$R *.DFM}
Uses jpeg; // JPG
Var
aSearchRec : TSearchRec;
aPath: String[128]; // ,
aFile: String[128]; //
aMask: String[5];
//
n: integer = 0;
procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.AutoSize := False;
Image1.Stretch := True; //
//
iw := Image1.Width;
ih := Image1.Height;
Button1.Enabled := False; // y y
FirstPicture; // y
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
If Key = #13 then
If DirectoryExists(Edit1.Text) then FirstPicture
else ShowMessage(' '+ Edit1.Text +' y .');
end;
// y
procedure TForm1.FirstPicture;
var
r : integer; // y

49
begin
aPath := Edit1.Text;
If aPath [Length (aPath) ] <> '' then aPath := aPath + '';
If RadioButton1.Checked then aMask := '*.bmp' else aMask := '*.jpg';
r := FindFirst(aPath + aMask, faAnyFile, aSearchRec);
If r = 0
then begin
aFile := aPath + aSearchRec.Name;
Image1.Picture.LoadFromFile(aFile); // y
ScaleImage;
r := FindNext(aSearchRec); // y
If r = 0 then Button1.Enabled := True; //
end;
end;
// yy
Procedure TForm1.NextPicture;
var
r : integer;
begin
aFile := aPath + aSearchRec.Name;
Image1.Picture.LoadFromFile(aFile) ;
ScaleImage; // .
r := FindNext(aSearchRec); // y
If r <> 0 then Button1.Enabled := False; //
end;
//
procedure TForm1.Button1Click(Sender: TObject);
begin
NextPicture;
end;
// y
Procedure TForm1.ScaleImage;
Var
pw, ph : integer; //
scaleX, scaleY : real; // Y
scale : real; //
begin
// y y y
pw := Image1.Picture.Width;
ph := Image1.Picture.Height;
If pw > iw // Image
then scaleX := iw/pw // y
else scaleX := 1;
If ph > ih // .
then scaleY := ih/ph // y
else scaleY := 1; //
If scaleX < scaleY
then scale := scaleX
else scale := scaleY;
//
Image1.Height := Round(Image1.Picture.Height*scale);
Image1.Width : = Round(Image1.Picture.Width*scale);
// . . Strech = True y ,
// y
end;
// -
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
FirstPicture;
end;
// JPG-
procedure TForm1.RadioButton2Click(Sender: TObject);
begin

50
FirstPicture;
end;
End.
41.

y,

y,
y
(. 1.42).
y ,
y
y .

y Windows, ,
.bmp y.bmp.

Implementation
{$R *.dfm}
Var Back : TBitmap; //
procedure TForm1.Form1Create(Sender: TObject);
begin
Back := TBitmap.Create; // Back.
LoadFromResourceName (HInstance, 'PUZ');
. 1.42.
Back.LoadFromFile ('y.bmp') ; // y y
end;
procedure TForm1.FormPaint(Sender: TObject);
var
x,y: integer; // y
begin
x:=0; y:=0;
While y < Form1.Height Do
begin
While x < Form1.Width Do
begin
Form1.Canvas.Draw(x,y,Back);
x:=x+Back.Width;
end;
x:=0;
y:=y+Back.Height;
end;
end;
End.

51

y
y , :

y y Animate MediaPlayer.

Animate y, y
y .

MediaPlayer y, .
42. y, ,
y ,
y ,

. . 1.43
.
procedure TForm1.FormCreate(Sender: TObject);
begin
try
Animate1.FileName := 'bart.avi';
Animate1.Play(0,Animate1.FrameCount,1);
Except
onException Do
begin
Label1.Caption:=' y y '
.
+Animate1.FileName +'. '
+' y.'
end;
end;
end;
// Ok
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Form1.Close;
end;

1.43.

43. y,

AVI. y

. 1.44.
. 1.44. Panel1 y

{ y MediaPlayer}
Unit UsMP_;
interface
Uses Windows, Messages, SysUtils, Classes, Graphics, Controls,
MPlayer, StdCtrls, ExtCtrls;
Type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer; // y
Panel1: TPane; // , y
Button1: TButton; // Ok
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);

Forms,

Dialogs,

52
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.DFM}
{ MediaPlayer1:
MediaPlayer1.Display = Panel1
MediaPlayer1.FileName =speeds.avi
MediaPlayer1.AutoOpen = True
MediaPlayer1.Visible = False}
// OK
procedure TForm1.Button1Click(Sender: TObject);
begin
MediaPlayer1.Play; //
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{ y .
delphi_s.avi 260x260 }
//
MediaPlayer1.DisplayRect:=Rect(0,0,260,260);
end;
End.
44. y, y y (
AVI-) (. 1.44).
y Animate. ,
AVI-, y ( ,
y, y MediaPiayer).
y . y
. 1.45.
{**** ! **** Animate AVI-, y!
, y ,
. }
. 1.44.
. 1.45.
Unit ShowAVI_;
Interface
Uses Windows, Messages, SysUtils, Classes, Graphics, Controls,
StdCtrls, ComCtrls, ExtCtrls;
Type
TForm1 = class(TForm)
Animate1: TAnimate; // Animate
Button1: TButton; // y-
Button2: TButton; // y
Button3: TButton; // y
//
RadioButton1: TRadioButton; //
RadioButton2: TRadioButton; //
OpenDialog1: TOpenDialog; //
Button4: TButton; //
GroupBox1: TGroupBox;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);

Forms,

Dialogs,

53
procedure Button3Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button4Click(Sender: TObject);
// yy
procedure OpenAVI;
private
{ Private declarations }
Public
{ Public declarations }
end;
var
Form1: TForm1; //
CFrame: integer; // ,
Implementation
($R *.DFM)
//
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
If (Key = #13) And (Length(Edit1.Text) <> 0) then OpenAVI;
end;
//
procedure TForm1.Button4Click(Sender: TObject);
begin
OpenDialog1.Title := ' AVI-';
If OpenDialog1.Execute
Then begin
Edit1.Text := OpenDialog1.FileName;
OpenAVI;
end;
end;
// y
procedure TForm1.Button1Click(Sender: TObject);
begin
If Animate1.Active = False //
then begin
Animate1.StartFrame:=1; //
Animate1.StopFrame:=Animate1.FrameCount; //
Animate1.Active:=True;
Button1.caption:='';
RadioButton2.Enabled:=False;
End
else begin //
Animate1.Active:=False; //
Button1.caption:='y';
RadioButton2.Enabled:=True;
end;
end;
//
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
Button1.Enabled:=True; // y y
// y
Form1.Button3.Enabled:=False;
Form1.Button2.Enabled:=False;
end;
//
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
Button2.Enabled:=True; // y y
Button3.Enabled:=False; // y y

54
// y y y
Button1.Enabled:=False;
Animate1.StartFrame:=1;
CFrame:=1;
end;
// yy y
procedure TForm1.Button2Click(Sender: TObject);
begin
If CFrame < Animate1.FrameCount
Then begin
CFrame := CFrame + 1;
//
Animate1.StartFrame := CFrame; Animate1.StopFrame := CFrame;
Animate1.Active := True;
If CFrame = Animate1.FrameCount // y
then Button2.Enabled:=False;
end;
If CFrame > 1 then Button3.Enabled := True;
end;
// yy y
procedure TForm1.Button3Click(Sender: TObject);
begin
If CFrame > 1
Then begin
CFrame := CFrame 1; //
Animatel.StartFrame := CFrame;
Animatel.StopFrame := CFrame; Animate1.Active := True;
If Frame = 1 // y
then Form1.Button3.Enabled := False;
end;
If CFrame < Animate1.FrameCount then Button2.Enabled := True;
end;
// AVI-
procedure TForm1.OpenAVI;
begin
Button1.Enabled := False;
Button2.Enabled := False;
Button3.Enabled := False;
RadioButton1.Enabled := False;
RadioButton2.Enabled := False;
Try
Animate1.FileName := Edit1.Text;
Except
on Exception Do
begin
MessageDlg(' VI-.'+#13+'
( y.)',mtError,[mbOk],0);
exit;
end;
end;
Button1.Enabled := True;
// Button2.Enabled := True;
// Button3.Enabled := True;
RadioButton1.Enabled := True;
RadioButton2.Enabled := True;
end;
End.
45. y, y y y y Windows.
y . 1.46.
Unit WinSound_;

55
interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
MPlayer, ExtCtrls;
Type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
ListBox1: TListBox; // WAV-
Label2: TLabel;
Label1: TLabel; //
procedure ListBox1Click(Sender: TObject);
procedure
MediaPlayer1Click(Sender:
TObject;
Button: TMPBtnType; var DoDefault: Boolean);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Public
( Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.Dmf}
var SOUNDPATH: string[80]; {
Windows

WAV-,
Media }
procedure TForm1.FormCreate(Sender: TObject);
. 1.46. y Windows
var
lpBuf: PChar; // y nul-terminated-y
sWinDir: string[128]; // -
SearchRec: TSearchRec; // yy SearchRec
// , y y
begin //
MediaGetMera(lpBuf,MAX_PATH); //
GetWindowsDirectory (lpBuf ,_) ; // y Windows
sWinDir:=lpBuf; // nt-y -y
SOUNDPATH:=sWinDir+'\Media\'; // y
FreeMem(lpBuf); // WAV-
If FindFirst(SOUNDPATH+'*.wav', faAnyFile, SearchRec) =0
{ wav }
then begin
Form1.ListBox1.Items.Add(SearchRec.Name);
// y wav
While (FindNext(SearchRec) = 0) Do Form1.ListBox1.Items.Add(SearchRec.Name);
end;
end;
//
procedure TForm1.ListBox1Click(Sender: TObject);
begin
// Label2
Label2.Caption:=ListBox1.Items[ListBox1.ItemIndex];
end;
// MediaPlayer
procedure TForm1.MediaPlayer1Click(Sender: TObject; Button:TMPBtnType; var DoDefault:
Boolean);
begin
If (Button = btPlay) And (Label2.Caption =)
Then begin // Play
With MediaPlayer1 Do
begin
FileName:=S0UNDPATH+Label2.Caption; //
Open;
// Wait:= True;

56
end;

end;

end;
End.
46. y, y y .
. (AVI-)
y . y
. 1.47.
. 1.47. Video Player
Unit Vp_;
interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, MPlayer, Buttons, StdCtrls;
Type
TForm1 = class(TForm)
OpenDialog: TOpenDialog;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
MediaPlayer: TMediaPlayer;
procedure FormCreate(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure MediaPlayerNotify(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
MediaPlayer.Display := Form1;
// . y ...
SpeedButton1.Grouplndex := 1;
SpeedButton1.AllowAllUp := True;
end;
// AVI-
procedure DimAviff: string; var w,h: integer);
var
fst: TFileStream;
{ yyy AVI- , , \CBuilder\Include\aviriff.h}
Header : record
RIFF : array[1..4] of char;
// 'RIFF'
Nul : array[1..5] of Longlnt; // y
AVIH : array[1..4] of char;
// 'avih'
nu2 : array[1..9] of Longlnt; // y
Width : LongInt;
Height: LongInt;
end;
begin
fst := TFileStream.Create(f,fmOpenRead);
fst.Read(header,sizeof(header));
w := header.Width;
h := header.Height;
fst.Destroy;
end;
// Eject
procedure TForm1.SpeedButton2Click(Sender: TObject);

57
var

top,left
width,height
mw,mh
kh,kw
k

:
:
:
:
:

integer;
integer;
integer;
real;
real;

//
//
//
//
//

y ""


- h w
-

begin
OpenDialog.Title := ' ';
If Not OpenDialog.Execute then exit;
// ' '
// "" ( ), y
DirnAvi (OpenDialog.FileName,width,height) ;
mh:=SpeedButton1.Top - 10;
mw:=Form1.ClientWidth;
If mh > height then kh :=1 else kh := mh/height;
If mw > width then kw :=1 else kw := mw/width;
If kw < kh
then k := kw else k := kh;
//
width := Round(width * k) ;
height := Round(height * k);
left := (Form1.ClientWidth - width) div 2;
top := 10;
MediaPlayer.FileName := OpenDialog.FileName;
MediaPlayer.Open;
MediaPlayer.DisplayRect := Rect(left,top,width,height);
SpeedButton1.Enabled := True;
end;
// Play/Stop
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
If SpeedButton1.Down
Then begin
//
MediaPlayer.Play;
SpeedButton1.Hint := 'Stop';
End
else begin
//
MediaPlayer.Stop;
SpeedButton1.Hint := 'Play';
end;
end;
//
procedure TForm1.MediaPlayerNotify(Sender: TObject);
begin
If (MediaPlayer.Mode = mpStopped) And SpeedButton1.Down
Then SpeedButton1.Down := False; // "" y Play
end;
End.
47. y, y y y -.

. y
. 1.48.
. 1.48. CD Player
Unit CDp_;
interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, MPlayer, ExtCtrls, MMSYSTEM;

58
Type
TForm1 = class(TForm)
MediaPlayer: TMediaPlayer;
Timer1: TTimer;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
procedure FormActivate (Sender: TObject);
procedure MediaPlayerNotify(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
var
Track: integer; //
//
procedure TForm1.FormActivate(Sender: TObject);
begin
MediaPlayer.Open;
{ , CD-ROM Audio CD. , Mode =
mpStopped. , Mode = mpOpened.
y . CD-ROM, ,
y - 1}
If (MediaPlayer.Mode = mpStopped) And (MediaPlayer.Tracks > 1)
Then begin
BitBtn1.Enabled := True;
MediaPlayer.Notify := True;
End
else Timer1.Enabled := True;
end;
// MediaPlayer
procedure TForm1.MediaPlayerNotify(Sender: TObject),
begin
case MediaPlayer.Mode of
mpOpened: //
begin
BitBtn1.Enabled := False;
BitBtn1.Caption := 'Play';
BitBtn1.Tag := 0;
BitBtn2.Enabled := False;
BitBtn3.Enabled := False;
Timer1.Enabled := True;
Label2.Caption := '00:00';
end;
end;
MediaPlayer.Notify := True;
end;
// Play/Stop
procedure TForm1.BitBtn1Click(Sender: TObject);
begin

59
If BitBtn1.Tag = 0
then begin
// Play
BitBtn1.Caption := 'Stop';
BitBtn3.Enabled := True;
MediaPlayer.Notify := False;
MediaPlayer.Play;
Timer1.Enabled :=True;
BitBtn1.Tag := 1;
Track := MCI_TMSF_TRACK(MediaPlayer.Position);
End
Else begin // Stop
BitBtn1.Caption := 'Play';
BitBtn3.Enabled := True;
MediaPlayer.Notify := True;
MediaPlayer.Stop;
Timer1.Enabled := False;
BitBtn1.Tag := 0;
end;
end;
// :
procedure TForm1.Timer1Timer(Sender: TObject);
var
trk, //
min, sec: byte; //
begin
If MediaPlayer.Mode = mpPlaying
//
then Begin
trk := MCI_TMSF_TRACK(MediaPlayer.Position);
min := MCI_TMSF_MINUTE(MediaPlayer.Position);
sec := CI_TMSF_SECOND(MediaPlayer.Position);
Labe11.Caption := Format('Track %d.',[trk]);
Label2.Caption :=Format('%d:%.2d',[min,sec]);
If trk <> Track
Then begin
Track := trk;
If Track = 2 then BitBtn2.Enabled := True;
If Track = MediaPlayer.Tracks then BitBtn3.Enabled := False;
end;
exit;
end;
{ Audio CD, Mode = mpOpen ( mpStopped
+ - > 1)}
If (MediaPlayer.Mode = mpStopped) And (MediaPlayer.Tracks > 1)
Then begin
Timer1.Enabled := False;
MediaPlayer.Open;
BitBtn1.Enabled := True;
MediaPlayer.Notify := True;
Label1.Caption := 'Audio CD';
Label1.Visible := True;
end;
//
If MediaPlayer.Mode = mpOpen
Then begin
Label1.Caption := ' Audio CD';
If Label1.Visible
then Label1.Visible := False
Else Label1.Visible := True;
end;
end;
// Previous
procedure TForm1.BitBtn2Click(Sender: TObject);

60
begin
MediaPlayer.Previous; // y
MediaPlayer.Previous; // y
If MCI_TMSF_TRACK(MediaPlayer.Position) = 1 then BitBtn2.Enabled := false;
If Not BitBtn3.Enabled then BitBtn3.Enabled := True;
end;
// Next
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
MediaPlayer.Next ;
// y y, y Next y
If MCI_TMSF_TRACK(MediaPlayer.Position) = MediaPlayer.Tracks
then BitBtn3.Enabled := False;
end;
//
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MediaPlayer.Stop;
end;
End.
48. y, y y y -.
() y TrackBar (. 1.49).
. 1.49. CD Player
Unit CDp2_;
interface
Uses Windows, Messages, SysOtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, MPlayer, ExtCtrls, MMSYSTEM;
Type
TForm1 = class(TForm)
MediaPlayer: TMediaPlayer;
TrackBar: TTrackBar;
Button1: TButton;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
procedure TrackBarChange(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TimerITimer(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
($R *.dfm}
var Track: integer;
// y
procedure TForm1.TrackBarChange(Sender: TObject);
var
trk: integer; // ,
begin
trk :=TrackBar.Position;
If trk > MCI_TMSF_TRACK(MediaPlayer.Position)
then While trk > MCI_TMSF_TRACK(MediaPlayer.Position) Do MediaPlayer.Next
else While trk < MCI_TMSF_TRACK(MediaPlayer.Position) Do MediaPlayer.Previous;

61
end;
// Play/Stop
procedure TForm1.ButtorilClick (Sender: TObject);
begin
If Button1.Tag = 0
Then Begin Button1.Caption := 'Stop'; Button1.Tag :=1; MediaPlayer.Play; End
Else Begin Button1.Caption := 'Play'; Button1.Tag :=0; MediaPlayer.Stop; end;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
If (MediaPlayer.Mode = mpStopped) And (MediaPlayer.Tracks > 1)
then begin Button1.Enabled := True; TrackBar.Max := MediaPlayer.Tracks; End
else begin Label1.Caption := ' Audio CD'; end;
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
var
trk, //
min, sec: byte; //
begin
case MediaPlayer.Mode of
mpPlaying: //
begin
min := MCI_TMSF_MINUTE(MediaPlayer.Position);
sec := MCI_TMSF_SECOND (MediaPlayer. Position) ;
Label2.Caption := Format('%d:%.2d',[min,sec]);
// y
trk := MCI_TMSF_TRACK(MediaPlayer.Position);
If trk <> Track
Then begin
Track:= trk; TrackBar.Position := Track;
Label1.Caption := Format ('Track %d. ' , [trk]) ;
end;
end;
mpOpen: //
begin
If Button1.Enabled
Then begin
Label1.Caption := ' Audio CD';
Label2.Caption := '';
Button1.Enabled := False; //
Button1.Caption := 'Play';
end;
//
If Label1.Visible
then Label1.Visible := False
else Label1.Visible := True;
end;
mpStopped: //
begin
If Not Button1.Enabled
then begin
//
MediaPlayer.Open;
Button1.Enabled := True;
Labe11.Caption := 'Track: 1';
Label1.Visible := True;
Label2.Caption:= '';
TrackBar.Position : = 1;
TrackBar.Max := MediaPlayer.Tracks;
end;
If Button1.Tag = 1

62
Then begin
//
Button1.Caption := 'Play';
Button1.Tag :=0;
TrackBar. Position := 1;
Label1.Caption := 'Track 1';
Label2.Caption := ' ' ;
end;
end;
end; // case
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MediaPlayer.Stop;
end;
End.
49.

Player.

-,

yy
y

.

y
ListBox,
y

SpeedButton.
y

.
1.50.

Unit mp3p_;
interface
Uses
Windows,
Messages,
SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons,
ExtCtrls, MPlayer, ComCtrls,
. 1.50. Player
MMSYSTEM, FileCtrl; // yy
Type
TForm1 = class(TForm)
//
SpeedButton1: TSpeedButton; // y
SpeedButton2: TSpeedButton; // /
SpeedButton3: TSpeedButton; // y
SpeedButton4: TSpeedButton; //
ListBox1: TListBox; // (-)
MediaPlayer1: TMediaPlayer; //
TrackBar1: TTrackBar; // y
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Shape1: TShape; // y
procedure FormCreate(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);

63
procedure Timer1Timer(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
// yy
procedure Play; //
procedure PlayList(Path: string); // y -
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
($R *.dfm}
Var
SoundPath: string[255];
min,sec: integer; //
volume: LongWord; // , .
// y -
procedure TForm1.PlayList(Path: string);
var
lpBuf: PChar; // y nul-terminated-y
sWinDir: string[128]; // -
SearchRec: TSearchRec; // yy SearchRec ,
// y y
Begin
ListBox1.Clear;
// -
If FindFirst(Path + '*.mp3', faAnyFile, SearchRec) = 0
Then begin
// wav
ListBox1.Items.Add(SearchRec.Name);
// y wav
While (FindNext(SearchRec) = 0) Do ListBox1.Items.Add(SearchRec.Name);
end;
ListBox1.ItemIndex := 0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//PlayList II
ListBox1.ItemIndex := 0;
Label1.Caption:=ListBox1.Items[ListBox1.ItemIndex];
TrackBar1.Position := 7;
// volume ,
volume := (TrackBar1.Position - TrackBar1.Max+1)* 6500;
volume := volume + (volume shl 16);
waveOutSetVolume(WAVE_MAPPER,volume) ; // y
end; //
procedure TForm1.ListBox1ClickfSender: TObject);
begin
// Label1
If Not SpeedButton2.Down then SpeedButton2.Down := True;
Label1.Caption:=ListBox1.Items[ListBox1.ItemIndex];
Play;
end;
//
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
If SpeedButton2.Down
then Play // y
Else
Begin
{ ,
}
MediaPlayer1.Stop;
Timer1.Enabled := False;

64
SpeedButton2.Down := False;
SPeedButton2.Hint := 'Play';
end;

end;
// y
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
If ListBox1.ItemIndex > 0 then ListBox1.ItemIndex := ListBox1.ItemIndex 1;
Play;
end;
// y
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
If ListBox1.ItemIndex < ListBox1.Count then ListBox1.ItemIndex:=ListBox1.ItemIndex+1;
Play;
end;
// y
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
volume := 6500* (TrackBar1.Max TrackBar1.Position);
volume := volume + (volume shl 16);
waveOutSetVolume(WAVE_MAPPER,volume);
end;
// , ListBox1
procedure TForm1.Play;
begin
Timer1.Enabled := False;
Label1.Caption:=ListBox1.Items[ListBox1.ItemIndex];
MediaPlayer1.FileName := SoundPath + ListBox1.Items[ListBox1.ItemIndex];
Try
MediaPlayer1.Open;
Except
on EMCIDeviceError Do
begin
ShowMessage(' y '+ ListBox1.Items[ListBox1.ItemIndex]);
SpeedButton2.Down := False;
exit;
end;
end;
MediaPlayer1.Play;
min :=0; sec :=0;
Timer1.Enabled := True;
SpeedButton2.Hint := 'Stop';
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
//
If sec < 59
Then inc(sec)
else begin sec :=0; inc(min); end;
//
Label2.Caption := IntToStr(min)+':';
If sec < 10
then Label2.Caption := Label2.Caption +'0'+ IntToStr(sec)
else Label2.Caption := Label2.Caption + IntToStr(sec);
// y
If MediaPlayer1.Position < MediaPlayer1.Length then exit;
// y
Timer1.Enabled := False; //
MediaPlayer1.Stop; //
If ListBox1.ItemIndex < ListBox1.Count //

65
then begin ListBox1.ItemIndex := ListBox1.ItemIndex + 1; Play; End
end;
// y, -
procedure TForm1.SpeedButton4Click(Sender: TObject);
var
Root: string; //
pwRoot : PWideChar;
Dir: string;
begin
Root := ''; //
GetMem(pwRoot, (Length(Root)+1) * 2) ;
pwRoot := StringToWideChar(Root,pwRoot,MAX_PATH*2);
If Not SelectDirectory(' y, pwRoot, Dir)
then Dir :=''
else Dir := Dir+'\'; // , -
SoundPath := Dir;
PlayList(SoundPath);
end;
End.

66

y , :

y y
try ... except.
50.

y,
Memo
.
y

. 1.51.

Implementation
{$R *.dfm}
//
procedure
TForm1.Edit1KeyPress(Sender:
TObject; var Key: Char),
begin
If Key = #13 // <Enter>
then Button1.SetFocus;
. 1.51.
end;
//
procedure TForm1.Button1Click(Sender: TObject);
var
f: TextFile; //
fName: String[80]; //
buf: String[80]; // y
begin
fName := Edit1.Text;
AssignFile(f, fName);
Try
Reset (f); //
Except
on EInOutError Do
begin
ShowMessage(' y y '+ fName);
exit;
end;
end;
//
While Not EOF(f) Do
begin
readln(f, buf); // y
Memo1.Lines.Add(buf); // y Memo1
end;
CloseFile(f); //
end;
//
procedure TForm1.Button2Click(Sender: TObject);
var
f: TextFile; //
fName: String[80]; //
i: integer;
begin
fName := Edit1.Text;
AssignFile (f, fName);
Try
Rewrite(f); //
Except
on EInOutError Do
begin
ShowMessage(' y y '+ fName);
exit;

67
end;
end;
//
for i:=0 to Memo1.Lines.Count Do // Memo y y
writeln(f, Memo1.Lines[i]);
CloseFile(f); //
MessageDlg(' ', mtInformation,[mbOk],0);
end;
//
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
If Not CheckBox1.Checked
then begin
Memo1.ReadOnly := False; //
Button2.Visible := True // y
End
Else Begin
Memo1.ReadOnly := True; //
Button2.Visible := False; // y
end;
end;
End.
51. y,
Memo
-
- .
y-

.
y

- . 1.52.
Implementation
. 1.52.
{$R *.dfm)
//
procedure TForm1.Button1Click(Sender: TObject);
var
f: TextFiie; //
fName: String[80]; //
buf: String[80]; // y
begin
If Not OpenDialogl.Execute
then { }
exit;
//
fName := OpenDialog1.FileName;
Form1.Caption := fName;
AssignFile(f, fName);
Try
Reset(f); //
Except
on EInOutError Do
begin
ShowMessage(' y y '+ fName);
exit;
end;
end;
//
While Not EOF(f) Do

68
begin

readln(f, buf) ; // y
Memo1.Lines.Add(buf); // y Memo1

end;
CloseFile (f) ; //
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
OpenDialog1.Filter := ' '*.txt|*.txt'; //
end;
End.
52. y,
y "", y
,
y.
y

MonthCalendar.

yy,

.
y

. 1.53.

Implementation
{$R *.dfm}
Const
DBNAME = 'pogoda.txt';
. 1.53. ""
var db: TextFile; //
// . .
procedure TForm1.FormCreate(Sender: TObject);
var
r: integer; //
begin
AssignFile(db,DBNAME);
Try
Append(db); //
Except
on E: EInOutError Do
begin
r := MessageDlg(' (pogoda.txt) +' .' + #13 + ' ?',
mtWarning, [mbOk,mbCancel],0);
If r = mrOK
then begin
Rewrite(db); // y
ShowMessage(' !');
End
else Application.Terminate; // y
end;
end;
Edit1.Enabled := True;
Button1.Enabled := True;
end;
// y
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
case Key of
' 0 ' . . ' 9', #8 :; // <Backspace>
#13: // <Enter>
If Length(Edit1.Text) <> 0 then Button1.SetFocus;
',','.': //
begin Key:= DecimalSeparator;
If Pos(DecimalSeparator,Edit1.Text) <> 0
then Key :=Char(0);
end;

69
'-': If Length(Edit1.Text) <> 0 then Key:=Char(0);
else Key:= Char(0); //
end;

end;
//
procedure TForm1.Button1Click(Sender: TObject);
begin
If Length(Edit1.Text) = 0
then ShowMessage(' yy. ')
else begin
writeln(db,FormatDateTime('dd/mm/yy', MonthCalendarl.Date),
' ',Edit1.Text);
Edit1.Text :=
end;
end;
//
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CloseFile(db); //
end;
End.
53. y, y
. y . 1.54.
y
(. 1.55).
// y
// y y y Find.
Unit FindFile_;
interface
Uses Windows, Messages, SysUtils, Variants, Classes, Graphics,
Dialogs, StdCtrls, FileCtrl;
Type
Tform1 = class(TForm)
Edit1: TEdit; //
Edit2: TEdit; //
Memo1: TMemo; // y
Button1: TButton; //
Button2: TButton; //
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
Var
FileName: string; //
cDir: string;
n: integer; // - , y y
// y
procedure Find;

Controls,

Forms,

70
var
SearchRec: TSearchRec; //
begin
GetDir(0, cDir); // y y
If cDir [length (cDir) ] <> '\' then cDir := cDir+'\';
If FindFirst(FileName, faAnyFile,SearchRec) = 0
then
Repeat
If (SearchRec.Attr And faAnyFile) = SearchRec.Attr
then begin
Form1.Memo1.Lines.Add(cDir + SearchRec.Name)
n := n + 1;
end;
Until FindNext(SearchRec) <> 0;
{ y . ,
faAnyFile faDirectory. ,
SearchRec.Attr faDirectory (16), Program Files
faDirectory+faReadOnly (1 7) , Windows faDirectory+faSysFile (20) }
If FindFirst (`*`, faAnyFile, SearchRec) = 0
then
Repeat
If (SearchRec.Attr And faDirectory) = faDirectory
then
// '.. ' '. ' , !!!
If SearchRec.Name[i] <> '.'
Then begin
ChDir(SearchRec.Name); //
Find; //
ChDir('..');//
end;
Until FindNext(SearchRec) <> 0;
end;
//
procedure TForm1.Button1Click(Sender: TObject);
begin
If Not DirectoryExists(Edit2.Text)
Then begin
ShowMessage(' y .');
Edit2.SetFocus;
exit;
end;
Button1.Enabled := False;
Label4.Caption := '';
Label4.Repaint;
Memo1.Clear; // Memo1
Label4.Caption := '';
FileName := Edit1.Text; //
cDir := Edit2.Text; //
n:=0; // -
ChDir(cDir); //
Find; //
If n = 0
Then ShowMessage(', y ' + ' .')
else Label4.Caption := ' :' + IntToStr(n);
Button1.Enabled := True;
end;
// ,
function GetPath(mes: string):string;
var
Root: string; //
pwRoot : PWideChar;
Dir: string;
Begin

71
Root : = ''; //
GetMemfpwRoot, (Length(Root)+1) * 2);
pwRoot := StringToWideChar(Root,pwRoot,MAX_PATH*2);
If SelectDirectory(mes, pwRoot, Dir)
then
If length(Dir) =2 //
then GetPath := Dir+'\'
else GetPath := Dir
else
GetPath := '';
end;
//
procedure TForral.Button2Click(Sender: TObject);
var
Path: string;
Begin
Path := GetPath(' y');
If Path <>''
then Edit2.Text := Path;
end;
End.

72


54. y " "15"". "15". .
y 15 , 1 15.
4x4, , y .
(. 1.56). , ,
, (. 1.57).
y " "15"". . 1.58 .

. 1.56.

. 1.57.

. 1.58. 15

Unit gamel5_;
interface
Uses Windows, Messages, SysUtils, Variants, Classes,Graphics, Controls, Forms,
Dialogs;
Type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
procedure FormPaint(Sender: TObject);
// yy
procedure ShowPole;
procedure Mixer;
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;

73
implementation
{$R *.dfm}
Const H = 4; W = 4; // 4x4
CH = 64; CW = 64; // - 16x16
Var
ex,ey: integer; // y
stp : array[1..H, 1..W] of byte =//
[( 1, 2, 3, 4),
( 5, 6, 7, 8),
( 9,10,11,12),
(13,14,15, 0)];
pole: array[1..H, 1..W] of byte; //
//
procedure NewGame;
var
i,j: integer;
begin
// ()
for i:=0 to H+1 Do for j:=0 to W+1 Do pole[i,j] := stp[i,j];
Form1.Mixer; //
Form1.ShowPole; //
end;
// , y
function Finish: boolean;
var
row,col: integer; i: integer;
begin
row :=1; col :=1; Finish := True; // y y
for i:=1 to 15 Do
begin
If pole[row,col] <> i
then begin
Finish:= False; break;
end;
If col < 4 // y
then inc(col)
else begin
col :=1; inc(row);
end;
end;
end;
// "" y yy y, ,
procedure Move(cx,y: integer);
,y ,
Var
r: integer; //
begin
// ,
If Not (( abs(cx-ex) = 1) And (cy-ey = 0) or ( abs(cy-ey) = 1) And (cx-ex = 0))
then exit;
// . y ,y ,y
l[y,] := Pole[y,];
Pole[y,] := 0; :=;
y:=y;
Form1. ShowPole ; //
If Finish
then begin
r := MessageDlg(' y!'+ #13
+' ? ',mtInformation,[mbYes,mbNo],0);
If r = mrNo then Form1.Close; // y
end;
end;
//
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift:
ShiftState; X, Y: Integer);
Var
cx,cy: integer; //
begin
// y

74
Cx := Trunc(X / CW) + 1;
y := Trunc(y / ) + 1;
Move(cx,y);
end;
//
procedure TForm1.ShowPole;
var
i,j: integer;
x,y: integer; // x,y
begin
// :
for i:= 1 to H- 1 Do
begin
Canvas.MoveTo(i*CW,0);
Canvas.LineTo(i*CW,ClientHeight) ;
end;
// :
for i:= 1 to H- 1 Do
begin
Canvas.MoveTo(0,i*CH);
Canvas.LineTo(ClientWidth, i*CH) ;
end;
// x,y
for i:= 1 to H Do
begin
y:=(i-1)*CH + 15;
for j:=1 to W Do
begin
x:= (j-1)*CK + 15;
case Pole[i,j] of
0
: Canvas.TextOut(x,y,' ');
1..9 : Canvas.TextOut(x,y,' '+IntToStr(Pole[i,j])+' ');
10..15: Canvas.TextOut(x,y,IntToStr(Pole[i,j])
end;
end;
end;
end;
// ""
procedure TForm1.Mixer;
var
x1,y1: integer; // y
x2,y2: integer; // y yy
d: integer; // , y
i: integer;
begin
x1:=4;
y1:=4;
randomize;
for i:= 1 to 150 Do
begin
Repeat
x2:=x1;
y2:=y1;
d:=random(4)+ 1;
case d of
1 : dec(x2);
2 : inc(x2);
3 : dec(y2);
4 : inc(y2);
end;
Until (x2>=l) And (x2<=4) And (y2>=l) And (y2<=4);
// y, y yy y
Pole[y1,x1] := l[y2,2]; l[y2,2] := 0;
x1:=x2;
Y1:=y2;
end;
// y
:= x1;
y:= y1;
end;

75
// OnCreate
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientWidth := CW * W;
ClientHeight := CH * H;
Canvas.Font.Name := 'Times New Roman';
Canvas.Font.Size := 22;
NewGame;
end;
// OnPaint
procedure TForm1.FormPaint(Sender: TObject);
begin
Form1.ShowPole;
end;
End.
55. y " y" "15", y
, . " y" "15"
( ). y
pic_l.bmp,
(. 1.59).

. 1.59. y

76

Unit soberi_;
interface
Uses Windows, Messages, SysUtils, Variants, Classes,Graphics, Controls, Forms,
Dialogs;
Type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
procedure FormPaint(Sender: TObject);
// yy
rocedure ShowPole;
procedure Mixer;
procedure NewGame;
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
Const H = 4; W = 4; // - 4x4
Var
we,he: integer; //
pole: array[1..H, 1..W] of byte; //
ex,ey: integer; // y
pic: TBitmap; //
stp : array[1..H, 1..W] of byte =
(( 1, 2, 3, 4),
( 5, 6, 7, 8),
( 9,10,11,12),
(13,14,15, 0));
//
procedure Tform1 .NewGame;
var
fname: string[20]; //
i,j: integer;
begin
{ y, , , y
y }
fname := 'pic_1.bmp';
try
pic.LoadFromFile(fname);
except
on EFopenError Do
begin
ShowMessage(' y ' + fname)
Form1.Close;
end;
end;
// y , y
he := Pic.Height div H;
we := Pic.Width div W;
//
ClientWidth := we * W;
ClientHeight := he * H;
// ()
for i:=1 to H Do
for j:=1 to W Do pole[i,j] := stp[i,j];
Form1.Mixer; //
Form1.ShowPole; //
end;

77
// , ( ) y
function Finish: boolean;
var
row,col: integer;
i: integer;
begin
row :=1;
col :=1;
Finish := True; // y y
for i:=l to 15 Do
begin
If pole[row,col] <> i
Then begin
Finish:= False;
break;
end;
// y
If col < 4
then inc(col)
else begin
col :=1;
inc(row);
end;
end;
end;
// "" y yy y, ,
procedure Move(cx,y: integer);
// ,y - ,
Var
r: integer; //
begin
// ,
If Not (( abs(cx-ex) = 1) And (cy-ey = 0) or ( abs(cy-ey) = 1) And (cx-ex = 0))
then exit;
// . y ,y ,y
Pole[ey,ex] := Pole[y,];
Pole[y,] := 0;
:=;
y:=y;
//
Form1.ShowPole;
If Finish
Then begin
pole[4,4] := 16;
Form1.ShowPole;
r : = MessageDlg(' y!'+#13
+ ' ?' ,mtInformation, [mbYes,mbNo], 0);
If r = mrNo then Form1.Close; // y
Form1.NewGame;
end;
end;
//
Procedure
TForm1.FormMouseDown(Sender:
TObject;
Button:
TMouseButton;
Shift:
TShiftState; X, Y: Integer);
var cx,cy: integer; //
begin
// y
:= Trunc(X / we) + 1;
y := Trunc(Y / he) + 1;
Move(cx,y);
end;
//
procedure TForm1.ShowPole;
var
Source, Dest: TRect; // :

78
sx,sy: integer; // y -
,j: integer;
begin
//
for i := 1 to W Do
for j := 1 to H Do
begin
// y
// y -
sy := ((pole[i,j] -1) div W) * he;
sx := ((pole[i,j] -1) mod W) * we;
Source := Bounds(sx,sy,we,he);
Dest := Bounds ((j-1) *wc, (i-1) *hc,wc,hc) ;
If pole[i,j] <> 0
then Canvas.CopyRect(Dest,pic.Canvas,Source)
else Canvas.Rectangle)(j-1)*wc, (i-1)*hc, j*wc, i*hc);
end;
end;
// ""
procedure TForm1.Mixer;
var
x1,y1: integer; // y
x2,y2: integer; // y yy
d: integer; .
// , y
i: integer;
begin
x1:=4; y1:=4; // . stp
randomize;
for i:= 1 to 150 Do // -
begin
Repeat
x2:=x1;
y2:=y1;
d:=random(4)+1;
case d of
1: dec(x2);
2: inc(x2);
3: dec(y2);
4: inc(y2);
end;
Until (x2>=1) And (x2<=4) And (y2>=1) And (y2<=4);
// y, y yy y
Pole[y1,x1] := l[y2,2];
l[y2,2] := 0;
x1:=x2;
Y1:=y2;
end;
// y
:= x1;
y:= y1;
end;
// OnCreate
procedure TForm1.FormCreate(Sender: TObject);
begin
pic := TBitMap.Create;
NewGame;
end;
// OnPaint
procedure TForm1.FormPaint(Sender: TObject);
begin
Form1.ShowPole;
end;
End.

56.

79

y,
y
y

(y)

.
, y
y. , y
, , ,
y. y:
- , y
. . 1.60.

Implementation
. 1.60.
{$R *.dfm}
Const = 5; // (- )
LT = 10; // ( )
Var
numb: integer; // , y
right: integer; //
n: integer; //
// y
function GetNumb(k: integer) : integer;
var
n: integer; // y
i: integer;
begin
// y y
n:= Random(9).+1; // y
for i := 1 to (k-1) Do n := n*10 + Random(10);
GetNumb := n;
end;
//
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Visible := False; // Edit1
Edit1.MaxLength := ; // - ,
Label1.Wordwrap : = True; // yy y
Label1.Caption := ' yy . ' +
' , y '+ ' <Enter>'; .
Button1.Caption := '';
Timer1.Enabled := False; //
Timer1.Interval := 1000; // 1 y
right := 0; // -
n := 0; //
Randomize; //
end;
// "/"
procedure TForm1.Button1Click(Sender: TObject);
begin
If Button1.Caption = '' then Form1.Close; //
If Button1.Caption = ''
Then begin
Button1.Caption := '';
Button1.Visible := False; // y
// Button1 y ,
Label1.Caption : = '';
Label1.Font.Size := 24; // Label1
Edit1.Font.Size : = 24; // Edit1
//
numb := GetNumb(KC);
Label1.Caption := IntToStr(numb);
Timer1.Enabled := True; // y
// y ""
end;

80
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False; //
Label1.Visible := False; //
Edit1.Visible := True; // y Edit1
Edit1.SetFocus; // y y Edit1
end;
// Edit1
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
igrok: integer; // , y
begin
case Key of
0'..'9',#8: ; // "0"-"9", <Backspace>
#13: // <Enter>
Begin
igrok := StrToInt(Edit1.Text) ;
If (igrok = numb) then right := right + 1;
n := n + 1; //
Edit1.Text := '';
Edit1.Visible := False; // Edit1
If n < LT
Then begin
numb := GetNumb(KC); // y
Label1.Caption := IntToStr(numb); //
Label1.Visible := True;
Timer1.Enabled := True; // y
End
else begin //
// y
Label1.Font.Size := 10;
Label1.Caption:= 'y:1 + #13 +' : '
+ IntToStr(LT)+#13 + ': ' + IntToStr(right);
Label1.Visible := True;
Button1.Visible := True; // y
end;
end;
else Key := Chr(0);
end;
end;
End.

81
57.

y, y y
(y) . , y
y. , y
,
,
,

y.

"y".
, , . . 10.
y y (y ) ,
, , ,
.
y y:
, y .

58.

y, yy y " ". "


" . . ,
. , . .
, .
"". "" y,
. y,
, . y y
y (. 1.61). ,
"". .
yy. y ,
y,
, y . ,
("") . ? y .

(. 1.62). y "y"
( )
: y y ,
, y y
. " " . 1.63.

Unit dblpic_;
interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, jpeg, ExtCtrls, Menus;
Type
TForm1 = class (TForm)
Timer1: TTimer;
MainMenu1: TMainMenu;
H1 TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
procedure Timer1Timer(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }

82

. 1.61.

. 1.62.

end;
col_row = record// col_row
col: integer;
row: integer;
end;
Const MAX_SIZE = 32; // -
_ = 8; // 8x8
MAX_W = 8;
Var
Form1: TForm1;
Pole: array [1..MAX_H,1..MAX_W] of integer;
{Pole[i,j] < 100 , ; Pole[i,j) > 100 < 200 -
, y; Pole[i,j) > 200 y )
Pictures: TBitmap; // , y
n: integer; .// -
count: integer; // -
open1: col_row; // 1-
open2: col_row; // 2-
W: integer; // -
: integer; // -
// W y
WK: integer; //
: integer; //
Implementation
(SR *.dfm}
// y y
procedure Kletka(col,row: integer);
var
x,y: integer; // y ()

83
src, dst : Trect; // y
begin
// y
: = (col-1)*WK;
y := (row-1)*HK;

. 1.63.

If Pole[col,row] > 200 // y y


then Begin
// y ,
Form1.Canvas.Brush.Color := clBtnFace;
Form1.Canvas.Pen.Color := clBtnFace;
Form1.Canvas.Font.Color : = clBtnFace;
end;
If (Pole[col,row] > 100) And (Pole[col,row] < 200)
then Begin // y
// Pole[col,row] = + 100, 100 ,
// Pictures
src := Bounds((Pole[col,row]-100 -1)*WK,0,WK,HK);
// ()
dst := Bounds(,y,HK-2,WK-2) ;
// y y
Form1.Canvas.CopyRect(dst,Pictures.Canvas,src) ;
// y
Form1.Canvas.Pen.Color := clBlack;
Form1.Canvas.Font.Color := clBlack;
Form1.Canvas.Brush.Style := bsClear;
end;
If (Pole[col,row] > 0) And (Pole[col,row] < 100)
then Begin// , y y

84
Form1.Canvas.Brush.Color := clBtnFace;
Form1.Canvas.Pen.Color := clBlack;
Form1.Canvas.Font.Color := clBtnFace;
end;
// y
Form1.Canvas.Rectangle(x,y,x+WK-2,y+HK-2);
//Form1. Canvas. TextOut (x+15,y+15, IntToStr (Pole [col, row]));
Form1.Canvas.Brush.Color := clBtnFace;
end;
//
procedure ShowPole;
var row,col: integer;
begin
for row: =1 to H Do
for col:=1 to W Do Kletka(row,col);
end;
//
Procedure NewGame;
Var
k: integer; // - ,
r: integer; // y
buf: array[1..MAX_SIZE] of integer;
// buf[i] , i Pole
i,j: integer; //
begin
Randomize;
k := Trunc(H*W/2);
for i:=l to k Do buf[i] := 0;
// Pole y 1 2
//
for i:=1 to H Do
for j:=1 to W Do
begin
Repeat
r := random (k) + 1;
Until buf[r] < 2;
Pole[i,j] := r; //
inc(buf [i] ) ;
end;
//
n:=0;
ShowPole;
end;
//
procedure TForm1.FormCreate(Sender: TObject);
var
np: integer; // -
begin
Pictures := TBitmap.Create;
Pictures.LoadFromFile('pictures.bmp'); // y
HK := Pictures.Height-1; //
WK := HK; //
np:= Round(Pictures.Width / WK);
If np <= 15 then H := 4 else H := 5;
W := Round(np*2/H);
// y
Form1.ClientHeight := H * HK;
Form1.ClientWidth := W * WK;
Form1.Timer1.Enabled := False;
Form1.Timer1.Interval := 200;
n := 0;
NewGame;
end;
//

85
procedure TForm1.FormPaint(Sender: TObject);
begin
ShowPole;
end;
//
procedure
TForm1.FormMouseDown(Sender:
TObject;
Button:
TMouseButton;
Shift:
TShiftState; X, Y: Integer);
Var
col_: integer; //
row_: integer; //
begin
col_ := Trunc(X/WK) + 1;
row_ := Trunc(Y/HK) + 1;
// y y
If Pole[col_,row_] > 200 then exit;
//
If count = 0
Then begin
count : = 1;
open1.col := col_;
open1. row : = row_;
//
Pole[open1.col,open1.row] := Pole[open1.col,open1.row] + 100;
Kletka(open1.col,open1.row);
exit;
end;
// , y
If count = 1
then begin
open2.col := col_;
open2.row := row_;
// ,
//
If (open1.col = open2.col) And (open1.row = open2.row)
then exit
else begin
count := 2; //
Pole[open2.col, open2.row] :=
Pole[open2.col, open2.row] + 100;
Kletka(open2.col, open2.row); // y y y
// , ?
If Pole[open1.col,open1.row] = Pole[open2.col,open2.row]
//
then Begin
n := n+1;
Form1.Timer1.Enabled := True; // y
// y OnTimer
// ""
end;
end;
exit
end;
If count = 2
Then begin
// 2 y,
//
Pole[open1.col,open1.row] := Pole[open1.col,open1.row] 100;
Pole[open2.col,open2.row] := Pole[open2.col,open2.row] 100;
Kletka(open1.col,open1.row);
Kletka(open2.col,open2.row);
// open1 y
open1.col := col_;

86
open1.row := row_;
count := 1; //
// yy y
Pole[open1.col,open1.row] := Pole[open1.col,open1.row] + 100;
Kletka(open1.col,open1.row) ;
end;
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
begin
// Pole
Pole[open1.col,open1.row] := Pole[open1.col,open1.row] + 100;
Pole[open2.col,open2.row] := Pole[open2.col,open2.row] + 100;
count := 0;
//
Kletka(open2.col,open2.row) ;
Kletka(open1.col,open1.row);
//
Form1.Timer1.Enabled := False;
If n = Trunc(W*H/2)
then begin//
Form1.Canvas.Font.Name := 'Times New Roman';
Form1.Canvas.Font.Size := 36;
Form1.Canvas.Font.Color := clBlack;
Form1.Canvas.TextOut(70,160,'Game Over!') ;
Form1.Canvas.Font.Size := 10;
Form1.Canvas.TextOut(120,210,'(c) Victoria LTD 2008');
end;
end;
//
procedure TForm1.N1Click(Sender: TObject);
begin
Canvas.Rectangle(0,0, ClientWidth, ClientHeight);
NewGame;
end;
End.
59.

y, yy y "".
Windows "" .
. , .
. y ,
y , y ,
. ,
. , y , ,
( , , , )
(' 1.64). ,
, y y , . y
, y ,
y . ,
, . ()
y , .
y y, y ,
. y, yy y "".
. 1.65.

87

. 1.64. ( )

.1.65.

// y
Unit saper_1;
interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Menus,
StdCtrls, OleCtrls;
Type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
procedure Form1Create(Sender: TObject);
procedure Form1Paint(Sender: TObject);
procedure Form1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
procedure NIClick(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N3Click(Sender: TObject);

88
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
implementation
Uses saper_2;
{$R *.DFM}
Const MR = 10; // -
= 10; // -
NM = 10; // -
W = 40; //
= 40; //
Var
Pole: array[0..MR+1, 0.. MC+1] of integer; //
// :
// 0..8
// 9
// 100..109
// 200..209 y
nMin : integer; // -
nFlag : integer; // -
status : integer; // 0 ; 1 ; 2 y
Procedure NewGame(); forward; // y
Procedure ShowPole(Canvas : TCanvas; status:integer); forward; //
//
Procedure Kletka(Canvas: TCanvas; row,col,status :integer);forward;
// yy ,
Procedure Open( row, col : integer); forward; // y y
Procedure Mina(Canvas : TCanvas; x, y : integer); forward; // y
Procedure Flag( Canvas : TCanvas; x, y : integer); forward;
//
Procedure Kletka(Canvas : TCanvas; row,col,status : integer);
Var
x,y : integer; //
begin
x := (col-1)* W + 1;
y := (row-1)* H + 1;
If status = 0
Then begin
Canvas.Brush.Color := clLtGray;
Canvas.Rectangle(x-1,y-1,x+W,y+H);
exit;
end;
If Pole[row,col] < 100
Then begin
//
Canvas.Brush.Color : = clLtGray;
Canvas.Rectangle(x-1,y-1,x+W,y+H);
// (status = 2),
If (status = 2) And (Pole[row,col] = 9) then Mina(Canvas, x, y);
exit;
end;
// y
Canvas.Brush.Color := clWhite; //
Canvas.Rectangle(x-1,y-1,x+W,y+H);
If ( Pole[row,col] = 100)
then exit; // , y
If (Pole[row,col] >= 101) And (Pole[row,col] <= 108)
Then begin
Canvas.Font.Size := 14;
Canvas.Font.Color := clBlue;
Canvas.TextOut (x+3, y+2, IntToStr(Pole[row,col] - 100));
exit;
end;
If ( Pole[row,col] >= 200) then Flag(Canvas, x, y);

89
If (Pole[row,col] = 109) // !
then Begin
Canvas.Brush.Color := clRed;
Canvas.Rectangle(x-1,y-l,x+W,y+H) ;
end;
If ( (Pole[row,col] mod 10) = 9) And (status = 2) then Mina(Canvas, x, y);
end;
//
Procedure ShowPole(Canvas : TCanvas; status : integer);
Var
row,col : integer;
begin
for row := 1 to MR Do
for col := 1 to MC Do
Kletka(Canvas, row, col, status);
end;
// y y yy ,
Procedure Open( row, col : integer);
Begin
If Pole[row,col] = 0
Then begin
Pole[row,col] := 100;
Kletka(Form1.Canvas, row,col, 1);
Open(row,col-1);
Open(row-1,col);
Open(row,col+1);
Open(row+1,col);
//
Open(row-1,col-1);
Open(row-1,col+1);
Open(row+1,col-1);
Open(row+1,col+1);
End
Else
If (Pole[row,col]<100)and(Pole[row,col]<>-3)
Then begin
Pole[row,col] := Pole[row,col] + 100;
Kletka(Form1.Canvas, row, col, 1) ;
end;
end;
// y
procedure NewGame();
var
row,col : integer; //
n : integer; // -
k : integer; // -
begin
// - , y .
for row :=1 to MR Do
for col :=1 to MC Do
Pole[row,col] := 0;
//
Randomized; //
n := 0; // -
Repeat
row := Random(MR) + 1;
col := Random(MC) + 1;
If ( Pole[row,col] <> 9)
Then begin
Pole[row,col] := 9;
n := n+1;
end;
Until ( n = NM);
// -

90
for row := 1 to MR Do
for col := 1 to MC Do
If ( Pole[row,col] <> 9)
Then begin
:=0;
If Pole[row-1,col-1] = 9 then := + 1;
If Pole[row-1,col]
= 9 then := + 1;
If Pole[row-l,col+1] = 9 then := + 1;
If Pole[row, col-1] = 9 then := + 1;
If Pole[row, col+1] = 9 then := + 1;
If Pole[row+1,col-1] = 9 then := + 1;
If Pole[row+1,col]
= 9 then := + 1;
If Pole[row+1,col+1] = 9 then := + 1;
Pole[row,col] := k;
end;
status := 0; //
nMin := 0; // y
nFlag := 0; //
end;
// y y
Procedure Mina(Canvas : TCanvas; x, y : integer);
Begin
With Canvas Do
begin
Brush.Color := clGreen;
Pen.Color := clBlack;
Rectangle(x+16,y+26,x+24,y+30);
Rectangle(x+8,y+30,x+l6,y+34);
Rectangle(x+24, y+30, x+*32, y+34 );
Pie(x+6,y+28,x+34,y+44,x+34,y+36,x+6,y+36);
MoveTo(x+12,y+32); LineTo(x+2 6,y+32);
MoveTo(x+8,y+36); LineTo(x+32,y+36);
MoveTo(x+20,y+22); LineTo(x+20,y+26);
MoveTo(x+8, y+30); LineTo(x+6,y+28);
MoveTo(x+32,y+30); LineTo(x+34,y+28);
end;
end;
// y
Procedure Flag( Canvas : TCanvas; x, y : integer);
Var
p : array [0..3] of TPoint; //
m : array [0..4] of TPoint; // y
begin
//
[0].:=+4; [0].y:=y+4;
[1].:=+30; [1].y:=y+12;
[2].:=+4; [2].y:=y+20;
[3].:=+4; [3].y:=y+36;
//
m[0].x:=x+8; m[0].y:=y+14;
m[1].x:=x+8; m[1].y:=y+8;
m[2].x:=x+10; m[2].y:=y+10;
m[3].x:=x+12; m[3].y:=y+8;
m[4].x:=x+12; m[4].y:=y+14;
With Canvas Do
begin
// y
Brush.Color := clRed; Pen.Color := clRed;
Polygon(p); //
//
Pen.Color := clBlack;
MoveTo(p[0].x, p[0] .y) ;
LineTo(p[3].x, p[3] .y) ;

91
// y
Pen.Color := clWhite;
PolyLine(m);
Pen.Color := clBlack;
end;
end;
// ?
procedure TForm1.N4Click(Sender: TObject);
begin
AboutForm.Top := Trunc(Form1.Top + Form1.Height/2 - AboutForm.Height/2);
AboutForm.Left := Trunc(Form1.Left +Form1.Width/2 - AboutForm.Width/2);
About Form.ShowModal;
end;
procedure TForm1.Form1Create(Sender: TObject);
var
row,col : integer;
begin
// - , y
// , -3.
// y y Open
// y y .
for row :=0 to MR+1 Do
for col :=0 to MC+1 Do
Pole[row,col] := -3;
NewGame(); // ""
Form1.ClientHeight := H*MR + 1;
Form1.ClientWidth := W*MC + 1;
end;
//
procedure
TForm1.Form1MouseDown(Sender:
TObject;
Button:
TMouseButton;
Shift:
TShiftState; X, Y: Integer);
Var
row, col : integer;
begin
If status = 2 then exit;//
If status = 0 then status := 1;//
// y
row := Trunc(y/H) + 1; col := Trunc(x/W) + 1;
If Button = rabLeft
Then begin
If Pole[row,col] = 9
Then begin // ,
Pole[row,col] := Pole[row,col] + 100;
status := 2; //
ShowPole(Form1.Canvas, status);
End
else If Pole[row,col] < 9 then Open(row,col);
End
Else If Button = mbRight
then
If Pole[row,col] > 200
Then begin
// y y
nFlag := nFlag 1;
Pole[row,col] := Pole[row,col] 200;
x := (col-1)* W + 1;
y := (row-1)* H + 1;
Canvas.Brush.Color := clLtGray;
Canvas.Rectangle(x-1,y-1,x+W,y+H);
End
Else begin // y
nFlag := nFlag + 1;
If Pole[row,col] = 9 then nMin := nMin + 1;

92
Pole[row,col] : = Pole[row,col]+ 200;
If (nMin = MM) And (nFlag = bJM)
Then begin
status := 2; //
ShowPole(Form1.Canvas, status);
End
else Kletka(Form1.Canvas, row, col, status);

end;
end;
//
procedure TForm1.N1Click(Sender: TObject);
begin
NewGame();
ShowPole(Form1.Canvas,status) ;
end;
// ?
procedure TForm1.N3Click(Sender: TObject);
begin
// y
Winhelp(Form1.Handle,'saper.hlp',HELP_CONTEXT,1);
end;
// OnPaint
procedure TForm1.Form1Paint(Sender: TObject);
begin
//
ShowPole(Form1.Canvas, status);
end;
End.

// y
Unit saper_2;
interface
Uses Windows, Messages, SysUtils, Classes, Graphics,
StdCtrls, saper_1;
Type
TAboutForm = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var
AboutForm: TAboutForm;
Implementation
{$R *.DFM}
procedure TAboutForm.Button1Click(Sender: TObject);
begin
ModalResult := mrOk;
end;
End.

Controls,

Forms,

Dialogs,

93
60. y "y". . 1.66.
y ,
, y . y

y .
{ y. y . }
Unit Alarm2_1_;
interface
Uses Windows, Messages, SysUtils, Variants,
. 1.66.
Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ComCtrls, DateUtils;
Type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
UpDown1: TUpDown;
Label5: TLabel;
UpDown2: TUpDown;
Shape1: TShape;
Label7: TLabel;
Button1: TButton;
Shape2: TShape;
Label8: TLabel;
Edit1: TEdit;
Label6: TLabel;
Label9: TLabel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure UpDoun1Click(Sender: TObject; Button: TUDBtnType);
procedure UpDown2Click(Sender: TObject; Button: TUDBtnType);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
Public
{Public declarations }
end;
var Form1: TForm1;
implementation
Uses Alarm2_2_;
{$R *.dfm)
Var
Hour,Min: word; //
AlHour, AlMin: word; // y y AlHour:AlMin
//
procedure TForm1.FormCreate(Sender: TObject);
begin
Hour := HourOf(Now);
Min := MinuteOf(Now);
Label1.Caption := IntToStr(Hour);
If Min < 10
then Label2.Caption := '0'+IntToStr(Min)
else Label2.Caption := IntToStr(Min);
end;
//
procedure TForm1.Timer1Tiraer(Sender: TObject);
var
cHour,cMin: word;
begin
// y y
cHour := HourOf(Now);

94
cMin := MinuteOf(Now);
If Timer1.Tag = 0 //
then begin
{ , y }
If cHour <> Hour
Then begin
Hour := cHour;
Label1.Caption := IntToStr(Hour);
end;
If cMin <> Min
Then begin
Min := cMin;
If min <10
then Label2.Caption := '0' + IntToStr(Min)
else Label2.Caption := IntToStr(Min);
end;
If Label3.Visible
//
then Label3.Visible := False
else Iabel3.Visible := True;
end
else // , y y
If (cHour = AlHour) And (cMin = AlMin)
// !
then begin
Form2.Show;
Timer1.Tag := 0;
Timer1.Interval := 1000;
end;
end;
// UpDoun1 y
procedure TForm1.UpDoun1Click(Sender: TObject; Button: TUDBtnType);
begin
If UpDoun1.Position < 10
then Label4.Caption := '0' + IntToStr(UpDoun1.Position)
else Label4.Caption := IntToStr(UpDoun1.Position);
end;
// UpDown2 y - y
procedure TForm1.UpDown2Click(Sender: TObject; Button: TUDBtnType);
begin
If UpDown2.Position < 10
then Label5.Caption := '0' + IntToStr(UpDown2.Position)
else Label5.Caption := IntToStr(UpDown2.Position);
end;
// OK
procedure TForm1.Button1Click(Sender: TObject);
begin
// y y
AlHour := UpDoun1.Position;
AlMin := UpDown2.Position;
Timer1.Tag := 1;
Form1.Hide;
Timer1.Interval := 3000; // y
end;
End.
{ y. y . }
Unit Alarm2_2_;
interface
Uses Windows, Messages, SysUtils, Variants, Classes,
Dialogs, StdCtrls, MMSYSTEM, // y PlaySound
Alarm2_1 _; // y

Graphics,

Controls,

Forms,

95
Type
TForm2 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
Form2.Hide; //
Form1.Show; // y
end;
procedure TForm2.FormActivate(Sender: TObject);
begin
Label1.Caption := Form1 .Edit1 .Text; //
PlaySound('tada.wav',0,SND_ASYNC); // y
end;
End.
61. y "y". . 1.67.
y ,
y ,
(. 1.68). y
. y .
. 1.68. y
. 1.67. y
Unit Alarm_;
interface
Uses Windows, Messages, SysUtils, Variants, Classes,Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls,ShellAPI, // y Shell_NotifyIcon
DateUtils, MPlayer;
Type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
UpDoun1: TUpDown;
Label5: TLabel;
UpDown2: TUpDown;
Label6: TLabel;
Shape1: TShape;
Label7: TLabel;
Button1: TButton;
Shape2: TShape;
Label8: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TimerITimer(Sender: TObject);
procedure UpDoun1Click(Sender: TObject; Button: TUDBtnType);
procedure UpDown2Click(Sender: TObject; Button: TUDBtnType);

96
procedure Button1Click(Sender: TObject);
// **** yy
procedure CreateTrayIcon(n: integer; Tip: String);
procedure DeleteTrayIcon(n: integer);
procedure SetSound;
// ******************************************
Private
{ Private declarations }
Public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{ WAV-, Media,
. y, y y,
sound.wav, ,
.}
{$R *.dfm}
Var
Hour,Min: word; //
AlHour, AlMin: word; // y y AlHour:AXMin
MediaPlayer : TMediaPlayer;
// MediaPlayer y
//
procedure TForm1.FormCreate(Sender: TObject);
begin
Hour := HourOf(Now);
Min := MinuteOf(Now) ;
Label1.Caption := IntToStr(Hour) ;
If Min < 10
then Label2.Caption := '0'+IntToStr(Min)
else Label2.Caption := IntToStr(Min);
// CreateTrayIcon(1); // y System Tray
SetSound; // y WAV-
end;
//
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DeleteTrayIcon(1); // y y System Tray
end;
Const WM_MYTRAYNOTIFY = WM_USER + 123;
// y System Tray
procedure TForm1.CreateTrayIcon(n: integer; Tip: string);
var
nidata: TNotifyIconData;
begin
// yyy nidata, System Tray
With nidata Do
begin
cbSize : = SizeOf(TNotifyIconData);
Wnd := Self.Handle; // (),
uld := n;
// (
// )
uFlags := NIF_ICON or NIF_MESSAGE or NIFJHP; //
uCallBackMessage := WM_MYTRAYNOTIFY;
hIcon := Application.Icon.Handle;
//szTip := 'y';
StrPCopy(szTip,Tip); // y Ansi-y nul-terminated-y
end;
Shell_NotifyIcon(NIM_ADD, Snidata);
end;
// y y System Tray
procedure TForm1.DeleteTrayIcon(n: integer);

97
Var
nidata: TNotifyIconData;
begin
// yyy nidata, System Tray
With nidata Do
begin
cbsize := SizeOf(TNotifyIconData);
Wnd := Self.Handle; // (),
uld := n; // (
)
end;
Shell_NotifyIcon(NIM_DELETE, @nidata);
end;
//
procedure TForm1.Timer1Timer(Sender: TObject);
var
cHour,cMin: word;
begin
// y y
cHour := HourOf(Now);
cMin := MinuteOf(Now);
If Timer1.Tag = 0 //
then begin
{ , y }
If cHour <> Hour
Then begin
Hour := cHour;
Label1.Caption := IntToStr(Hour) ;
end;
If cMin <> Min
then begin
Min := cMin;
If min <10
then Label2.Caption := '0' + IntToStr(Min)
else Label2.Caption := IntToStr(Min);
end;
//
If Label3.Visible
then Label3.Visible := False
else Iabel3.Visible := True;
end
else // , y y
If (cHour = AlHour) And (cMin = AlMin)
// !
then begin
Form1.Show;
Timer1.Tag := 0;
Timer1.Interval := 1000;
Try
MediaPlayer.Play; // y
Except
on EMCIDeviceError Do;
end;
end;
end;
// UpDovml y
procedure TForm1.UpDoun1Click(Sender: TObject; Button: TUDBtnType);
begin
If UpDoun1.Position < 10
then Label4.Caption := '0' + IntToStr(UpDoun1.Position)
else Label4.Caption := IntToStr(UpDoun1.Position);
end;
// UpDown2 y y

98
procedure TForm1.UpDown2Click(Sender: TObject; Button: TUDBtnType);
begin
If UpDown2.Position < 10
then Label5.Caption := '0' + IntToStr(UpDown2.Position)
else Label5.Caption := IntToStr(UpDown2.Position);
end;
//
procedure TForm1.Button1Click(Sender: TObject);
begin
// y y
AlHour := UpDoun1.Position;
AlMin := UpDown2.Position;
Timer1.Tag := 1;
// y System Tray
CreateTrayIcon( 'y ' + Label4.Caption+':'+Label5.Caption);
Form1.Hide;
Timer1.Interval := 3000; // 3 y
end;
// y y
procedure TForm1.SetSound;
var
pWinDir: PChar; // y nul-terminated-y
sWinDir: String[80];
begin
// MediaPlayer
MediaPlayer := TMediaPlayer.Create(Form1) ;
MediaPlayer.ParentWindow := Form1.Handle;
MediaPlayer.Visible := False;
{ WAV- Media,
, y Windows? . y
Windows, y API-y GetWindowsDirectory. ,
API-y, nul-terminated-. y Windows}
GetMem(pWinDir,80); //
GetWindowsDirectory(pWinDir,80); // y Windows
sWinDir := pWindir; WAV-
If ParamStr(1) = ''
then MediaPlayer.FileName := 'Sound.wav'
else MediaPlayer.FileName := sWinDir + '\media\' + ParamStr(1);
Try
MediaPlayer.Open;
Except
on EMCIDeviceError Do;
end;
end;
End.
62. y

(.
1.69).


,
.
.

y
.
.
.
y 4- y . y

1.69.

99

,
y. y .
1 0. ,
. y , ,
.

. !
6
. .
5
. Y.
4
. !
3
y:
" "
0
" "
0
""
1
" "?

0
y
0
,
1
?

1
y
0

0
"y" :
, y
1
,
0
, y
0
"y-y" ?

0

0
(, )
1
y :

0
y

100
0
Implementation
($R *.dfm}
Var
f: TextFile; // ( )
nq: integer; //
right: integer; //
level: array[1..4] of integer; //
mes: array[1..4] of string; //
buf: string;
//
function NextQw : boolean;
begin
If Not EOF(f)
Then begin
//
Readln(f,buf);
Form1.Label1.Caption := buf;
// 1-
Readln(f,buf) ; // 1-
Form1.Label2.Caption : = buf;
Readln(f,buf); // : 1 , 0
Form1.RadioButton1.Tag := StrToInt(buf); // 2-
Readln(f,buf);
Form1.Label3.Caption := buf;
Readln(f,buf);
Form1.RadioButton2.Tag := StrToInt(buf); // 3-
Readln(f,buf);
Form1.Label4.Caption := buf;
Readln(f,buf);
Form1.RadioButton3.Tag:=StrToInt(buf);// -
nq: = nq + 1;
// y,
Form1.Button1.Enabled := False;
//
Form1.RadioButton1.Checked := False;
Form1.RadioButton2.Checked := False;
Form1.RadioButton3.Checked := False;
NextQw := TRUE;
End
else NextQw := FALSE;
end;
// FormCreate
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
fname : string;
begin
{ y Delphi, y
Parameters Run Parameters, y y
Run Parameters. }
fname := ParamStr(1); //
If fname = ''
Then begin
ShowMessage(' y '
+#13+ ' y .');
Application.Terminate; // y
end;
AssignFile(f,fname); // , y ...
Try
Reset(f); // y y
Except

101
on EInOutError Do
begin
ShowMessage(' y : ' + fname);
Application.Terminate; // y
end;
end;
// y
Readln(f,buf) ;
Form1.Caption := buf;
//
for i:=1 to 4 Do
begin
Readln(f,buf); mes[i]
:= buf;
Readln(f,buf); level[i] := StrToInt(buf);
end;
right := 0; //
nq := 0; //
NextQW; //
end;
//
procedure TForm1.Button1Click(Sender: TObject);
var
buf: string;
i: integer;
begin
If Button1.Caption = '' then Close;
// y Button.Tag
// Button.Tag = 1 , 0
If RadioButton1.Checked then right := right + RadioButton1.Tag;
If RadioButton2.Checked then right := right + RadioButton2.Tag;
If RadioButton3.Checked then right := right + RadioButton3.Tag;
// y NextQW NextQW = FALSE,
//
If Not NextQW
Then begin
// NextQW = FALSE
Button1.Caption := '';
//
RadioButton1.Visible := False;
RadioButton2.Visible := False;
RadioButton3.Visible := False;
Label2.Visible := False;
Label3.Visible := False;
Label4.Visible := False;
buf := ' . + #13 + ' : ' +
IntToStr(right) + ' ' + IntToStr(nq) + '.' + #13;
// y right -
i:=1; // y
While (right < level[i]) And (i < 4) Do inc(i);
buf := buf + mes[i];
Label1.AutoSize := TRUE;
Label1.Caption := buf;
end;
end;
//
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
Button1.Enabled := True; // y
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
Button1.Enabled := True;

102
end;
procedure TForm1.RadioButton3Click(Sender: TObject);
begin
Button1.Enabled := True;
end;
End.
63.


,
y
y y
4.
. 1.70.

,

y yy .

y :

.
1.70.
y
, ,
. .
, .
: yy
y y -y.
.
y , y
, y. y
. :

100

85
Y
60

50
y .
, ,
\.
. y , .
, y .
. , y ,
( ) .
y , ,
.
:
:
\isaak.bmp

103

,0

,1

.0

( y).
. 1.71.
. 1.71.
Unit tester_;
interface
Uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Dialogs, StdCtrls, ExtCtrls, jpeg;
Type
TForm1 = class(TForm)
Label5: TLabel; //
Label1: TLabel; //
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
//
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
Image1: TImage; //
Button1: TButton;
Panel1: TPanel;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure RadioButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
// yy
procedure Info;
procedure VoprosToScr;
procedure ShowPicture; //
procedure ResetForm; // ""
procedure Itog; // y
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1; //
implementation
{$R *.DFM}
Const N_LEV=4; // y
N_ANS=4; //
var
f
: TextFile;:
fn
: string; //
level: array[1..N_LEV] of integer; // y, y y
mes : array[1..N_LEV] of string; // , y y
score: array[ 1. .N_ANS] of integer; //
summa: integer; //
vopros : integer; // y
otv : integer; //

Forms,

104
//
procedure TForm1.Info;
var
s,buf:string;
begin
readln(f,s);
Form1.Caption := s;
buf:='';
Repeat
readln(f,s);
If s[1] <> . then buf := buf +s + #13;
Until s[1] ='.' ;
Label5.caption:=buf;
end;
//
Procedure GetLevel;
Var
i:integer;
buf:string;
begin
i:=1;
Repeat
readln(f,buf) ;
If buf[1] <> '.'
then begin
mes[i]:=buf; //
readln(f,level[i]); //
i:=i+1;
end;
Until buf[1]='.';
end;
//
Procedure TForm1.ShowPicture;
Var
w,h: integer; //
begin// y
w:=ClientWidth -10;
h:=ClientHeight Panel1.Height -10 - Label5.Top - Label5.Height - 10;
//
If Label1.Caption <> '' then h:=h-Label1.Height-10;
If Label2.Caption <> '' then h:=h-Label2.Height-10;
If Label3.Caption <> '' then h:=h-Label3.Height-10;
If Label4.Caption <> '' then h:=h-Label4.Height-10;
// w h, y
ImageI.Top:=Form1.Label5.Top+Label5.Height+10;
If Image1.Picture.Bitmap.Height > h
then Image1.Height:=h
else Image1.Height:= Image1.Picture.Height;
If Image1.Picture.Bitmap.Width > w
then Image1.Width:=w
else Image1.Width:=Image1.Picture.Width;
Image1.Visible := True;
end;
//
Procedure TForm1.VoprosToScr;
Var
i:integer;
s, buf:string;
ifn:string; //
begin
vopros:=vopros+1;
caption:=' ' + IntToStr(vopros); //
buf:='';
Repeat
readln(f,s);

105
If (s[i] <> '.') And (s[i] <> '') then buf:=buf+s+' ';
Until (s[i] ='.') or (s[i] ='\');
Label5.caption:=buf; //
{ , ,
,
.}
If s[i] <> ''
then Image1.Tag:=0 // y
else // y
begin
Image1.Tag:=1;
If n:=copy(s,2,length(s)) ;
Try
Image1.Picture.LoadFromFile(ifn);
Except
on E:EFOpenError Do
Image1.Tag:=0;
end;
end;
//
i:=1;
Repeat
buf:='';
Repeat //
readln(f,s);
If (s[i]<>'.' ) And (s[i] <> ',' ) then buf:=buf+s+' ';
Until (s[i] = '.' )or(s[i] = ',') ;
//
scored := StrToInt (s[2]) ;
case i of
1: Label1.caption:=buf;
2: Label2.caption:=buf;
3: Label3.caption:=buf;
4: Label4.caption:=buf;
end;
i:=i+1;
Until s[i] = '.' ;
//
// y
If Image1.Tag =1 then ShowPicture;// y
//
If Form1.Label1.Caption <> ''
then begin
If Form1.Image1.Tag =1
then Label1.Top:=Image1.Top+Image1.Height+10
else Label1.Top:=Label5.Top+Label5.Height+10;
RadioButton1.Top:=Label1.Top;
Label1.visible:=TRUE;
RadioButton1.visible:=TRUE;
end;
If Form1.Label2.Caption <> ''
then begin
Label2.top:=Label1.top+ Label1.height+10;
RadioButton2.top:=Label2.top;
Label2.visible: =TRUE;
RadioButton2.visible:=TRUE;
end;
If Form1.Label3.Caption <> ''
then begin
Label3.top:=Label2.top+ Label2.height+10;
RadioButton3.top:=Label3.top;

106
Label3.visible:=TRUE;
RadioButton3.visible:=TRUE;
end;
If Form1.Label4.Caption <>''
then begin
Label4.top:=Label3.top+ Label3.height+10;
RadioButton4.top:=Label4.top;
Label4.visible:=TRUE;
RadioButton4.visible:=TRUE;
end;
end;
Procedure TForm1.ResetForm;
begin //
Label1.Visible:=FALSE;
Label1.Caption:='';
Label1.Width:=ClientWidth-Label1.left-5;
RadioButton1.Visible:=FALSE;
Label2.Visible:=FALSE;
Label2.Caption:='';
Label2.Width:=ClientWidth-Label2.left-5;
RadioButton2.Vis ible:=FALSE;
Label3.Visible:=FALSE;
Label3.Caption:='';
Label3.Width:=ClientWidth-Label3.1eft-S;
RadioButton3.Visible:=FALSE;
Label4.Visible:=FALSE;
Label4.Caption:='';
Labe14.Width:=C1ientWidth-Label4.lett-5;
RadioButton4.Visible:=FALSE;
Label5.Width:=ClientWidth-Label5.left-5;
Image1.Visible:=FALSE;
end;
// y y
procedure TForm1.Itog;
var
i:integer;
buf:string;
begin
buf:='';
buf:='y '+ #13 +' : '+ IntToStr(summa);
i:=1;
While (summa < level[i]) And (i<N_LEV) Do
i:=i+1;
buf:=buf+ #13+mes(i];
Label5.Top:=20;
Label5.Caption:=buf;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
ResetForm;
If ParamCount = 0
then begin
Label5.Caption:= 'He .';
Button1.Caption:='Ok';
Button1.Tag:=2;
Button1.Enabled:=TRUE
End
else begin
fn := ParamStr(1);
assignfile(f,fn);
try
reset(f);
except

107
on EFOpenError Do
begin
ShowMessage(' '+fn+' .');
Button1.Caption: = 'Ok' ;
Button1.Tag:=2;
Button1.Enabled:=TRUE;
exit;
end;
end;
Info; //
GetLevel; // y
end;
end;
// Button1
procedure TForm1.Button1Click(Sender: TObject);
begin
case Button1.tag of
0: begin
Button1.caption:='';
Button1.tag:=1;
RadioButton5.Checked:=TRUE; //
Button1.Enabled:=False;
ResetForm;
VoprosToScr;
end;
1: begin //
summa:=surama+score[otv];
RadioButton5.Checked:=TRUE;
Button1.Enabled:=False;
ResetForm;
If Not eof(f)
then VoprosToScr
else begin
summa:=summa+score[otv];
closefile(f);
Button1.caption:='Ok';
Form1.caption:='y';
Button1.tag:=2;
Button1.Enabled:=TRUE;
Itog; // y
end;
end;
2: begin //
Form1.Close;
end;
end;
end;
// y Onclick RadioButton1-RadioButton4
procedure TForm1.RadioButtonClick(Sender: TObject);
begin
If sender = RadioButton1
then otv:=1
else If sender = RadioButton2
then otv:=2
else If sender = RadioButton3
then otv:=3
else otv:=4;
Button1.enabled:=TRUE;
end;
// y
procedure TForm1.FormCreate(Sender: TObject);

108
begin
Image1.AutoSize := False;
Image1.Proportional := True;
RadioButton1.Visible := False;
end;
End.

109


y , :

,
y Borland Database Engine (BDE).
BDE y y Delphi.

y (y )
y Database Desktop, Delphi.

y ,
(Alias) . y BDE Administrator SQL
Explorer. y Delphi.

y y ,
y CD. Borland y
y y InstallShield Express, Delphi.
64.

"y

-y"
(.
1.72).

y yy Database Desktop,

SQL
Explorer

BDE
Administrator.

. 1.1,
. 1.73.
{ y
STANDARD (y monuments.db),

Peterburg.

SQL Explorer. }
Unit peter_;
interface
. 1.72.
Uses Windows, Messages, SysUtils,
"y -y"
Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, DBCtrls,
Mask, Db, DBTables, jpeg; // JPG-
Type

1.1.

TForm1 = class(TForm)
Monument

60

Tablel: TTable; //

40

DataSource1: TDataSource; // Architect

-
Note
A
255

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;
Photo
A
12

DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBMemo1: TDBMemo;
DBEdit3: TDBEdit;
Image1: TImage;
DBNavigatorl: TDBNavigator;
Label4: TLabel;
procedure TablelAfterScroll (DataSet: TDataSet);
procedure DBEdit3KeyPress(Sender: TObject; var Key: Char);
procedure DBNavigatorlClick(Sender: TObject; Button: TNavigateBtn);
procedure TablelBeforeOpen(DataSet: TDataSet);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }

110
Public
{ Public declarations }
end;
var Form1: TForm1;
BmpPath: string; { y
.

Data

.}
Implementation
{$R *.DFM}
procedure
TForm1.FormCreate
(Sender: TObject);
begin
Tablel.Active := True;
{
(y) y }
end; . 1.73.

"y
-y"

// Image1
procedure ShowFoto(foto: string);
begin
try
Form1.Image1.Picture.LoadFromFile(BmpPath+foto);
Form1.Image1.Visible:=True;
Except
on EFOpenError Do
begin
MessageDlg(' '+foto+' .',
mtlnformation, [mbOk], 0);
end;
end;
end;
// . y (y, y, )
procedure TForm1.TablelAfterScroll(DataSet: TDataSet);
begin
If Form1.DBEdit3.Visible
then
begin
Form1.DBEdit3.Visible := False;
Form1.Label4.Visible:=False;
end;
If Form1.DBEdit3.Text "
then ShowFoto(Form1.DBEdit3.Text)
else Form1.Image1.Visible:=False;
end;
//
procedure TForm1.DBEdit3KeyPress(Sender: TObject; var Key: Char);
begin
If (key = #13)
then
If Form1.DBEdit3.Text <> ''
Then ShowFoto(Form1.DBEdit3.Text) //
else Form1.Image1.Visible:=False;
end;
//
procedure TForm1.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
begin
case Button of
nbInsert:
begin //

111
Image1.Visible:=False; //
DBEdit3.Visible:=True; //
Label4.Visible:=True; // y

end;
nbEdit:
begin //
DBEdit3.Visible:=True; //
Label4.Visible:=True; // y
end;

end;
end;
// , y (y)
procedure TForm1.Table1BeforeOpen(DataSet: TDataSet);
begin
// ,
BmpPath:=ExtractFilePath(ParamStr(0)) + 'data\' ;
end;
End.

65. y, y "y
-y". . 1.74.
//
procedure TForm1.Button1Click(Sender: TObject);
begin
Query1.DatabaseName := 'Peterburg';
. 1.74.

{ Peterburg ,
y . }
With Query1 Do
begin
SQL.Clear;
SQL.Add('CREATE TABLE pam (');
SQL.Add('Monument CHAR(60),');
SQL.Add('Architect
CHAR
(40),');
SQL.Add('Note CHAR(255),');
SQL.Add('Photo CHAR(12));');
// , y,
// y
Try
ExecSQL; //
Except
on E: EDBEngineError Do
begin
ShowMessage(' .'+ #13 + .Message);
Button1.Enabled := False;
end;
end;
end;
end;

112
66.

y

"
".

y
yy
Database
Desktop,

SQL
Explorer

BDE
Administrator.

.
1.2,
. 1.75.

. 1.75.
1.2. " "

Fam
Name
Tel
Email

A
A
A
A

15
20
15
20

{ " ".}
{ y adrbook.db ( Paradox) adrbook.
y y Table, DataSource, DBGrid
y .

Tablel.DataBaseName
adrbook
Tablel.TableName
adrbook.db
Tablel.Active
True
DataSource1.DataSet
Tablel
DBGrid.DataSource
DataSource1
}
Unit adrbook_;
interface
Uses Windows, Messages, SysUtils, Variants, Classes, Graphics,Controls,
Dialogs, ExtCtrls, DBCtrls, Grids, DBGrids, DB, DBTables, StdCtrls;
Type
TForm1 = class(TForm)
Tablel: TTable; //
DataSource1: TDataSource;
DBGrid1: TDBGrid; //
DBNavigator1: TDBNavigator;
Button1: TButton;
Button2: TButton;
Query1: TQuery;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Public

Forms,

113
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm)
procedure TForm1.FormCreate(Sender: TObject);
begin
Tablel.Active := True; // y
end;
//
procedure TForm1.Button1Click(Sender: TObject);
var
buf: string[30]; //
begin
buf := InputBox(' ',
' ','') ;
If buf = '' then exit; //
With Query1 Do
begin
Close; // y y
SQL.Clear; // y y y
SQL.Add('SELECT Fam, Name, Tel, Email);
SQL.Add('FROM ":adrbook:adrbook.db" ');
SQL.Add('WHERE');
SQL.Add{' (Fam ='" + buf + "')');
SQL.Add('ORDER BY Fam, Name');
Open; //
If RecordCount <> 0
then // y
DataSource1.DataSet := Query1
Else ShowMessage(' , y1 + #13
+ ' .');
end;
end;
//
procedure TForm1.Button2Click(Sender: TObject);
begin
DataSource1.DataSet := Tablel; //
end;
End.
67.

"",

y
y

. y

114
. 1.76, yy . 1.3.
. 1.76.

1.3. ""

What
Data

80

// y "".
// y, Project y View Source
program org;
Uses
Forms,
org_ in 'org_.pas' {Form1},
SysUtils,Dialogs,
DateUtils, // y IncDay
DBTables; // y Session, AddStandardAlias
{$R *.res}
Var
Present: TDateTime; //
NextDay: TDateTime; // y
Year, Month, Day : Word; // , ,
Query: TQuery; // , ()
Begin
Application.Initialize;
Application.Title := '';
Application.CreateForm(TForm1, Form1);
{ y y
yy . ,
. , ,
y y ParamStr. }
//
With Session Do
begin
ConfigMode := cmSession;
AddStandardAlias('diary', 'PARADOX');//
ExtractFilePath(ParamStr(0)), //
end;
// yy y
Present:= Now; // Now y, yy y
//
DecodeDate(Present, Year, Month, Day);
case Day0fWeek(Present) of
6: NextDay := IncDay(Present,3); //
7: NextDay := IncDay(Present,2); // y
else NextDay := IncDay(Present,1)
end;
// : ,
Form1.Query1.SQL[3] := '{Data >= '''+ FormatDateTime('dd/mm/yyyy',Present)+''')'
+ 'and'+ 1 (Data <= ''' + FormatDateTime ('dd/mm/yyyy', NextDay) + ''')';
Try
Form1.Query1.Open; //
Except
on E:EDBEngineError Do
// , .
// .
Begin
MessageDlg(' .' +#13+ ' y c.',
mtWarning, [mbYes],0);
Query := TQuery.Create(Form1);
With Query Do
begin

115
// y ,
SQL.Add('CREATE TABLE diary (');
SQL.Add('What CHAR(80),');
SQL.Add('Data DATE);');
ExecSQL;
end;
//
Form1.Query1.Open; //
end;
end;
If Form1.Query1.RecordCount <> 0 // ,
Then Form1.DataSource1.DataSet := Form1.Query1
Else Begin
Form1.DataSource1.DataSet := Form1.Tablel;
Form1.Tablel.Open;
ShowMessage(' ' + #13
+ ' .');
end;
Application.Run;
End.
{y y ,
, , . - ,
.
y y
. y, Project y View Source.}
Unit org_; // y
interface
Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, DBTables, StdCtrls, DBCtrls, ExtCtrls;
Type
TForm1 = class(TForm)
Tablel: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Query1: TQuery;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Label2: TLabel;
DBNavigator1: TDBNavigator;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
Public
{ Public declarations }
end;
var Form1: TForm1;
Const stDay : array[1..7] of string[11] =
('','','', '','','','y'),
stMonth : array[1..12] of string[8] =
('',
'',
'',
'',
'',
'',
'',
'y',

116
'', '', '', '');
Implementation
{$R *.dfm}
Uses DateUtils;
//
procedure TForm1.FormActivate(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day : Word;
Begin
Present:= Now; // Now y, yy y
DecodeDate(Present, Year, Month, Day);
Label1.Caption := ' ' + IntToStr(Day)+' ' + StMonth[Month] + ' '+
IntToStr(Year)+' , ' + stDay[Day0fWeek(Present)];
Form1.Label2.Caption := ' ';
end;
//
procedure TForm1.Button2Click(Sender: TObject);
var
st : string; //
begin
Form1.Label2.Caption := '';
st:= FormatDateTime('dd/ram/yyyy',Now);
Form1. Query1. SQL [3] := ' (Data = ''' +st+ ''')';
Form1.Query1.Open;
If Form1.Query1.RecordCount <> 0
Then Form1.DataSource1.DataSet := Form1.Query1
else begin
ShowMessage(' . ');
//Form1.DataSource1.DataSet := Tablel;
end;
end;
//
procedure TForm1.Button3Click(Sender: TObject);
var
Present, //
Tomorrow: TDateTime; //
Begin
Form1.Label2.Caption := '';
Present:= Now; // Now y, yy y
Tomorrow := IncDay(Present); //
Form1.Query1.SQL[3] : = '(Data = '''+ FormatDateTime('dd/mm/yyyy',Tomorrow)+''')';
Form1.Query1.Open;
If Form1.Query1.RecordCount <> 0
Then Form1.DataSource1.DataSet := Form1.Query1
Else ShowMessage(' . ');
end;
//
procedure TForm1.Button4Click(Sender: TObject);
var
Present: TDateTime;
EndOfWeek: TDateTime;
Begin
Form1.Label2.Caption := ' ';
Present:= Now; // Now y, yy y
EndOfWeek := StartOfAWeek(YearOf(Present),WeekOf(Present)+1);
Form1.Query1.SQL[3] := '(Data >= '''+
FormatDateTime (' dd/rtim/yyyy', Present) + ''')' +
' and' + '(Data < ' ' ' +
FormatDateTime ('dd/mm/yyyy', EndOfWeek)+ ' ' ') ' ;
Form1.Query1.Open;
If Form1.Query1.RecordCount <> 0
Then Form1.DataSource1.DataSet := Form1.Query1
Else ShowMessage(' y .');
end;

117
// y
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
d1, d2: TDateTime;
begin
Form1.Label2.Caption := ' y 1;
Present:= Now; // Wow y, yy y
//
d1 := StartOfAWeek(YearOf(Present),WeekOf(Present)+1) ;
d2 := StartOfAWeek(YearOf(Present),WeekOf(Present)+2);
Form1.Query1.SQL[3] := '(Data >= '''+ FormatDateTime('dd/mm/yyyy', dl) + ''')'
+ 'and'+ '(Data < "'+ FormatDateTime ('dd/mm/yyyy',d2)+ 111)';
Form1.Query1.Open;
If Form1.Query1.RecordCount <> 0
Then Form1.DataSource1.DataSet := Form1.Query1
Else ShowMessage(' yy .');
end;
//
procedure TForm1.Button5Click(Sender: TObject);
begin
Form1.Label2.Caption := ', ';
DataSource1.DataSet := Tablel;
Tablel.Active : = True;
end;
End.

118

( TForm) . (.
2.1) .

Name
Caption
Top
Left
Width
Height
ClientWidth
ClientHeight
BorderStyle

Borderlcons

Icon
Color
Font

Canvas

2.1. ( TForm)

. y y y






() , . . y
() , . . y

. (bsSizeable), (bsSingle)
y(bsNone). y ,
. .
yy, y
.
y . , y yy
y . - y
y biSystemMenu, biMinimize,MMaximize biHelp.
biSystemMenu - y y - , biMinimize
y,biMaximize y, biHelp
, y
. , y y y
. y y ,

. , y " y" , .
Font y Font ,
wiineanna . y Font
( )
, y y

Label
Label (. 2.1)
. (. 2.2) .

. 2.1. Label

Name
Caption
Left
Top
Height
Width
AutoSize
Wordwrap
Alignment
Font
ParentFontColor
Transparent
Visible

Edit

2.2. Label ( )

. y y y





,
, , y ,
yy y ( AutoSize - False)
y . y
(taLeftJustify), y (taCenter) y (taRightJustify)
, y .Y
(Font.Name), (Font.Size) (Font.Color)
,
. True, , y

Y . True
( , Color)
(False) (True)

Edit (. 2.2) -

119
. . 2.3.

. 2.2. Edit -
2.3. Edit ( )

Name
. y y y ,
y y, y
Text
,
Left

Top

Height

Width

Font
, y
ParentFont , .
True, Font
Font
Enabled
y .
False,
Visible
(False) (True)

Button
Button (. 2.3) y y.
. 2.4.

. 2.3. Button Memo


2.4. Button ( )
Name
. y y y
Caption

Left

Top

Height

Width

Enabled
y . True, y.
False, y, , y
Click
Visible
y (False) (True)
Hint
, y y
( , ShowHint
True)
ShowHint (True) (False) y

Memo
Memo (. 2.4)
, .
. 2.5.

. 2.4. Memo
Name
Text
Lines
Lines.Count
Left

2.5. Memo
. y y
, Memo.
, y y .y y y.
yy y
Memo

120

Top
Height
Width
Font
ParentFont



, y

RadioButton
RadioButton (. 2.5)
y y.
. 2.6.
, y yy y

y y,

y
RadioGroup.

. 2.5. RadioButton
Name
. y y
Caption
,
Checked
, : , Checked = True; ,
Checked = False
Left

Top

Height

Width

Font
, y
ParentFont

CheckBox
CheckBox (. 2.6) y y
(). . 2.7.

. 2.6. CheckBox
Name
Caption
Checked
State
AllowGrayed
Left
Top
Height
Width
Font
ParentFont

2.7. checkBox
. y y
,
, : y ( ""), Checked
= True; ( ""), Checked =False
. checked, y,
y . :cbChecked (y);
cbGrayed (, ); cbUnChecked ()
, y : AllowGrayed = False,
y ; AllowGrayed = True, y
y




, y

ListBox
ListBox (. 2.7) ,
y . . 2.8.

. 2.7. ListBox

Name

2.8. LlstSox

. y y y

121
Items
Count
Sorted
Itemlndex
Left
Top
Height
Width
Font
ParentFont



(True)

( yy y).
, y 1




, y

ComboBox
ComboBox (. 2.8)
y y .
. 2.9. ComboBox

. 2.8. ComboBox

Name
Text
Items
Count
Itemlndex
Sorted
DropDownCount
Left
Top
Height
Width.
Font
ParentFont

2.9. ComboBox

. y y
, -


, . ,
y 1
(True)

.
DropDownCount, y


( -)

, y

StringGrid
StringGrid (. 2.9) y,
. . 2.10.

. 2.9. StringGrid

Name
ColCount
RowCount
DefaultColWidth
DefaultRowHeight
FixedCols
FixedRows
Cells
GridLineWidth
Left
Top
Height
Width

2.10. StringGrid

. y y y





.
y
y .
y
y y . ,
col row, y
cells[col,row]
,



122
Options.goEditing
Options.goTab
Options.goAlwaysShowEditor
Font
ParentFont

y . True
, False
(True) (False) <>
y yy y
.
False, , y,
, y <F2>
, y

Image
image (. 2.10)
, bmp- (
JPG, y jpeg y
y uses). image . 2.11. Image

. 2.10. Image
2.11. image

Picture
,
Width, Height . ,
AutoSize, Strech Proportional False,
Proportional .
, AutoSize False
Strech
( )
. y ,
y
AutoSize

Center
,
. False,
, True y
Visible
, ,
Canvas
, y y

Timer
Timer (. 2.11)
onTimer. . 2.12.

. 2.11. Timer

Name
Interval
Enabled

2.12. Timer

. y y y
OnTimer. y
. ( True) ( False)
OnTimer

Animate
Animate (. 2.12) y,
y y , AVI-.
. 2.13.

. 2.12. Animate

Name

2.13. Animate

. y y y

123
FileName
StartFrame
StopFrame
Activate
Color
Transparent
Repetitions

AVI-, ,
,
,

( ""),
""

MediaPlayer
MediaPlayer (. 2.1.3)
, y y y .
. 2.14.

. 2.13. MediaPlayer

Name
DeviceType

FileName
AutoOpen
Display
VisibleButtons

2.14. MediaPlayer

. y y y

y. y,
MediaPlayer. y : dtAutoSelect y
; dtVaweAudio y; dtAVlvideo
; dtCDAudio CD-
, y
y y ,
y
, (
y Panel)
. .

SpeedButton
SpeedButton (. 2.14) y,
. . 2.15.

. 2.14. SpeedButton

Name
Glyph
NumGlyphs
Flat
Grouplndex
Down
Left
Top
Height
Width
Enabled
Visible
Hint
ShowHint

2.15. SpeedButton

. y y y
, .
(. 2.15)
Glyph
Flat ( ). True,
y
y . , y,
: y y y
. ,
GroupIndex 0




y . True, y.
False, y
y (False) (True)
, y y
( , ShowHint
True)
(True) (False) y

124

. 2.15. yy Glyph: , y UpDown

UpDown
upDown (. 2.16) ,
y y -
y y. Y y
. . 2.16. UpDown

. 2.16. UpDown

Name
Position
Min
Max
Increment
Associate
Orientation

2.16. upDown

. y y y
. y Up (y) Down
(y). Min , y Increment
Position
Position
, y Position y

(Edit ), y
Position. ,
Position
. y (udVertical)
(udHorizontal)

Table
Table (. 2.17) y .
. 2.17.

. 2.17. Table

Name
. y y
DatabaseName , ( ), y
y. y
TableName
( ), y y y
TableType
. Paradox (ttParadox), dBase
(ttDBase),FoxPro (ttFoxPro) (ttASCii)
Active
, ( ). y y
True

Query
Query (. 2.18) ,
y SQL- .

125
. 2.18.

. 2.18. Query
2.18.. Query

Name
. y DataSource y
( ) , , DBGrid
SQL
SQL- ( )
Active
y True y

DataSource
DataSource (. 2.19) y ,
Table Query
(DBEdit, DBMemo, DBGrid). . 2.19.

. 2.19. DataSource y
2.19. DataSource

Name
. y y y ,
, ,
DataSet
, (Table Query)

DBEdit, DBMemo, DBText


DBEdit DBMemo (. 2.20)
, DBText
. . 2.20.

. 2.20.
2.20. DBText, DBEdit DBMemo

Name
. y y
DataSource
-
DataField
, y

DBGrid
DBGrid (. 2.21) y
. . 2.21.DBGrid

. 2.21. DBGrid y
2.21. DBGrid

Name

DataSource
( DataSource)
Columns
columns Column,

126
Options.dgTitles
Options.dglndicator
Options.dgColumnResize
Options.dgColLines
Options.dgRowLines

Column

FieldName
Width
Font
Color

Alignment
Title.Caption
Title.Alignment
Title.Color
Title.Font

y y (. 2.22)

. y
y, ,
y
y
,
,

2.22. column

,

, y

. y
(taLeftJustify), y (taCenter) y (t.aRiyhtJustify)
. y
. y
(taLeftJustify), y (taCenter) y (taRightJustify)

DBNavigator
DBNavigator (. 2.22 2.23)
y y , , y
. y (. 2.23).
. 2.24. DBNavigator

. 2.22. DBNavigator
. 2.23. DBNavigator

nbFirst
Y y

Prior

Y y y

nbNext

Y y y

nbLast

Y y

nblnsert

nbDelete'

Y y

nbEdit

Y y

nbPost

, yy ,

Cancel

yy

nbRefresh

y
y

>
Y

Name
DataSource
VisibleButtons

2.24. DBNavigator

. y y
, . y
( Database), ( Table) y -
( Query)

127

Canvas
Canvas ( image),
y (. 2.25) y .
,
(. 2.26).

TextOut(x,y,s)
Draw(x,y,b)
LineTp(x,y)
MoveTo(x,y)
PolyLine(pi)
Polygon(pi)

Ellipse(xl,y,x2,y2)
Arc(xl,yl,x2,y2,
,y,4,y4)

Rectangle(xl,y,x2,y2)
RoundRec(xl,yl,x2,y2,
,y)
Transparent
Pen
Brush
Font

Color

Style

Width

2.25. Canvas

y s (, y). Font
(Canvas), y , -
Brush
(, y) .
Transparent, y , True, ,
,
y y y .

y y y y
y . pi
yy TPoint. , y
y y.
y. y pi
yy TPoint.
. , y
Brush
, y y. xl, yl, 2 y2
y, . )
(1.Y1)(2,y2) (2,y2)
yy. xl, yl, 2, y2 ,
y, 2, y2, y4 y. y
(.y) (4,y4).
() , y
Brush
y. xl, yl,2 y2
y. ,
y Brush
y yy. xl, yl, 2 y2
y, y y y.
, y
Brush
"" Draw.
True, ,
,
(.. 2.27), y
, y ,

Brush (.. 2.28), y
,

Font , y
(, , , ), y

2.27. n

(clBlack ; clMaroon ; clGreen ; clOlive ;clNavy


-; clPurple ; clTeal-y; clGray ; cisilver; clRed
; clLime ; clBlue; clFuchsia - -; clAqua ; clWhite
)
. : psSolid ;psDash y ( ); psDot
y ( ); psDashDot y( );
psDashDotDot y ( y ); psClear
(y, y, , y)
. y 1

Brush

Color
Style

2.28. TBrush ()

y
() (bsSolid ; bsClear
;bsHorizontal ; bsvertical ;
bsFDiagonal ; bsBDiagonal

128
;bsCross - , y; bsDiagCross
, y)

OnClick
OnDblClick
OnMouseDown
OnMouseUp
OnMouseMove
OnKeyPress
OnKeyDown
OnKeyUp
OnCreate
OnPaint
OnEnter
OnExit

2.33.




y

y
y. OnKeyDown OnKeyPress y,
, , y y y
( OnKeyUp)
y y
(, y). y
y ,
, , ,
, y y y.
()
y y y
y y

y.

2.29. y
y

InputBox(, y y ,
,) y . y .
y "y", . . y, y

ShowMessage(s)
y ShowMessage , s

MessageDlg(s,t,b,h) s ,
. t :mtwarning ;
mtError ; mtlnformation ;mtConf irmation ; mtCustom
( ). h (
) (mbYes,mbNo, mbOK, mbCancel,
mbHelp, mbAbort,mbRetry, mblgnore mbAll). h
, y Help <F1>.
y, 0. y
: mrAbort, mrYes, mrOk, mrRetry,mrNo, mrCancel, mrlgnore
mrAll, yy y y

y
Abs(n)
Sqrt(n)
Sqr(n)
Exp(n)
Ln(n)
Rardom(n)
Sin(a)
Cos(a)
Arctan(a)

2.30. y

n
n
n
n
y n
y 0 n-1 ( y
y Randomize, y )
y y
y y a
y

y y .

y
y
(*3.1415256) /180, : y y; 3.1415926 "".
3.1415926 y y y pi).

y
Chr(n)
IntToStr(k)

2.31. y

,
,

129
FloatToStr(n)
,
, . y y: f
; ; .
: f fGeneral y;ffExponent y; ff Fixed
; ffNumber y ; ffCurrency
. y : 7
single, 15 Double 18
Extended
Format(s,[nl,n2, ...] , nl, 2 . .
y y ,
s
StrToInt(3)
, s
StrToFloat(s)
, s
Round(n)
, y y y
Trunc(n)
, y y
Frac(n)
, y
Int(n)
, y
FloatToStrF(n,f,k,m)

y
y y y
TDateTime, ,
, y y Now.
y
Now
DateToStr(dt)
TimeToStr(dt)
DayOf(dt)
MonthOf(dt)
WeekOf(dt)
YearOf(dt)
DayOfWeek(dt)
StartOfWeek(w)
HourOf(dt)
MinuteOf(dt)
SecondOf(dt)
DecodeDate(dt,y,m,d)
DecodeTime(dt,h,m,s,ms)
FormatDateTime(s,dt)

2.32. y y

TDateTime
, y dd.mm.yyy
, hh:mm:ss
( ), y , y
y
, y ,y y
, y ,y y
, y y
, yy : 1 , 2 ,
3 . .
y

y
y
, ,
(, y, y y),

, y .
s, , dd/mm/yyyy , y
, hh:mm

y ,
(. 2.34).

EConvertError
EZeroDivide
EFOpenError
EInOutError
EDBEngineError

2.34.

, y
yy y.
, y
y, y
LoadFromFile. y y ,
y , y
y, (y reset)
yy
, SQL-
yy