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

C

-
-
2005

681.3.068+800.92++
32.973.26-018.1
90
. .
90

C++ Builder . , 2005. 336 : .

.: -

ISBN 5-94157-631-5
C++ Builder. ,
C++ Builder. . -
.

681.3.068+800.92++
32.973.26-018.1

:

.
.

02429 24.07.00. 24.08.05.


60x90 Vie. . . . . 21.
5000 . 1241
"-", 194354, -, . , 5.
-
77.99.02.953..006421.11.04 11.11.2004 .
.

" ""
199034, -, 9 , 12
I S B N 5-94157-631-5

. ., 200S
, "-", 2005

1.

-2


-2
Internet Explorer

5
5
6
10
12
16
18
21
25
28
33
36
43
48
51
54
57
58



...-.

62
62
65
70
75

IV_


.....

81
81
81
84
87
90
93
100
104
109
114
118
121


WAV
Player
MIDI
Compact Disk Player ( 1)
Compact Disk Player ( 2)
Video Player

124
124
124
128
138
142
148
150
158

'.

161
161
162
166
172

15
" " (Puzzle)
" "

-2

180
180
192
198
207
218
232

241
246
255
..259

265

....,
.

( )

""

265
266
266
267
267
268
268
269
269
269
270
270
271
271
272
272
272
273
273

2. BORLAND C++ BUILDER

275

Label
Edit
Button
Memo
RadioButton
CheckBox
ListBox

277
278
279
280
281
283
284
285
286

VI

ComboBox
StringGrid
Image
Timer
SpeedButton
UpDown
ProgressBar
StatusBar
Animate
MediaPlayer.....
Table
Query
DataSource.....
DBEdit, DBMemo,
DBGrid
DBNavigator

287
288
290
291
.292
294
295
296
297
298
299
.....300
......301
301
302
304

:...,

DBText

Canvas
Pen.
Brush

....,


306
306
309
310
310
310
311
312
313
315
315

. CD-ROM

317

324


.

. , , , , , .
,
,
" ". RAD- (Rapid Application Development
)
,
,
,
. RAD-
!
RAD- Borland
C++Builder, :
. Borland C++Builder C++.
, , . . ,
.
, ,
, , , ,

, , . , .
.
, ,
.
, .
,
. , ,
. ,
. , ,
. .
- , , C++Builder , , . . C++Builder. .:
-, 2004. ,
, , :
, , Microsoft Help Workshop, , , installShield Express, ( ).


,
.


C++Builder
: (
), . ( , Windows) .

,
()
.
. :

Label ;

Edit ;

Button ;

checkBox ;

RadioButton ;

ListBox ;

comboBox .

, () (

).

1.

(
).

( Edit), ( ListBox) (
comboBox). CheckBox RadoiButton.

( Label) (
ShowMessage, MessageDlg).
, ,
,
strTomt, strToFioat. , , ,
intTostr,
F l o a t T o S t r F l o a t T o S t r F .

.
TextBox L a b e l

. , (). . 1.1.
\
'

'"jfll

":1~.

- Editi

(/$>

- Edit2

Label4
Buttoni

'

-Button2

. 1 . 1 .


//
void
&Key)

fastcall TForml::EditlKeyPress(TObject *Sender, char

{
// ,
//
// Key -
// ,
if ((Key >= '0') && (Key <= '9')) //
return;
// DecimalSeparator
// ,
//
if (Key == DecimalSeparator)
{
if ((Editl->Text).Pos(DecimalSeparator) != 0)
Key = 0; //
return;

if (Key == VK_BACK) // <Backspace>


return;
if (Key == VK_RETURN) // <Enter>
{
Edit2->SetFocus();
return;

//
Key = 0 ; //

1.

8
//
void

fastcall TForml::Edit2KeyPress(TObject *Sender,


char &Key)

{
if ((Key >= '0') && (Key <= '9')) //
return;
if (Key == DecimalSeparator)
{

if ((Edit2->Text).Pos(DecimalSeparator) != 0)
Key = 0 ; //
return;

if (Key == VK_BACK) // <Backspace>


return;
if (Key == VK_RETURN) // <Enter>

I
Buttonl->SetFocus();//
// <Enter>
//
return;

//
Key = 0 ; //

//
void

fastcall TForml::ButtonlClick(TObject *Sender)


float usd; //


float ;

//

float rub; //
// ,
if (((Editl->Text).Length() ==0) ||
((Edit2->Text).Length)) == 0))
{
MessageDlgC'Haflo ",
mtlnformation, TMsgDlgButtons()

mbOK, 0);

if ((Editl->Text).Length!) == 0)
Editl->SetFocus(); //
else
Edit2->SetFocus(); //
return;

//
usd = StrToFloat(Editl->Text);
k = StrToFloat(Edit2->Text);
//
rub = usd * k;
//
Label4->Caption = FloatToStrF(usd,ffGeneral,7,2) +
"$ = "+FloatToStrF(rub,ffGeneral,7,2) + " ."

//
void

fastcall TForml::Button2Click(TObject *Sender)

{
Forml->Close(); //

1.

10

-
-,
. 1.2, .
,
,
.

.

Editl -

- Buttoni

Label2

. 1.2. ,

fastcall

T F o r m l : : T F o r m l ( T C o m p o n e n t * Owner)

: TForm(Owner)

{
/* Editl (
),
*/
Buttonl->Enabled

False;

// Editl
void
&Key)

fastcall TForml::EditlKeyPress(TObject *Sender, char

{
/ /
//

// Key -
// ,
if ( (Key >= '0') && (Key <= '9')
return;

11_

// DecimalSeparator
// ,
//
if (Key == DecimalSeparator)
{
if ((Editl->Text).Pos(DecimalSeparator) ! = 0)
Key = 0 ; //
return;

if (Key == VK_BACK) // <Backspace>


return;
if (Key == VK_RETURN) // <Enter>
{
Buttonl->SetFocus();
return;

//
Key = 0 ; //

// Editl
void
fastcall TForml::EditlChange(TObject *Sender)
{
// , Editl
if ( (Editl->Text).Length() == 0)
Buttonl->Enabled
else Buttonl->Enabled
Label2->Caption = "";

=
=

False; // .
True; // .

1.

12
//
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
double funt; //
double kg;

//

// ,
// Editl . ,
// .
funt
kg

= StrToFloat(Editl->Text);

funt * 0.4995;

Label2->Caption

FloatToStrF(funt,ffGeneral,5,2) +
" . - " +

FloatToStrF(kg,ffGeneral,5,2) + " ";


TextBox Label, "
". . 1.3.


() ()-

EdiH
- Edit2

LabeU Buttoni -

. I; : : : *

- Button2

. 1.3. .
/ /
void

f a s t c a l l T F o r m l : : B u t t o n l C l i c k ( T O b j e c t *Sender)

float u; //
float r; //
float i; //
// ,
//
if ( ((Editl->Text).Length() = = 0 ) ||
((Edit2->Text).Length() == 0))
{
MessageDlg(" ",
mtlnformation, TMsgDlgButtons() << mbOK, 0) ;
if ((Editl->Text).Length() == 0)
Editl->SetFocus(); //
else
Edit2->SetFocus; //
return;

//
u = StrToFloat(Editl->Text);
= StrToFloat(Edit2->Text);
//
try
{
i = u/r;
}
catch (EZeroDivide &e)
{
ShowMessage(" "
" ");
Edit2->SetFocus();
return;

//

1.

14
// Labels
Label4->Caption - " : " +

FloatToStrF(i,ffGeneral,7,2) + " A";

//
// ,
//
void
fastcall TForml::EditlKeyPress(TObject *Sender,
char &Key)
{
// Key -
// ,
if ( ( Key >= '0') && ( Key <= '9' ) ) //
return;
// DecimalSeparator
// ,
//
if ( Key == DecimalSeparator)
{
if ( (Editl->Text).Pos(DecimalSeparator) != 0 )
Key = 0 ; //
return;

if (Key == VK_BACK) // <Backspace>


return;
if ( Key == VK_RETURN) // <Enter>
Edit2->SetFocus();
return;

75

//
Key = 0; //

//
void
fastcall TForml::Edit2KeyDown(TObject *Sender,
WORD &Key,TShiftState Shift)
{
if ( ( Key >= '0') && ( Key <= '9' ) ) //
return;
if ( Key == DecimalSeparator) {
if ( (Edit2->Text).Pos(DecimalSeparator) != 0 )
Key = 0; //
return;

if (Key == VK_BACK) // <Backspace>


return;
if ( Key == VK_RETURN) // <Enter>

I
Buttonl->SetFocus(); //
// <Enter>
//
// . ButtonlClick
return;

//
Key = 0 ; //

//
void
fastcall TForml::Button2Click(TObject 'Sender)

16

1.

Forml->Close(); //

/* EditlChange Change
Editl, Edit2.
- Change
Editl, - Change
Edit2
EditlChange. */
void

fastcall TForml::EditChange(TObject *Sender)

{
Label4->Caption = "";

, . 1.4, , , . RadioButton.


,

I
RadioButtoni
RadioButton2

Label4

. 1.4.

17_

//
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
float rl,r2,r;
rl = StrToFloat(Editl->Text);
r2 = StrToFloat(Edit2->Text);
/* RadioButtonl RadioButton2
,
*/
( RadioButtonl->Checked )
{
// ""
= rl + 2;
ela*
//

//

//

""

EInvalidOp

try
{
= ( r l * r2) / ( r l + r 2 ) ;
}
catch ( EInvalidOp &e)
{
ShowMessage(" "
"");
return;

Label4->Caption = FloatToStrF(r, ffGeneral, 6,2) + " ";


}

18

1.

II ""
void

fastcall TForml::RadioButtonlClick(TObject *Sender)

{
Label4->Caption = "";

// ""
void

fastcall TForml::RadioButton2Click(TObject *Sender)

{
Label4->Caption = "";

, . 1.5, checkBox.

Label!

Che:kBox1

CheckBox2

CheckBox3

CheckBox4

Buttoni

I::
. 1.5.

float surnm; //
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)

// ""
CheckBox2->Enabled = false;

// "-"
void

fastcall TFoml: :CheckBoxlClick(TObject *Sender)

{
if ( CheckBoxl->Checked )
{
/* ,
*/
summ += 54;
// ""
CheckBox2->Enabled = true;
}
else
{
/* ,
*/
summ -= 54;
// ""
if (CheckBox2->Checked)
CheckBox2->Checked = false;
CheckBox2->Enabled = false;

//
Labell->Caption = FloatToStrF(summ,ffCurrency,6,2);

1.

20
// ""
void

faetcall TForml::CheckBox2Click(TObject *Sender)

if ( CheckBox2->Checked)
summ +=10.5;
la*
summ -= 10.5;
Labell->Caption = FloatToStrFtsumm,ffCurrency,6,2);

// ""
void

faetcall TForml::CheckBox3Click(TObject *Sender)


if ( CheckBox3->Checked)
summ += 18.5;
la*
summ -= 18.5;
Labell->Caption = FloatToStrF(summ,ffCurrency,6,2);

// "-"
void

faetcall TForml::CheckBox4Click(TObject *Sender)

{
if ( CheckBox4->Checked)
s u m += 14;
summ -= 14;
Labell->Caption = FloatToStrF(summ,ffCurrency,6,2)

// OK


void

21_

fastcall TForml::ButtonlClick(TObject *Sender)

{
if ( (CheckBoxl->Checked)&& (CheckBox2->Checked)&&
(CheckBox3->Checked)&&(CheckBox4->Checked) )
/*
5% */
summ = summ * 0.95;
ShowMessage(" 5%.\"
" : " + FloatToStrF(summ, ffCurrency, 6,2) +
" .");
}
else
if ( (CheckBoxl->Checked)||
(CheckBox3->Checked)||
(CheckBox4->Checked))
ShowMessage(" : " +
FloatToStrF(summ,ffGeneral,6,2)+ " .");
else

ShowMessage(" ");


, . 1.6,
.
ComboBox2

( ).

comboBox2 ,
, .

. 1.1.

1.

22
riv


Label2:

Labell-

ComboBoxi

- LabeB

ComboBox2

. 1.6.
1.1.

ComboBoxl . s t y l e

csDropDownList

(
)

ComboBox2.Style

csDropDown

.Style

csSimple

/ /
fastcall TForml::TForml(TComponent* Owner)
/ /

TForm(Owner)

ComboBox2->Sorted = t r u e ; / /
ComboBox2->Items->Add("-");
ComboBox2->Items->Add("Mepjttui,a") ;
ComboBox2->Items->Add("-");
ComboBox2->Items->Add("");
ComboBox2->Items->Add("");

23

//
ComboBox2->Sorted = t r u e ; / /

ComboBox3->Items->Add("4aii") ;
ComboBox3->Items->Add("4aM ");
ComboBox3~>Items->Add("Ko(J>e ") ;
ComboBox3->Items->Add("Ko<J>e ");
ComboBox3->Items->Add("KaKao");

// ComboBoxl
void

fastcall TForml::ComboBoxlClick(TObject *Sender)

{
Labell->Caption = CornboBoxl->Text;

// ComboBox2
void

fastcall TForml::ComboBox2Click(TObject *Sender)

{
Label2->Caption = ComboBox2->Items->
Strings[ComboBox2->ItemIndex]

//
void

fastcall TForml::ComboBox3Click(TObject *Sender)

{
Label3->Caption = ->Iterns->
Strings[ComboBox3->ItemIndex]

// ComboBox2
void
fastcall TForml::ComboBox2KeyPress(TObject *Sender,
char &Key)
{
if

(Key == VK_RETURN)

24

1.
/ // <Enter>. .
int n = ComboBox2->ltems->Add(ComboBox2->Text);
ComboBox2->ItemIndex = n;
Label2->Caption = ComboBox2->Items->Strings[n];

//
void

fastcall TForml::ComboBox3KeyPress(TObject *Sender,


char &Key)
AnsiString st;

// ,
//
// ComboBox

if

(Key == VK_RETURN)
//
// <Enter>. ,
//
st = ComboBox3->Text.Trim(); //
if ( ComboBox3->Items->lndex0f(st) == -1 )
//
int n = ComboBox3->Items->Add(st);
ComboBox3->ItemIndex = n;
Label3->Caption = ComboBox3->Items->Strings[n]

25

(. 1.7) ,
,
.

' -

(./)

1052'7
I31274'2
I0'96

: 212,64.
[/HTbj

. 1.7.
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
/ * ,

Edit2

KeyPress

Edit3

EditKeyPress

*/

Edit2->0nKeyPress = E d i t K e y P r e s s ;
Edit3->0nKeyPress = E d i t K e y P r e s s ;
/ *
,


*/
E d i t l - > T a g = 1;
Edit2->Tag = 2 ;

KeyPress

Tag

Edit

26

1.
Edit3->Tag = 3;

//
void
fastcall TForml::EditKeyPress(TObjt *Sender,
char &Key)
TEdit * Edit;

// Edit

Edit = (TEdit*)Sender;
/* ed - Edit,
*/
/* ,
<Enter> . */
if ( Key == VK_RETURN) // <Enter>
switch (Edit->Tag) {
case 1 : /* Editl
Edit3 */
Edit2->SetFocus() ; break;
case 2 : /* Edit2
Edit3 */
Edit3->SetFocus() ; break;
case 3

/* Edit3
*/
Buttonl->SetFocus ; break;

}
return;

if ( (( Key >= '0') && ( Key <= 9' )


(Key == VK_BACK))

// <>Backspace>
return;

if ((Key == ',') || (Key == '.'))


{
Key = DeciinalSeparator;
if ( (Edit->Text).Pos(DecimalSeparator) != 0
Key = 0;
return;

if

( K e y = = VK_BACK )
return;

/ /

Key = 0;

//
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
float prior, curr; //
//
float tariff;
float summ;

// - 1 /
//

prior = StrToFloat(Editl->Text);
curr = StrToFloat(Edit2->Text);
tariff = StrToFloat(Edit3->Text);
//
if ( curr < prior)
2 3. 1241

1.

28

MessageDlg(" "
" .",
mtWarning, TMsgDlgButtons()

mbOK,0);

return;
}
summ = (curr - prior) * tariff;
Label4->Caption = " : " +
FloatToStrF(summ, ffCurrency, 6,2);

(. 1.8), (. 1.9), . ,
. ,
, , .
JUJ<J


(
(.):

Jl980

: [-
;
:

: |0

22 . 2

j j

(.): [ 70 95 _^J

[ 9

OK

. 1.8.

29

: 1 980,00.
. : 1,8

. : 0,95
. : 1
. - , : 1
. : 1
. : 1
: 3385,80.

. 1.9.
AnsiString reg[8] = {""," .",
"-",
" ",
" .",
"-", "",
""};
// .,
float Kt [8] = {1.8,1.6, 1.8,1.3,1,1,1,1};
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
int i, n;
n = sizeof (Kt) / sizeof (float);
for (i=0; i<n; i++)
ComboBoxl->Items->Add(reg[i]);
/* Change
TForml::Change */
ComboBoxl->OnChange = Change;
ComboBox2->OnChange = Change;-

1.

30
ComboBox4->0nChange = Change;
ComboBox4->OnChange = Change;
Editl->OnChange = Change;
Edit2->0nChange = Change;
Edit3->0nChange = Change;

/*
- 3- , (
) 4- ..). ,
: -
, - - .
//

*/

i n t Cb[6][5] = {{1,-1,-1,-1,-1},
{2,-1,-1,-1,-1},
{3,1,-1,-1,-1},
{4,1,-1,-1,-1},
{5,2,1,-1,-1},
{6,3,1,-1,-1}};
//
float Kb[7] = {2.3, 1.55, 1.4, 1, 0.95, 0.9};
//
void

fastcall TForml::ButtonlClick(TObject *Sender)


float aTb; //
float aKt; // .
float aKb; // .
float aKvs; // .
float aKo; // ., ,
//

31_

float ;

// .

float aKs;

// .,

int pcb,ccb; //
int nss;

//
//

= StrToFloat (Edit3->Text) ;
aKt = Kt[ComboBoxl->Itemlndex];
pcb = StrToInt(Editl->Text);
nss = StrToInt(Edit2->Text);
ccb =

Cb[pcb][nss];

if ( ccb != -1)
aKb = Kb[ccb];
else aKb = 2.45;
aKb = Kb[ccb];
// .
switch (ComboBox2->ItemIndex)
{
case 0: aKvs = 1.3;

break;

case 1: aKvs = 1.2; break;


case 2: aKvs = 1.15; break;
case 3: aKvs = 1.0; break;

// ., ,
//
if (CheckBoxl->Checked)
= 1;
else
1.5;

32

1.
// .
switch (ComboBox3->ItemIndex)

0
case
case 1

aKm =

case 2

aKm =: 1.0; break ;

case 3

aKm =: 1.3; break ;

case 4

aKm == 1.5; break ;

case 5

aKm == 1.7; break ;

case 6

aKm == 1.9; break

0.5;

break

aKm =: 0.7; break ;

'

// . , .

switch (ComboBox4->ItemIndex)
{
case 0 : aKs = 0.7; break;
case 1 : aKs = 0.8; break;
case 2 : aKs = 0.9; break;
case 3 : aKs = 0.95; break;
case 4 : aKs = 1.0; break;

//
float T; //
AnsiString st;
T = * aKt * aKb * aKvs * * aKm *aKs;
st = " : " +
FloatToStrF(aTb,ffCurrency,5,2)+
". : " + FloatToStrF(aKt,ffGeneral,2,2)+
". : " +

3J3

FloatToStrF(aKb,ffGeneral,2,2)+
". : " +
FloatToStrF(aKvs,ffGeneral,2,2)+
"\.. - , : " +
FloatToStrF(aKo,ffGeneral,2,2)+
"\. : " +
FloatToStrF(aKm,ffGeneral,2,2)+
". : " +
FloatToStrF(aKs,ffGeneral,2,2)+
"\\: " + FloatToStrF(T,ffCurrency,5,2);
ShowMessage(st) ;

// -

void

fastcall TForml::Change(TObjt *Sender)

{
Buttonl->Enabled =
(ComboBoxl->ItemIndex != -1) &&
(ComboBox2->ItemIndex != -1) &&
(ComboBox3->ItemIndex != -1) &&
(ComboBox4->ItemIndex != -1) &&
(Editl->Text.Length<) != 0) &&
(Edit2->Text.Length() != 0) &&
(Edit3->Text.Length() != 0);


(. 1.10)
ListBox openDiaiog.
()
,
.
OpenDiaiog.

1.

34

PICT0208JPG
PICT0209.JPG
PICT0210.JPG
PICT0211.PG
PICT0212.JPG
PICT0213.PG
PICT0214.PG
PICT0217.JPG
PICT0001.JPG
PICT0002.JPG
PICT0003.PG
PICT0004.JPG
PICT0006.PG
PICT0O0BJPG
PICT0011.PG
PICT0013JPG
PICT0014.JPG
01

. 1.10.
L i s t B o x
#include <jpeg.hpp>

AnsiString aPath;

//
// JPEG
// ,
//

TSearchRec aSearchRec; // -
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
Imagel->Proportional = true;
if (FindFirst(aPath+ "*.jpg"/ faAnyFile, aSearchRec) == 0)
ListBoxl->Items->Add(aSearchRec.Name);
while ( FindNext(aSearchRec) == 0 ) / / . .

3!5

{
ListBoxl->Items->Add(aSearchRec.Name);
}
//
ListBoxl->ItemIndex = 0;
Labell->Caption = ListBoxl->Items->Strings[0];
Imagel->Picture->LoadFromFile(aPath +
ListBoxl->Items->Strings[0]);

// ListBox
void

fastcall TForml::ListBoxlClick(TObject *Sender)

{
int n = ListBoxl->ItemIndex; // -
//
Labell->Caption = ListBoxl->Items->Strings[n];
Imagel->Picture->LoadFrornFile(aPath + ListBoxl->
Items->Strings[n]);

//
void

fastcall TForml::BitBtnlClick(TObject *Sender)

{
if ( OpenDialogl->Execute() )
{
//
ListBoxl->Clear(); //
aPath = ExtractFilePath(OpenDialogl->FileName);
Forml->Caption = " - " + aPath;
if ( FindFirst(aPath+ "*.jpg", faAnyFile, aSearchRec)
== 0)

36

1.

ListBoxl->Items->Add(aSearchRec.Name);
w h i l e (FindNext(aSearchRec) == 0)//

..

{
ListBoxl->Items->Add(aSearchRec.Name);
}
//
// ListBox
int n = ListBoxl->Items->
IndexOf(ExtractFileName(OpenDialogl->FileName));
ListBoxl->ItemIndex = n;
Labell->Caption = ListBoxl->Items->Strings[n];
Imagel->Picture->LoadFromFile(aPath +
ListBoxl->Items->Strings[n]);

(. 1.11) . ,
staticText.
( --'

I _ ! _ L J _ ^ J

. 1 . 1 1 .

37^

float accum; // (- )
int op;

/* :
1 - "+",2 - "-";
- "" ( "=" */

int f;

/* f == 0 - ,
,
, .
f == 1 - */

//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
f =0;

//

op = 0;

//

StaticTextl->Caption = 0;

// "0"
void
fastcall TForml::Btn0Click(TObject *Sender)
{
if ( f != 0)
StaticTextl->Caption = StaticTextl->Caption + "0"

// "1"
void
fastcall TForml::BtnlClick(TObject *Sender)
{
if ( f == 0)
{
StaticTextl->Caption = "1";
f = 1;

38

1.
else
StaticTextl->Caption = StaticTextl->Caption + "1";

// "2"
void

fastcall TForml::Btn2Click(TObject *Sender)

{
if ( f == 0)
{
StaticTextl->Caption = "2";
f = 1;
else
StaticTextl->Caption = StaticTextl->Caption + "2";

// "3"
void

fastcall TForml::Btn3Click(TObject *Sender)

{
if ( f == 0)
{
StaticTextl->Caption = "3";
f = 1;
}
else
StaticTextl->Caption = StaticTextl->Caption + "3"

// "4"
void

fastcall TForml::Btn4Click(TObject *Sender)

{
if ( f == 0)
StaticTextl->Caption = "4";


f = 1;
}
else
StaticTextl->Caption = StaticTextl->Caption + "4";

// "5"
void
fastcall TForml::Btn5Click(TObject *Sender)
{
if ( f == 0)
{
StaticTextl->Caption = "5";
f = 1;
}
else
StaticTextl->Caption = StaticTextl->Caption + "5"

// ""
void

fastcall TForml::Btn6Click(TObject *Sender)

{
if ( f == 0)
{
StaticTextl->Caption = "6";
f = 1;
}
else
StaticTextl->Caption = StaticTextl->Caption + "6"

// "7"
void
fastcall TForml::Btn7Click(TObject *Sender)
{
if ( f == 0)

39

1.

40
StaticTextl->Caption = "7";
f = 1;
}
else

StaticTextl->Caption = StaticTextl->Caption

// "8"
void
fastcall TForml::Btn8Click(TObject *Sender)
{
if ( f == 0)
{
StaticTextl->Caption = "8";
f = 1;
else
StaticTextl->Caption = StaticTextl->Caption + "8";

// "9"
void

fastcall TForml::Btn9Click(TObject *Sender)

{
if ( f == 0)
{
StaticTextl->Caption = "9";
f = 1;
else
StaticTextl->Caption = StaticTextl->Caption + "9"

// ", " ( )
void
fastcall TForml::BtnkClick(TObject *Sender)


{
if ( f == 0)
{
StaticTextl->Caption = "0,";
f = 1;
else
if ( StaticTextl->Caption.Pos(",") == 0)
StaticTextl->Caption = StaticTextl->Caption

// "" ()
void

fastcall TForml::BtnCClick(TObject *Sender)

{
StaticTextl->Caption = "0";
accum = 0;
op = 0;
f = 0; //

//
void

fastcall TForml::DoOp(void)

{
/* accum .
, .
*/
float op2 = StrToFloat(StaticTextl->Caption);
switch ( op )
{
case 0 : accum = op2; break ;
case 1 : accum += op2; break;

41_

1.

42
case 2 : accum -= op2; break;

StaticTextl->Caption = FloatToStrF(accum,ffGeneral,6,3);

// "+"
void
fastcall TForml::BtnPClick(TObject *Sender)
{
/* ,
,

*/
if ( f != 0)
{
//
DoOp(); //
f = 0;

//

}
=1;

// "-"
void
fastcall TForml::BtnMClick(TObject *Sender)
{
if ( f != 0)
{
//
DoOp(); //
f = 0;

//

}
= 2; //

// "="


void

43

fastcall TForml::BtnEClick(TObject *Sender)

{
if ( f != 0)
{
DoOp(); //
f = 0; //
}
= 0;

-2
-2,
. 1.12,
, , " ". SpeedButton.
,
() click.
, speedButton click
, .

. 1.12. -2
/ / & -
c l a s s TForml : p u b l i c TForm

h-

published:
TStaticText *StaticTextl; //

1.

44
private:

// ** **
TSpeedButton * btn[16];

//

// Click
void

fastcall btnClick(TObject *Sender);

public:
fastcall TForml (TComponent* Ownejr) ;

// *** ***
float ;

// ( )

int op;

//

int fd;

/* fd == 0 - , ,
, "+";
fd = 1 -
*/

#define WBTN

35

#define HBTN

20

//
//

#define DXBTN

// X

#define DYBTN

// Y

//
Char btnText[] = "789+456-123=00.";
#define CM -1

//

#define EQ -2

// "="

ttdefine PL -3

// "+"

#define MN -4

// "-"

#define CL -5

// "C"

//
int btnTagU = {7,8,9,PL,4,5,6,MN,1,2,3,EQ,0,0,CM,CL}


//

45


fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)

{
int left, top; //
top = 48;
int = 0; // btn
for ( int i = 0; i < 4; i++ ) //
{
left = 8;
for ( int j = 0;

j < 4; j++) // no 4

{
btn [] = new TSpeedButton {Forml),btn[k]->Parent = Forml; // ""
//
//
btn[k]->Left = left;
btn[k]->Top = top;
btn[k]->Width = WBTN;
btn[k]->Height = HBTN;
//btn[k]->Flat = true;
btn[k]->Font->Color = clNavy;
btn[k]->Caption = btnText[k]; //
btn[k]->Tag = btnTag[k];

//

// Click
btn[k]->OnClick = btnClick; // .
// h-
left = left + WBTN+ DXBTN;

1.

46
top = top + HBTN + DYBTN;
}

// "" (btn[12] btn[13])


btn[13]->Visible = false;
btn[12]->Width = 2 * WBTN + DXBTN;
op = EQ;

// btn[i]
// ( )
void

fastcall TForml::btnClick(TObject *Sender)

{
TSpeedButton *btn;
int id; //
btn = (TSpeedButton*(Sender;
// Tag
id = btn->Tag;
// "1" .. "9"
if ( id > 0 ) {
if ( fd == 0 ) {
StaticTextl->Caption = btn->Tag;
fd = 1;
}
else
StaticTextl->Caption =
StaticTextl->Caption + btn->Tag;
return;
// ""
if ( id == 0) {
if ( StaticTextl->Caption != "0" )
StaticTextl->Caption =

47
StaticTexCl->Caption + btn->Tag;

return;
}
// ","
if ( id == CM) {
if ( StaticTextl->Caption.Pos(",") == 0 )
{
StaticTextl->Caption = StaticTextl->Caption + ",";
fd = 1;
}
return;
}
// ""
if ( id == CL) {
ac = 0;
id = EQ;
fd = 0;
StaticTextl->Caption = 0;
return;
}
// : "+", "-" "="
float op2; // ( )
2 = StrToFloat(StaticTextl->Caption);
/* , ,
,
*/
switch (op) {
case EQ : = op2; break;
case PL : ac = ac + op2; break;
case MN : ac = ac - op2; break;
}
StaticTextl->Caption = FloatToStrF(ac,ffGeneral,15,6);
op = id;

//

1.

48
fd = 0;

//

//
void

fastcall TForml::FormDestroy(TObjt *Sender)


// ,
for ( int i = 0; i < 16; i++)
delete btn[i];

,
. 1.13, Timer.
Label

Timeri -

Label2 Label3

0:00 00:

Buttoni

j:

Button2

. 1.13.
//
int min;

//

int sec;

//

int msec;

//

//
_fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)

{
//
Timerl->Enabled = false;
Timerl->Interval = 10; //
// 1

// /
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
if ( ! Timerl->Enabled )
{

*
//
Timerl->Enabled = true;
Buttonl->Caption = "";
Button2->Enabled = false,}

else
{
//
Timerl->Enabled = false;
Buttonl->Caption = "";
Button2->Enabled = true,-

//
void

fastcall TForml::TimerlTimer(TObject *Sender)

{
if ( msec < 99)
msec++;
else

50

1.
msec = 0;
if ( sec < 59 )
sec++;
else
{
sec = 0;
min++;
Labell->Caption = IntToStr(min);
}
if ( sec <= 9 )
Label2->Caption = "0" + IntToStr(sec);
else
Label2->Caption = IntToStr(sec);
//
Label4->Visible = ! Label4->Visible;
}
if ( msec <= 9 )
Label3->Caption = "0" + IntToStr(msec);
else
Label3->Caption = IntToStr(msec);

//
void

fastcall TForml::Button2Click(TObject *Sender)

{
min = 0;
sec = 0;
msec = 0;
Labell->Caption = "0";
Label2->Caption = "00";
Label3->Caption = "00";

51


(. 1.14) ProgressBar.
ProgressBar . 1.2.
\

"" . .
<Enter>
Editi

ProgressBarl

F
60' Buttoni

CheckBoxi

Timeri

. 1.14.
1.2. ProgressBar

Min

60

Step

Position

60

Smooth

true

#define TR 60 // ,
int pw;
// ""
int rem = TR; //
//
fastcall TForml::TForml(TComponent* Owner) : TForm(Owner)

1.

52

Label4->Caption = IntToStr(TR);
//

// ,
//
ProgressBarl->Max = TR;
ProgressBarl->Position = TR;
ProgressBarl->Step = 1;

//

ProgressBarl->Smooth = true,-

// -

//
Randomize() ;
pw = RandomRange(100,999); // ""

//
void

fastcall TForml::TimerlTimer(TObject *Sender)

{
rem;
ProgressBarl->Position--;
Label4->Caption = IntToStr(rem);
if (rem == 0 )
{
// ,
Timerl->Enabled = false;
Editl->Enabled = false;
Buttonl->Enabled = false;
ShowMessage(" , "
" \ \"\" :" +
IntToStr(pw) );


//
void
fastcall TFonnl::CheckBoxlClick(TObject *Sender)
{
if ( CheckBoxl->Checked )
{
//
ProgressBarl->Step = 1 ;
ProgressBarl->Smooth = true;

//
// -

else
//
ProgressBarl->Step = 6 ;

//

ProgressBarl->Smooth = false; // -

// ,
void
fastcall TForml::isRight(void)
{
if ( StrToInt(Editl->Text) == pw )
{
Timerl->Enabled = false;
Buttonl->Enabled = false;
Editl->Enabled = false;
ShowMessage("!\ " +
IntToStr(TR - rem)+ " ");

//
void
fastcall TForml::EditlKeyPress(TObject *Sender,
char &Key)
{
if ( ( Editl->Text.Length() < 3) &&

1.

54
((Key >= '0') &&
(Key <= '9')))
return;
if ( Key == VK_RETUKN)
{

isRight(); // ,
//
return;
}
if ( Key == VK_BACK) return;
//
Key = 0;

//
void

fastcall TForml::EditlChange(TObject *Sender)

{
// OK ,
// ()
if ( Editl->Text.Length() == 3)
Buttonl->Enabled = true;
else
Buttonl->Enabled = false;

// OK
void
faatcall TForml::ButtonlClick(TObject *Sender)
isRightO;

// ,
//

-2
-2, . 1.15,
statusBar.

55

,
, , .
!' -2

"" . .
<Entef>
)482|
: 3 " (:!

j : 5,

. 1.15.
# d e f i n e TR
i n t pw;

60 / / ,

/ / ""

//

/ /

i n t rem = TR; / /
i n t = 0;


f a s t c a l l TForml::TForml(TComponent* Owner) : TForm(Owner)

{
//
Randomize();
pw = RandomRange(100,999); / / ""

//
void

fastcall TForml::TimerITimer(TObject *Sender)

{
rem--;
S t a t u s B a r l - > P a n e l s - > I t e m s [ 2 ] - > T e x t = " : " +
IntToStr(rem) + " ";
if

(rem == 0 )
/ / ,

56^

1.
Timerl->Enabled = false;
Editl->Enabled = false;
ShowMessage(" , "
" \\"\" :" +
IntToStr(pw) );

//
void
fastcall TForml::EditlKeyPress(TObject *Sender, char
&Key)
if ( ( Editl->Text.Length() < 3) && ( ( Key >= '0') &&
( Key <= '9') ) )
return;
if (( Key == VK_RETURN) && (Editl->Text.Length() == 3))
// ,
if ( StrToInt(Editl->Text) == pw )
Timerl->Enabled = false;
Editl->Enabled = false;
ShowMessage("!\ " +
IntToStr(TR - rem)+ " ");
else
//
++;
StatusBarl->Panels->Items[I]->Text =
" : " + IntToStr(p);
return;

57

if ( Key == VK_BACK) return;


//
Key 0;

//
void
fastcall TForml::EditlChange(TObject *Sender)
StatusBarl->Panels->Items[O]->Text =
" : " + IntToStr(Editl->Text.Length()

Internet Explorer
Internet , Internet
Explorer -.
. 1.16. Label i.
Label . 1.3.

http: //www.phy.ru

Labeli
. 1.16. Internet

1.3. Label i

Font.Color

clBlue

Font.Style.fsUnderline

true

Cursor

crHandPoint

58

1.

//
void

Label 1

f a s t c a l l TForml::LabellClick(TObject

*Sender)

{
/ / ,

Labell

ShellExecute(Forml->Handle,"open",Labell->Caption.c_str,
NULL,NULL,SW_RESTORE);

(. 1.17)

Winhelp ( ). (. 1.18)
<F1>
. ,
<F1> ,
, , ,
.

(. 1.4). , , . 1.5.
\-

($)

(/$) J"~

F1 -

EdiM

Edil2

Button3

. 1.17.

<F1>

59

3
-

Borland C++Builder.

. (
onvertor.hlp)
Help.

d
. 1.18. Winhelp
1.4.

5
1.5. ,

Forml
Forml

HelpFile
HelpContext

conv.hlp

Editl

HelpContext

Edit2

HelpContext

/ /
""
void
f a s t c a l l T F o r m l : : B u t t o n 3 C l i c k ( T O b j e c t *Sender)
{
WinExecCwinhlp32.exe c o n v . h l p " , SW_RESTORE) ;

3 . 1241

1.

60

-2
-2 (. 1.19) HTML
Help ( chm). (. 1.20)
<F1> , /
. () .
, KeyDown, a He KeyPress.
I-.?1 -2

($)

*1

|~

(/$) |"

F1 -

. 1 . 1 9 .
< F 1 >
.iql.xj

* -2
TV
tLJ

51


ii]


.
Borland C++ Builder.

.
^
(convertor.chm)

Help.

. 1.20. HTML Help

61_

/* "".
KeyDown
,
( KeyPress
) */
void

fastcall TForml::EditlKeyDown(TObject *Sender,


WORD &Key, TShiftState Shift)

{
if (Key == VK_F1 )
/*
hh.exe,
Windows. mappid
*/
WinExecfhh.exe -mapid 3 converter.chm", SW_RESTORE);

// ""
void
fastcall TForml::Edit2KeyDown(TObject *Sender,
WORD &Key, TShiftState Shift)
{
if (Key == VK_F1 )
WinExecChh.exe -mapid 4 convertor.chm", SW_RESTORE)

// ""
void
fastcall TForml::Button3Click(TObject *Sender)
{
WinExecChh.exe -mapid 1 convertor.chm", SW_RESTORE)


,
.

, . 1.21, , ,
. meteo.txt . , .
,
, .

7
14
3
I 28

12
8 9
15 16
22 23
.:

3
10
17
24
:

4
11
18
25
:

5 6
12 13
19 20
26 27

. -

: 21.02.2005

; I

::::::

I ; : : : : ; : : : : ; ; : . : :
. 1 . 2 1 .

63

int f; //
//'
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
MonthCalendarl->ShowTodayCircle = false;
MonthCalendarl->Date = Now();
Buttonl->Enabled = false;
}
//
void

fastcall TForml::EditlChange(TObject *Sender)

{
// "" ,
// .
// - "",
if ( (Editl->Text.Length() == 0 ) ||
( (Editl->Text.Length() ==1) &&
(Editl->Text[l] == '-') ) )
Buttonl->Enabled = false;
else
Buttonl->Enabled = true;
}
// ""
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
AnsiString st;
/* fmCreate, ,
, ,
, */

1.

64

st MonthCalendarl->Date.DateString() + " " +


Editl->Text + "\r\n";
/* meteo.txt */
if ( FileExists("meteo.txt") )
f = FileOpen("meteo.txt",fmOpenWrite);
else
= FileCreatef"meteo.txt"); //
if ( f != -1 )
{
//
FileSeek(f,0,2); //
//
FileWrite(f,st.c_str(),st.Length());
FileClose(f);
Buttonl->Enabled = false;
}
else
{
/* : ,
*/
ShowMessage(" : ,"
" ");

//
//
void

fastcall TForml::EditlKeyPress(TObject *Sender,


char &Key)

65

if (( Key >= '0') && (Key <= '9'))


return;
// ()
if ( ( Key == '.') || (Key == ','))
{
Key = ' , ' ;
if ( Editl->Text.Pos(',') != )
Key = 0;
return;

if ( Key == 8)
return;
if ((Key == '-') && (Editl->Text.Length() == 0))
// ""
return;
//
Key = 0;
}
// MohthCalendar
void

fastcall TForml::MonthCalendarlClick(TObject *Sender)

{
Editl->Text = "";

//

Editl->SetFocus();

//
//


(. 1.22) .
, meteo.txt,
.

1.

66
---

19.02.2005
20.02.2005
21.02.2005
22.02.2005
23,02.2005
24.02.2005

-12
-7
-5
-14
-12
-10

j
JJ

: -8,73

OK
. 1.22.
#include "DateUtils.hpp"

// MonthOf

/* GetString
.
- - */
int GetString(int f, AnsiString *st);
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
ComboBoxl->Style = csDropDownList;
ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("MapT");
ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("MraHb");
ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("");

(7_

ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("");
ComboBoxl->Items->Add("");
// -
ComboBoxl->ItemIndex = MonthOf( Now() ) -1 ;
}
//
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
int h; //
h = FileOpen("meteo.txt",fmOpenRead);
if ( h == -1)
{
ShowMessage(" meteo.txt .");
return;

Memol->Lines->Clear();
//
AnsiString st; // ,
int Is;

//

TDateTime aDate;

//

float temp;
int nMonth;

//
//

int n = 0;

// ( )

float sum = 0 ; //
float sred;

//

AnsiString buf;
/* :

1.

68
-.

: .. -; - */
do
Is = GetString(h,&st); //
if ( Is I 0)
{
nMonth = MonthOf (StrToDate(st)) - 1; //
buf = st;
Is = GetStringfh,&st); //
temp = StrToFloat(st);
if ( nMonth == ComboBoxl->ItemIndex )

sum = sum + temp;


buf = buf + "

" + st;

Memol->Lines->Add(buf);

} while ( Is != 0);
FileClose(h);
if ( n != 0 )
sred = sum / n;
Labell->Caption = " : " +
FloatToStrF(sred,ffGeneral,3,2);
else
Labell->Caption = " "
" " + ComboBoxl->Text,}

//
void

fastcall TForml::ComboBoxlChange(TObject *Sender)

{
Labell->Caption = "";
Memol->Text = "";

// GetString
// .
// - -
int GetString(int f, AnsiString *st)
{
unsigned char buf[256]; // ()
unsigned char *p = buf;
int n;

/ / -

//

i n t l e n = 0 ; / /

//
do
n = FileReadff, , 1 ) ;
while ((n != 0) && (* == '

'));

while (( != 0 ) && ( * ! = ' ' ) )


{
if ( * == '\')
{
= F i l e R e a d ( f , , 1 ) ; / /
break;

++;
n = FileRead(f, p, 1);

'\'

FileRead)

70

.
* = ' \ 0 ' ;
if

( l e n !=0 )
s t - > p r i n t f ( " % s " , buf) ;

return l e n ;
}


.
stringGrid (. 1.23).

stringGrid , .

. 1.23. StringGrid
,

//
fastcall TForml::TForml(TComponent* Owner)
: TFormfOwner)
// *** ***
StringGridl->Options

goEditing

goTabs;

//
// <Tab> -

//
StringGridl->Cells[O][0] = "";
StringGridl->Cells[l][0] = "";
StringGridl->Cells[2][0] = "";
//
StringGridl->ColWidths[0] = 70;
StringGridl->ColWidths[l] = 70;
StringGridl->ColWidths[2] = 200;

//
void _fastcall TForml::StringGridlKeyPress(TObject *Sender,
char &Key)
{
int cRow, cCol;
if ( Key == VKJXETURN )
{
//
cRow = StringGridl->Row;
cCol = StringGridl->Col;
if ( cCol < StringGridl->ColCount - 1 )
StringGridl->Col = StringGridl->Col + 1;
else
if ( cRow < StringGridl->RowCount - 1 )
{
StringGridl->Row = StringGridl->Row + 1;
StringGridl->Col = 1 ;

//
void
fastcall TForml::ButtonlClick(TObject *Sender)

1.

72

//
StringGridl->Row = StringGridl->RowCount-l;

//

//
StringGridl->RowCount++;
StringGridl->Row =
StringGridl->RowCount-l;

//
//

//
void _fastcall TForml::FormCloseQuery(TObject *Sender, bool
&CanClose)
{
int f; //
/* fmCreate, ,
, ,
, */
if ( FileExistsC'tabl.grd") )
f = FileOpen("tabl.grd",fmOpenWrite);
else
f = FileCreateC'tabl.grd");
if ( f != -1 )
//
for (int i = 1; i < StringGridl->RowCount;
{

AnsiString st = StringGridl->
Rows[i]->DelimitedText +"\r\n
FileWriteff,st.c_str(), st.Length());

}
FileClose(f);

73

else
//
ShowMessage ('' ");
}
int GetLine(int f, AnsiString *st); //
//
void

fastcall TForml::FormActivate(TObject *Sender)

{
int f;

//

AnsiString st;

//

bool fl = true; // true -


if (( f = FileOpen("tabl.grd",fmOpenRead)) == -1 )
return;
//
//
while ( GetLine(f, &st) != 0)
{
//
if ( fl )
{
StringGridl->Rows[StringGridl->Row]->
DelimitedText = st;
fl = false;
}
else
{
StringGridl->RowCount++;
StringGridl->Row = StringGridl->RowCount-l;
StringGridl->Rows[StringGridl->Row]->
DelimitedText = st;

1.

74

}
FileClose(f);

//
// " "
// - -

int GetLine(int f, AnsiString *st)


unsigned char buf[256]; // ()
unsigned char *p = buf;
int n;

//

// - ( - FileRead)

int len = 0; //
n = FileRead(f, p, 1 ) ;
while ( n != 0 )
if ( * == '\')
n = FileRead(f,

, 1 ) ; / /

break;
len++;
++;
n = FileRead(f, p, 1 ) ;

* = '\0';
if ( len !=0)
st->printf("%s", buf) ;
return len;

'\'

75


MEdit (Micro Editor) RichEdit, MainMenu, ToolBar, SpeedButton, OpenDialog
saveDialog, . . 1.24,
RichEdit . 1.6.
MEedit,

. MEedit . 1.25.
MEdit -

SpeedButtoni SpeedButton2
ToolBar!
MainMenui
RIchEditi

OpenDialogi

j!|

SaveDialog!

. 1.24. MEdit
1.6.

Align

alClient

BorderStyle

bsNone

ScrollBars

ssVertical

Wordwrap

true

RichEdit

76

1.
MEdit

Image! M

Labeli

. C++Builder.
RichEdit,
MainMenu, ToolBar, SpeedButton, OpenDialog, SaveDialog.

Label2Beveli -

Ok

Buttoni

. 1.25. MEedit
//

*** (MEd.itFrm.cpp) ***

#include "about.h" //
TForml *Forml;
AnsiString aFileName; //
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
aFileName = "";
/* Click

!
Click / /,
- . */
SpeedButtonl->OnClick = imOpenClick;
SpeedButton2->0nClick = imSaveClick;

//
bool
fastcall TForml::SaveText()


// SaveText false,
//
//
if ( aFileName == "" )
{
//
//SaveDialogl->FileName = "Text.txt";
SaveDialogl->Options

ofPathMustExist
ofOverwritePrompt;

if ( SaveDialogl->Execute() )
aFileName = SaveDialogl->FileName;
else
return false; //
//
}
//
RichEditl->Lines->SaveToFile(aFileName);
return true;

// /
void
fastcall TForml::imOpenClick(TObject *Sender)
{
int r;
// ,
if ( RichEditl->Modified )
{
//
= MessageDlg(" .\"
" ?",
mtWarning, TMsgDlgButtons ()
mbNo mbCancel, 0 ) ;
if ( r == mrCancel )

mbYes

1.

78

// Cancel
// return;
// Yes
if ( ( == mrYes ) && ( ! SaveText() ))
return;

/ /
OpenDialogl->FileName = "*.txt";
OpenDialogl->Options

ofPathMustExist
ofFileMustExist;

if ( OpenDialogl->Execute() )
{
RichEditl->Lines->LoadFromFile(OpenDialogl->FileName);
RichEditl->Modified = false;
Fomnl->Caption = "MEdit - " +

OpenDialogl->FileName;

aFileName = OpenDialogl->FileName;

// /
void

fastcall TForml::imSaveClick(TObject *Sender)

{
//
if ( SaveText() )
{
RichEditl->Modified = false;
Forml->Caption = "MEdit - " + aFileName;

// /


void

79
fastcall TForml::imExitClick(TObject *Sender)

{
Forml->Close();
/* FormCloseQuery,
,
*/

// " "
void

fastcall TForml::FormCloseQuery(TObject *Sender,


bool &CanClose)

{
int r;
if ( RichEditl->Modified ) //
{
= MessageDlg(" .\n"
" ?",
mtWarning, TMsgDlgButtons()

mbYes

mbNo

mbCancel, 0 ) ;

switch ( r )
{
case mrYes : // Yes
if ( ! SaveTextO )
CanClose = false;

//

break;
case mrCancel : // Cancel
CanClose = false; //
//

1.

80

// /
void

fastcall TForml::imToolBarClick(TObject *Sender)

{
// /
ToolBarl->Visible = ! ToolBarl->Visible,// / "" /
//
imToolBar->Checked = ! imToolBar->Checked;

// /
void
fastcall TForml::imAboutClick(TObject *Sender)
{
TAboutForm *AboutForm;
// Position AboutForm
// poOwnerForm
AboutForm = new TAboutForm (this);
AboutForm->ShowModal();
delete AboutForm;

/* " " (about.cpp).


( iinclude "about.h")
(MEditFrm.cpp) */
//
void
fastcall TAboutForm: :ButtonlClick(TObject *Sender)
ModalResult = mrOk;


,
.


( image), () Canvas.

(, , . .)
, canvas .

, ,
L i n e , E l l i p s e , R e c t a n g l e . .,

Canvas.

,
Line, E l l i p s e , Rectangle . .,
Brush canvas.

,
Textout Font canvas.


onPaint.

, ,

1.

82

(. 1.26). . , ,
, ,
, .

. 1.26.

Graphics::TBitmap *bgp; //
AnsiString sMonth[] =

("","","","",

"","","",
"","","",
"","",""};
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
bgp = new Graphics::TBitmap();
try
bgp->LoadFromFile("sky.tamp");

83

c a t c h (EFOpenError &e)

// Paint
void
fastcall TForml::FormPaint(TObject *Sender)
{
int h;

// ()

AnsiString mes;

//

int wt,ht;

// ( )

int ,;

//
//

h = HourOf( Now() );
if ( h <= 4 ) mes = " !";
else if ( h < 12 ) mes = " !" ;
else if ( h <= 16) mes = " !" ;
else mes = " !";
Forml->Font->Name = "Times New Roman";
//Forml->Font->Color = clBlue;
Forml->Canvas->Font->Size = 20;
//
wt Canvas->TextWidth(mes);
ht = Canvas->TextHeight(mes);
x = (ClientWidth - wt) / 2;
= ClientHeight / 2 - ht;
//
Canvas->Draw(0,0,bgp);
//

1.

84
Canvas->Brush->Style = bsClear;
Canvas->TextOutA(x,y,mes);

= + ht; //
//
//
mes = FormatDateTime(" d", Ncw() );
mes = mes + " " + sMonth[MonthOf( Now())] + ", "
FormatDateTime("dddd", Now() );
/* 4
*/
Canvas->Font->Size -= 4;
wt = Canvas~>TextWidth(mes);
ht = Canvas->TextHeight(mes);
x = (ClientWidth - wt) / 2;
= + 6;
Canvas->TextOutA(x,,mes);

//
void

fastcall TForml::FormResize(TObject *Sender)

{
Forml->Refresh(); //


(. 1.27)
.

85

, , !

. 1.27.
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)

{
Canvas->Font->Name = "Tahoma";
Canvas->Font->Size = 12;

void

fastcall TForml::FormPaint(TObject *Sender)

{
tdefine WB 140
#define HB 80
#define D

36

//
//
//
i

int x,y;
AnsiString st = ", , !";
//
= (ClientWidth - WB) / 2;
= (ClientHeight - HB ) / 2 - Canvas->Font->Size;
//
Canvas->Brush->Color = (TColor) RGB(255,255,255);
Canvas->FillRect( Rect(x,y,x+WB,y+HB) );

86

1.
int xl = (ClientWidth - Canvas->TextWidth(st)) / 2;

/* ,
Ellipse , ,
Brush->Style bsClear */
Canvas->Brush->Style = bsClear;
//
Canvas->TextOutA(xl,y+HB+6,st);
Canvas->Pen->Width = 2; // -
//
// 3.2 * D - , 1-
//
= + (WB - 3.2 * D) / 2;
y=y+(HB-1.6*D)/2;
Canvas->Pen->Color = (TColor) RGB(0,0,225);

//

Canvas->Ellipse(x,y,x+D,y+D);
x = x + 1.1* D,Canvas->Pen->Color = clBlack;

//

Canvas->Ellipse(x,y,x+D,y+D);
X = x + 1.1 * D;
Canvas->Pen->Color = (TColor) RGB(255,0,0);

//

Canvas->Ellipse(x,y,x+D,y+D);
//
x = x - D * 0.55;
= + 0.6 * D;
Canvas->Pen->Color = (TColor) RGB(0,128,0);
Canvas->Ellipse(x,y,x+D,y+D);

//

87

X = X - 1.1 * D;
Canvas->Pen->Color = (TColor) RGB(250,217,25);

//

Canvas->Ellipse(x,y,x+D,y+D);

//
void
fastcall TForml::FormResize(TObject *Sender)
{
Forml->Refresh();

(. 1.28) , .
, , , ,
, .


28,1528,15
28,11
28,08
28

27,98
27,94

^ ^ 5

. 1.28.
f l o a t d a t a [ ] = {27.98, 2 8 . 0 1 , 2 7 . 9 6 , 27.96., 2 8 . 1 1 , 2 8 . 0 8 ,
28.00, 27.98, 28.15, 28.15, 28.11, 27.94,
27.86, 27.88, 27.95,

27.95};

1.

88

AnsiString Title = " ";


void

fastcall TForml::FormPaint(TObject *Sender)

{
int x,y;
//
Canvas->Font->Name = "Tahoma";
Canvas->Font->Size = 1 2 ;
x = (ClientWidth - Canvas->TextWidth(Title)) /2;
Canvas->Brush->Style = bsClear;
Canvas->TextOutA(x,10,Title);
//
int n;

//

int wCol; //
#define MC 5 //
n = sizeof(data) / sizeof(float);
wCol = (ClientWidth - (n - 1)*MC - 20) / n;
x = 10;
= ClientHeight - 20;
//
int min,max;

// , ,

min = 0 ;

//

max = 0 ;

//

for (int i = 1; i < n; i++)


if (datati] < data[min]) min = i;


if (data[i] > data[max]) max = i;

/*
, .
,
. */
bool frmin = true; // true -
int h; //
//
// ClientHeight - 90
Canvas->Font->Size -= 2;
for ( int i = 0; i < n; i++)
{
if (I frmin)
h = (ClientHeight - 90) * data[i]/data[max];
else
/* .

10 */
h = (ClientHeight - 90) * (data[i] data[min])/(data[max] - data[min]) + 10;
Canvas->Brush->Style = bsSolid;
Canvas->Brush->Color = clLime;
Canvas->Rectangle(x,y,x+wCol,y-h); //
//
AnsiString st;
st = FloatToStrF(data[i],ffGeneral,5,2);
Canvas->Brush->Style = bsClear,- //
// -

1.

90
Canvas->TextOutA(x,y-h-20,st);
= + wCol + ;

//
void

fastcall TForml::FormResize(TObject

*Sender)

{
F o r m l - > R e f r e s h ( ) ; / /

(. 1.29) . , ,
. ,
( ) .
-iDlxj

W

23,15
28,11

28,11

. 1.29.

91_

float data[] = {27.98, 28.01, 27.96, 27.96, 28.11, 28.08,


28.00, 27.98, 28.15,28.15, 28.11, 27.94, 27.86, 27.88, 27.95,
27.95};
AnsiString Title = " ";
fastcall TForml::TForml(TComponent* Owner)
: TFormfOwner)

void

fastcall TForml::FormPaint(TObject *Sender)

{
int n;

//

int x,y;

//

int dx;

// X

int x0,yO;

//
//

//
Canvas->Font->Name = "Tahoma";
Canvas->Font->Size = 12, = (ClientWidth - Canvas->TextWidth(Title)) /2;
Canvas->Brush->Style = bsClear;
Canvas->TextOutA(x0,10,Title);
n = sizeof(data) / sizeof(float);
//
int min,max; // . ,
min = 0 ;

//

max = 0 ;

//

for (int i = 1; i < n; i++)

4 3. 1241

1.
if (datafi] < data[min]) min = i;
if (data[i] > data[max]) max = i;

/*


, .
,
. */

bool frmin = true; // true -


//
dx= (ClientWidth - 20) / (n-1);
Canvas->Font->Size -= 2;
Canvas->Pen->Color = clGreen;
Canvas->Pen->Width = 1;
xO = 10;
yO = ClientHeight - 10;
x = xO;
dx= (ClientWidth - 20) / (n-1);
for ( int i = 0; i < n; i++)
{
/*
ClientHeight - 90 */
if (! frmin)
= 0 + (ClientHeight- - 90) * data [i]/data[max] ;
else
//
= yO-(ClientHeight - 90) * (data[i] data[min])/(data[max] - data[min])-10;

93
/ /

Canvas->Rectangle(-2,-2,+2,+2);
if

( i != 0)
Canvas->LineTo(x,y);

// ** **
/* .. TextOutA
(, LineTo,

(,) */
if ( ( i == 0) || (data[i] != data[i-l]))
AnsiString st;
st = FloatToStrF(data[i] , ffGeneral, 5,2) ,Canvas->Brush->Style = bsClear;

//

// -
Canvas->TextOutA(x,y-20,st);
Canvas->MoveTo(x,y);
x += dx;
}

' .

//
void

fastcall TForml::FormResize(TObject *Sender)

{
Forml->Refresh(); //


(. 1.30)
,
. "

1.

94

" ( ), . . .
'


, 40%
[
|

| , 24%
| , 23%
| , 7%
| , 2,5%
, 0,5%

. 1.30.
#include "Math.h" // sin cos
TForml *Forml;
#undef PEOPLE

// " "

#define ENERGY

// " "

#ifdef PEOPLE
#define HB 6
define OBR
/*
( ) */
// *** ***
AnsiString Title = " ";
//

95

float datafHB] = {1.25e9,19,2746,2166,1726,146};


// ()
float pr[HB];
// *** ***
AnsiString dTitle[HB] = {"","","",
"","",""};
// *** ***
TColor cl[HB] = {clLime, clBlue, clMaroon,
clGreen, clYellow, clTeal};
#endif
#ifde ENERGY
#define HB 6
#undef OBR
/*
- data 100 */
// *** ***
AnsiString Title = " ";
float data[HB] = {0.5,2.5,7,23,24,40}; //
float pr[HB];

//
// ()

// *** ***
AnsiString dTitle[HB] - ("",
" ",
" ",
"","",""};
// *** ***
TColor cl[HB] = {clLime, clBlue, clPurple, clSkyBlue,
clYellow, clTeal};

1,
#endif
#define R 80

//

#define D 160 //
#define TORAD 0.0174532 // .
//
/* ,
Pi/180 */
//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
int i,j;
// ""
float bd;
AnsiString bt;
TColor be;.
for (i = 0; i < KB; i ++)
for (j = 0 ; j < HB-1; j++)
if (data[j+l] < datatj])
// i- i+1-
bd = datatj];
datatj] = data[j+l];
data[j+l] = bd;
bt = dTitletj];
dTitletj] = dTitle[j+l];
dTitle[j+l] = bt;
be = cl[j];

97
cl[j+l] = be;

#ifdef OBR
// -
//
float sum = 0;
for (i = 0; i < HB; i++)
sum += data[i];
for (i = 0; i < HB; i++)
pr[i] = ( data[i] / sum) * 100;
#else
//
for ( i = 0; i < HB;
pr[i] = data[i];
#endif

// Paint
void

fastcall TForml::FormPaint(TObject *Sender)

{
int x,y;
int i;

// *** ***
Canvas->Font->Name = "Tahoma";
Canvas->Font->Size = 12;
x = (ClientWidth - Canvas->TextWidth(Title)) /2;
Canvas->Brush->Style = bsClear;
Canvas->TextOutA(x,15,Title);

98

1.
// *** ***
// , -
// , ,
//
= (ClientWidth - D) /2 - R;
= 15 + Canvas->TextHeight(Title) + 20;
int xO,yO; // ()
int xl,yl; //
int x2,y2; //
int al,a2; // ,
//

//

int n;

// ()

//

n = sizeof(data) / sizeof(float);
xO = x + R;
yO = + R;
al = 0; //
//Canvas->Pen->Style = psClear;
for (int i = 0; i < HB; i++ )
/* -
,

.
,
*/
if (i != -1)
2 = ( al + 3.6 * pr[i]);

9
else
2 = 359;
//
xl = + R * cos (2 * TORAD);
yl = + R * sin (2 * TORAD);
//
2 = + R * cos (al * TORAD);
2 = + R * sin (al * TORAD);
if ( abs(al-a2) <= 6 )
Canvas->Pen->Style = psClear;
else
Canvas->Pen->Style = psSolid;
Canvas->Brush->Color =
Canvas->Pie(x,y,x+D,y+D,xl,yl,x2,y2);
al =a2; //

//
Canvas->Font->Size -= 2;
int dy = Canvas->TextHeight("a");
x = x + D + 40;
= + 20;
for (i =HB-1; i >=0; i)
{
Canvas->Brush->Color = cl[i];
Canvas->Rectangle(x,y,x+40,y+dy);
Canvas->Brush->Style = bsClear;
Canvas->TextOutA(x+50,y,dTitle[i]+
", " + FloatToStrF(pr[i],ffGeneral,2,2)

100

1.
= + dy +10;

void

fastcall TForml::FormResize(TObject *Sender)


Forml->Refresh();


(. 1.31) JPEG, . ()
.
-.
. 1.32, imagei . 1.7.
-
interval .
ftff

[ !

f~

. 1 . 3 1 .
-

101

\'

Label!

'

Buttoni

Button2


CheckBoxi

I
.:::!:::

Imagei

Timerl

. 1.32.

1.7. imagei

Autosize

false

Stretch

false

Proportional

true

#include <FileCtrl.hpp>

// SelectDirectory

tinclude <jpeg.hpp>

//
// JPEG

AnsiString aPath;

// ,
//

TSearchRec aSearchRec; // -

102

1.

void

fastcall TForml::FormCreate(TObject *Sender)


aPath = ""; // - ,
//
FirstPicture(); // ,
//

//
void

fastcall TForml::ButtonlClick(TObject *Sender)


if (SelectDirectory(" , "
" ", "", aPath) ! =
//
aPath = aPath + " \ \";
if ( FirstPicture() ) //
CheckBoxl->Enabled = true;
else
Labell->Caption = " " + aPath +
" jpg-." ;

//
bool
fastcall TForml::FirstPicture()
{
Imagel->Visible - false;
Button2->Enabled = false;

// Imagel
//

CheckBoxl->Enabled = false;
CheckBoxl->Checked = false;
Labell->Caption =
if (FindFirst(aPath+ "*.jpg", faAnyFile, aSearchRec) == 0)
Imagel->Picture->LoadFromFile(aPath+aSearchRec.Name);

103
Imagel->Visible = true;
Labell->Caption = aPath + aSearchRec.Name;
if ( FindNext(aSearchRec) == 0 )

// . .

//
Button2->Enabled = true; //
//
CheckBoxl->Enabled = true;
return true;
}
}
return false;

//
fastcall TForml::NextPicture()

bool

Imagel->Picture->LoadFromFile(aPath+aSearchRec.Name);
Labell->Caption = aPath + aSearchRec.Name;
if ( FindNext(aSearchRec) != 0 )

// .
//

//
Button2->Enabled = false;

//
//

CheekBoxl->Enabled = false;
return false;
return true;

//
void

fastcall TForml::Button2Click(TObject *Sender)

1.

104
NextPicture();

// ""
void

fastcall TForml::CheckBoxlClick(TObject *Sender)

{
if ( CheckBoxl->Checked)
Timerl->Enabled = true;

// -

else
Timerl->Enabled = false; //

/ /
void

f a s t c a l l T F o r m l : : T i m e r l T i m e r ( T O b j e c t *Sender)

{
if ( ! NextPicture())
Timerl->Enabled = false;

(. 1.33)
, .

. 1.33.

105

#include "DateUtils.hpp" // SecondOf, MinuteOf


// HourOf
include "math.h"

// sin cos

/*
SinCos, ,
. ,
^include "Math.hpp" */
tdefine R 75
int

//

, ;

//

int ahr,amin,asec;

// ()

fastcall TForml::TForml(TComponent* Owner)


: TFormfOwner)
{
TDateTime t;
//
//
ClientHeight = (R + 30)*2;
ClientWidth

= (R + 30)*2;

R + 30;

R + 30;

Now();

/* .
() , , 2
3, -30 .
- 6 .
12- */
ahr

90 - HourOf(t)*30-(MinuteOf(Today() ) / 12) *6;

1.

106
amin
asec

=
=

90 - MinuteOf(t)*;
90 - SecondOf( Today() )*6;

Timerl->Interval =

1000; //

Timerl->Enabled

// 1
true; //

// (0,0)
// X. 1 .
void
fastcall TForml: .-Vector (int xO, int yO, int a, int 1)
{
// x0,y0 -
/ / a -
// 1 -
#define TORAD 0.0174532 //
//
int , ;

//

Canvas->MoveTo(x0,0);
= + 1 * cos(a*TORAD);
0 - 1 * sin(a*TORAD);
Canvas->LineTo(x,y);

//
void
fastcall TForml::FormPaint(TObject *Sender)
int x, ;
int a;
int h;

//
// (0,) (,)
//

TBrushStyle bs; //
TColor pc;
//

107

int pw;

//

bs

Canvas->Brush->Style;

pc

Canvas->Pen->Color;

pw

Canvas->Pen->Width;

Canvas->Brush->Style
Canvas->Pen->Width

=
=

Canvas->Pen->Color =

bsClear;

1;
clBlack;

a = 0; // 3- ,
//
h = 3; // 0 - 3
//
while ( < 360 )
{
= +

R * cos( * TORAD);

= -

R * sin( * TORAD);

Forml->Canvas->MoveTo(,);
if ( (a % 30) 0 )
{
Canvas->Ellipse(-2,-2,+3,+3);
//
= +

(R+15) * cos(a * TORAD);

= -

(R+15) * sin(a * TORAD);

Canvas->TextOut(x-5,y-7,IntToStr(h));
h--;
if ( h == 0 ) h = 12;
}
else
Canvas->Ellipse (x.-l, y-1, x+1, y+1) ;
a = a + 6; // 1 - 6
}
//

108

1.
Canvas->Brush->Style
Canvas->Pen->Width

= bs;
= pw;

Canvas->Pen->Color = pc;
DrawClock();

void

fastcall TForml::DrawClock(void)

TDateTime t;
// 6 ,
// - 30.
//
Canvas->Pen->Color =
Canvas->Pen->Width

clBtnFace;

= 3;

//
Vector(xO,yO, ahr, R-20);
//
Vector(xO,yO, amin, R-15);
//
Vector(xO,yO, asec, R-7);
t

Now();

//
ahr

90 - HourOf(t)*30-(MinuteOf(t)% 12)*6;

amin

90 - MinuteOf(t)*6;

asec

90 - SecondOf(t)*6;

//
//
Canvas->Pen->Width

Canvas->Pen->Color =

3;
clBlack;

109

Vector(xO,yO,

a h r , R-20);

//
Canvas->Pen-:>Width

Canvas->Pen->Color =

2;
clBlack;

Vector(xO,yO, amin, R-15);


//
Canvas->Pen->Width

= 1;

Canvas->Pen->Color =

clYellow,-

Vector(xO,yO, asec, R-7);

/ / '
void

f a s t c a l l T F o r m l : : T i m e r I T i m e r ( T O b j e c t *Sender)

{
DrawClockO ;

-
- , . : (. 1.34),
.
Timer.

. 1.34. -

110

1.

/* "-"

*/
int , ;

//

int dx, dy;

//

int r;

//

TColor cBall; //
TColor cBack; //
int wp, hp;

// ()

//
int rd;

// 0 - ; 1 -
// ; 2 -

int rxl, rx2; // X


int ry;

// Y

int rdx;

//

//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
r = 5;

//

x = ; = 50; //
dx = 1;
dy = 1;
cBall = (TColor)RGB(217, 217, 25); //
cBack = (TColor)RGB(33, 94, 33);
Forml->Color = cBack;
wp = Forml->ClientWidth;
hp = Forml->ClientHeight;

//


//

111

rd = 0;

// ( )

rxl = 100;
2 - 12 5;
ry = Forml->ClientHeight - 20; //
// 20
rdx = 2; //
//
Timerl->Interval = 10;
Timerl->Enabled = true,-

void

fastcall TForml::FormPaint(TObject *Sender)

{
//
Forml->Canvas->Pen->Color = clRed;
Forml->Canvas->Rec tangle(rxl, ry, rx2, ry+1) ;

/ /
void

fastcall TForml::TimerlTimer(TObject *Sender)

{
//
Forml->Canvas->Pen->Color = ;
Forml->Canvas->Ellipse(x,y,x+r,y+r);
// ** **
if ( dx > 0 )
{
//
if

( x + d x + r > w p )

d x = - dx;

1.

112
else
//
( x + d x - r < O ) d x = -dx;

if

if ( dy > 0 )
{
//
if (( >= rxl) && ( <= 2 -) && ( == - - 1) )
//
dy = - dy;
else
if ( + dy + > Forml->ClientHeight ) dy = -dy;
}
else
{
//
if ((x >= rxl) && (x <= rx2) && (y >= ry - r) && (y <
ry + r) )
{
//
// .
// , .
Forml->Canvas->Pen->Color = clRed;
Forml->Canvas->Rectangle(rxl, ry, rx2, ry+1);
}
if ( + dy - r < 0 ) dy = -dy;
}
x += dx;
+= dy;
//
Forml->Canvas->Pen->Color = cBall;
Forml->Canvas->Ellipse(x,y,x+r,y+r);

/3

/ / ***
if

***

( r d != )

{
/ /

//

"

//

(. FormKeyDown )

"

if

( r d == 1 )

"

"

{
//
if

( rx2 < wp )

{
/ /

Forml->Canvas->Pen->Color = cBack,Forml->Canvas->Rectangle(rxl, ry,

r x l + rdx,

ry + 1 ) ;
//
Forml->Canvas->Pen->Color = clRed;
Forml->Canvas->Rectangle (rx2, ry, rx2 + rdx,
ry + 1) ;
rxl += rdx;
rx2 += rdx;

else
//
if (rxl > 1 )
{

/ /

Forml->Canvas->Pen->Color = cBack;
Forml->Canvas->Rectangle (rx2, ry, rx2 - rdx,
ry+1);
//
Forml->Canvas->Pen->Color = clRed;
Forml->Canvas->Rectangle(rxl - rdx, ry, rxl +
rdx, ry+1);

114

1.
rxl -= rdx;
rx2 -= rdx;
}

}
}
//
void

fastcall TForml : : ForrriKeyDown (TOb


ject *Sender,
WORD &Key, T ShiftState Shift)

if

( r d != )
/ /

return,s w i t c h ( Key )
case VK_LEFT : // ()
rd = 2; break;
case VK_RIGHT : // ()
rd = 1; break;

//
void

fastcall TForml::FormKeyUp(TObject *Sender, WORD &Key,


TShiftState Shift)

{
r d = 0;


(. 1.35) ( ).

115

. 1.35.

(. 1.36) .
( ),
.

. 1.36.
//
fastcall TForml::TForml(TComponent* Owner)
: TFormlOwner)
// bmp-
back = new Graphics::TBitmap();
back->LoadFromFile("sky.bmp");
// ()
//

116

1.
ClientWidth = back->Width;
ClientHeight = back->Height;
//
sprite =

new Graphics::TBitmap();

sprite->LoadFromFile("plane.bmp");
sprite->Transparent = true;
//
kadr new Graphics::TBitmap();
kadr->LoadFromFile("plane.bmp");

//
x=-40; // "" -
=20;
Timerl->Interval = 10;
Timerl->Enabled = true;

//
void

fastcall TForml::TimerlTimer(TObject *Sender)

{
TRect badRect; // ,
//
TRec t

f rameRec t ;

badRect = Rect(x,y,x+sprite->Width,y+sprite->Height)
frameRect = Rect(0,0, kadr->Width, kadr->Height);
#ifdef ONCANVAS


//

1J7_
***

//

***

""

Canvas->CopyRect(badRect,back->Canvas,badRect);
/ /
+=2;
if ( > ClientWidth)
{
/ /

//
= -20;
= random(ClientHeight - 30);

/ /

//

//


OnTimer,

//

, ,

Interval

T i m e r l - > I n t e r v a l = random(20) + 10; / /


//

""

10 29

}
Canvas->Draw(,,sprite);
#else
//

//
//
//

kadr->Canvas->CopyRect(frameRect,
/ /

kadr->Canvas->Draw(0,0,sprite);
/ /

back->Canvas,badRect);

1.

118
Forml->Canvas->Draw(x,y,kadr);
//
+= 1;
if ( > ClientWidth)

//
//

= -20;
= random(ClientHeight - 30); //
//
// OnTimer, , ,
// Interval
Timerl->Interval = random(20) + 10; //
// "" 10 29
#endif
}
void

fastcall TForml::FormPaint(TObject *Sender)


//
Canvas->Draw(0,0,back);

//

(. 1.37)
. ( )
. "" - .
, , , .

119

4 ,

.. + +Builder. -'

. 1.37.
Graphics::TBitmap *banner;

// -
//

int x,y;

//

int pause;

//
// ( )
//

int xp;

//

TColor be;

//

//
fastcall TForml::TForml(TCoinponent* Owner)
: TForm(Owner)
banner = new Graphics::TBitmap();
//
banner->LoadFromResourceID((int)HInstance,101);
be = banner->Canvas->Pixels[O][0]; //
x = Forml->ClientWidth; // "" -
//
= 0;
// X
//
xp = (Forml->ClientWidth - banner->Width) / 2;
if (xp < 0 ) xp = 0;

120

1.

//
void
fastcall TForml::TimerlTimer(TObject *Sender)
if ( pause > 0 )
pause;
return;

Forml->Canvas->Draw(x,,banner);
if ( x == xp)
pause = 100; //
// 100

if ( < - banner->Width)
= Forml->ClientWidth;

// Paint
void
fastcall TForml::FormPaint(TObject *Sender)
TColor b,p;
b = Canvas->Brush->Color,- //
= Canvas->Pen->Color;

//
//

//
Canvas->Brush->Color = be;
Canvas->Pen->Color = be;
Canvas->Rectangle(O,O,ClientWidth,banner->Height);

121

Canvas->Brush->Color = b ; / /

Canvas->Pen->Color = p ;

/ /

//
void

fastcall TForml::FormResize(TObject *Sender)

{
/ /
//

= (Forml->ClientWidth - banner->Width)
if

/ 2,-

(xp < 0 ) = 0;


,
.
, .
,
, . 1.38.

. 1.38. ()
()

122

1.

//
void

fastcall TForml::FormCreate(TObject *Sender)

{
back = new Graphics::TBitmap(); // //
//
try //
{
Forml->back->LoadFromFile("canvas.bmp");
}
catch (EFOpenError &e)
{
return,-

//
void

fastcall TForml::Background()

,.

{
int x=0,y=0; //
//
if ( back->Empty ) //
return;
do {
do {
Canvas->Draw(x,y,back);
x += back->Width;
}
while (x < ClientWidth);

123

= 0;
+= back->Height;
}
while ( < ClientHeight);

// Paint
void

fastcall TFormlt:FormPaint(TObject *Sender)

{
B a c k g r o u n d ( ) ; / /

5 3. 1241


,
, .


Animate MediaPlayer.

MediaPlayer ,
.
Animate , .

WAV
Windows (. 1.39) ( WAV, RMI MID),
Windows\Media.

Microsoftwav
ir_begin.wav
ir_end.wav
ir_inter.wav
Windows.wav
Windows.wav
ringin.wav
ringoutwav
start wav
chimes.wav
chord.wav
ding, wav
.
W

. 1.39. Windows
,
WindowsVMedia

125

.
,

. . 1.40.
Windows


Label2

ListBoxi

CheckBoxi
MediaPlayeri-

V
I

. 1.40. Windows
/ /
void
f a s t c a l l TForml::FormCreate(TObject *Sender)
{
char *wd; // Windows
wd = (char*)AllocMem(MAX_PATH);
GetWindowsDirectory(wd,MAX_PATH);
SoundPath = wd;
// Media
SoundPath = SoundPath + "WMediaW" ;
//

126

1.
TSearchRec sr;
if (FindFirst( SoundPath + "*.wav", faAnyFile, sr) == 0 )
// WAV
ListBoxl->Items->Add(sr.Name); //
//
// WAV ?
while (FindNext(sr) == 0 )
ListBoxl->Items->Add(sr.Name);

if (FindFirstf SoundPath + "*.mid", faAnyFile, sr) == 0 )


{
// MID
ListBoxl->Items->Add(sr.Name); //
//
// MID ?
while (FindNext(sr) == 0 )
ListBoxl->Items->Add(sr.Name);

if (FindFirst( SoundPath + "*.rmi", faAnyFile, sr) == 0


{
// RMI
ListBoxl->Items->Add(sr.Name); //
//
// RMI ?
while (FindNext(sr) == 0 )
ListBoxl->Items->Add(sr.Name);

//
if ( ListBoxl->Items->Count != 0)

727

{
Label2->Caption = ListBoxl->Items->Strings[1];
ListBoxl->ItemIndex = 0;
MediaPlayerl->FileName = SoundPath + ListBoxl->
Items->Strings[1] ;
MediaPlayerl->Qpen();
MediaPlayerl->Play();

//
void
fastcall TForml::ListBoxlClick(TObject *Sender)
{
if ( (CheckBoxl->Checked) &&
( MediaPlayerl->Mode == mpPlaying ) )
return;
Label2->Caption = ListBoxl->Items->
Strings[ListBoxl->ItemIndex];
MediaPlayerl->FileName = SoundPath + Label2->Caption;
MediaPlayerl->Open();
if ( ! CheckBoxl->Checked)
MediaPlayerl->Notify = false;
MediaPlayerl->Play();

/* Notify
, Play
Notify true */
void
fastcall TForml::MediaPlayerlNotify(TObject *Sender)
{
if ( ListBoxl->ItemIndex < ListBoxl->Items->Count )
{
ListBoxl->ItemIndex = ListBoxl->ltemlndex + 1;

1.

128

Label2->Caption = ListBoxl->Items->
Strings[ListBoxl->ItemIndex];
MediaPlayerl->FileName = SoundPath + Label2->Caption;
MediaPlayerl->Open()j
if ( ! CheckBoxl->Checked)
MediaPlayerl->Notify = false;
MediaPlayerl->Play();

MP3

Player

Player (. 1.41) .
'S Player
Thoughts o f a dying atheist. mp3
Thoughts ot a wina atheret.mc3
Butterflies and Huiricanes.mp3
Muse Map of your head.mp3
Hypernnusic.mp3
Hyper chondriac music. mp3
Endlessly. mp3
Stockholm syndrome.mp3
Sinn fmflhsnluhnnmn3
2:57

. 1.41.
,

. 1.42. , MediaPlayerl,
( ).
(), , ,
Eject
(speedButtoni). ,
SpeedButton2 SpeedButton4 -

129

speedButtoni speedButton3 ().


Play/Stop (speedButton3)
. : " Play", "
Stop" " Play".
, , 101, 102 103.
. 1.8.
Player
Labell

ListBoxi

TrackBart

SpeedButtoni-

-Timer!

SpeedButton2

SpeedButton3 Speedbutton4

Label2 LabeH

. 1.42. Player
1.8. TrackBarl

Orientation

vrVertical

Min

-65535

ThumbLength

10

TickMarks

tmBoth

Frequency

8192

ShowHint

true

Hint

1.

130
TForml *Forml;
//

fastcall TForml::TForml(TComponent* Owner)


: TForm(Owner)
/ *

MediaPlayer.

MediaPlayerl

(. mp3main.h),
MPlayer.hpp

( include

"MPlayer.hpp"

).

*/
MediaPlayerl new TMediaPlayer(Forml->Handle);

#include "FileCtrl.hpp"

// TSearchRec

AnsiString SoundPath; // -
int min,sec;
int mode = 0 ;

// (, )
// 0 -

""

// 1 - ""
/* vaweOutSetVolume
,
, - .
TVolume,
.

OxFFFF.
*/
union TVolume{
unsigned long Volume;
struct
Word Left;


Word Right;
};
} volume;
//
void

fastcall TForml::FormCreate(TObject *Sender)

{
PlayList("");
//
// ,
waveOutGetVolume(0,&volume.Volume);
TrackBarl->Position = - volume.Left;
ListBoxl->Color = (TColor)RGB(56,176,222);

/ / -,
//

void __fastcall TForml::PlayList(AnsiString path)


{
/ * SearchRec

*/
TSearchRec SearchRec;
ListBoxl->Clear();
/ /

if ( FindFirst(path + "*.mp3", faAnyFile, SearchRec)!= 0 )


{
// -
SpeedButton2->Enabled = false;
SpeedButton3->Glyph->
LoadFrornResourceID( (int)HInstance, 103) ;
SpeedButton4->Enabled = false;

132

1.
Labell->Caption
return,-

//
//
ListBoxl->Items->Add(SearchRec.Name);
// wav
while (FindNext(SearchRec) 0)
ListBoxl->Iterns->Add(SearchRec.Name);
ListBoxl->ItemIndex

0;

Labell->Caption = ListBoxl->Items->
Strings [ListBoxl->ItemIndex];
SpeedButton2->Enabled = false;
if (ListBoxl->Coxmt == 1)
SpeedButton4->Enabled = false;
else
SpeedButton4->Enabled = true;
SpeedButton3->Glyph->
LoadFromResourcelDf(int)HInstance,101);

// -,
// ListBox
void

fastcall TForml::Play()

{
Labell->Caption = ListBoxl->Items->
Strings [ListBoxl->ItemIndex];
MediaPlayerl->FileName = SoundPath +
ListBoxl->Items->Strings [ListBoxl->ItemIndex],
MediaPlayerl->Open();
MediaPlayerl->Play();

133

min = 0;
sec = ;
Timerl->Enabled = true;

//
void
fastcall TForml::Stop()
{
MediaPlayerl->Stop();
Timerl->Enabled = false;
Label2->Caption = "0";
Label4->Caption "00";

// Play/Stop
// ( )
void
fastcall TForml::SpeedButton3Click(TObject *Sender)
{
if ( mode == 1 )
{
SpeedButton3->Glyph->
LoadFromResourcelD((int)Hlnstance, 101)
SpeedButton3->Hint = "";
StopO;
mode = 0;
}
else {
SpeedButton3->Glyph->
LoadFromResourcelD((int)HInstance, 102);
SpeedButton3->Hint = "";
Play();
mode = 1;

1.

134
//
void

fastcall TForml::TimerlTimer(TObject *Sender)

{
//
if ( sec < 59 )
{
sec++;
if ( sec < 10)
Label4->Caption = "0" + IntToStr(sec);
else
Label4->Caption = IntToStr(sec);
}
else
sec = 0;
min++;
Label2->Caption = IntToStr(min)
Label4->Caption = "00";

// ?
if ( MediaPlayerl->Position < MediaPlayerl~>Length )
//
return;
//
Stop();
if ( ListBoxl->ItemIndex < ListBoxl->Count - 1 )
ListBoxl->ItemIndex += 1;
PlayO; //
// -

135

if ( ListBoxl->ItemIndex == ListBoxl->Count - 1 )
SpeedButton4->Enabled = false;
}
else {
// -
SpeedBut ton3->Glyph->
LoadFromResourcelD((int)HInstance, 101);
SpeedButton3->Hint = "";
mode = 0;

// " "
void
fastcall TForml::SpeedButton4click(TObject *Sender)
{
if ( mode == 1 )
Stop();

//

//
ListBoxl->ItemIndex += 1;
Labell->Caption = ListBoxl->
Items->Strings [ListBoxl->ItemIndex];
// , ,
//
if ( ListBoxl->ItemIndex == ListBoxl->Count - 1)
SpeedButton4->Enabled = false,if ( ! SpeedButton2->Enabled

SpeedButton2->Enabled = true;
if ( mode == 1)
PlayO; //
//

136

1.

// " "
void
fastcall TForml::SpeedButton2Click(TObject *Sender)
{
if ( mode == 1 )
Stop();

//
//

ListBoxl->ItemIndex -= 1;
Labell->Caption = ListBoxl->Iteitis->
Strings [ListBoxl->ItemIndex];
// , ,
//
if ( ! SpeedButton4->Enabled )
SpeedButton4->Enabled = true;
if ( ListBoxl->ItemIndex == 0 )
SpeedButton2->Enabled = false;
if (mode == 1 )
PlayO; //
//

iinclude "FileCtrl.hpp"
// Eject -
void
fastcall TForml::SpeedButtonlClick(TObject *Sender)
AnsiString dir;
if ( SelectDirectory(" ","",dir) )
if ( mode = = 1 ) //
Stop () ;

""

737
SpeedButton3->Glyph->
LoadFroirtResourcelD((int)HInstance, 101);
SpeedButton3->Hint = "";
Stop();
mode = 0;

}
SoundPath = dir + "\\";
PlayList(SoundPath);

// ()
void
fastcall TForml::ListBoxlClick(TObject *Sender)
{
if ( MediaPlayerl->Mode ==2) //

{
Stop () ,- //

Play(); //

// , ,
//
if (ListBoxl->ItemIndex == 0 )
SpeedButton2->Enabled = false;
else
SpeedButton2->Enabled = true;
if (ListBoxl->ItemIndex == ListBoxl->Count -1
SpeedButton4->Enabled = false;
else
SpeedButton4->Enabled = true;

include "mmsystem.hpp"

138

1.

//
void

fastcall TForml::TrackBarlChange(TObject *Sender)

{
volume.Left = - TrackBarl->Position,volume.Right = - TrackBarl->Position;
waveOutSetVolume(0,volume.Volume);

MIDI
60 , . 1.43,
MediaPlayer MIDI.
" ", ,
, .
60

**! 60 ,

<Enter>
OK
- 60

Timeri

Label4

II

MediaPlayeri

. 1.43. 60
int pw;

// ""

int rem = 60; //


//
void
fastcall TForml::FormCreate(TObject *Sender)
{
TSearchRec sr;
if

( F i n d F i r s t ( " * . m i d " , f a A n y F i l e , s r ) == 0)

739

{
MediaPlayerl->FileName = sr.Name;
MediaPlayerl->Open();
MediaPlayerl->Play();

Randomize();
pw = RandomRange(100,999); // ""

// ,
void
fastcall TForml::isRight(void)
{
if ( StrToInt(Editl->Text) == pw )
{
Timerl->Enabled = false;
Buttonl->Enabled = false;
Editl->Enabled = false;
MediaPlayerl->Stop();
// !
//PlaySound("Applause.wav", 0, SND_ASYNC);
ShowMessage("!\ " +
IntToStr(60 - rem)+ " ");

//
void
fastcall TForml::EditlKeyPress(TObject *Sender, char
&Key)
{
if

( ( E d i t l - > T e x t . L e n g t h ( ) < 3) &&


( (Key >= ' 0 ' ) Scb (Key <= ' 9 ' ) ) )
return;

if ( Key - VK_RETURN)

140

1.
isRight(); // ,

//
return;

if ( Key == VK._) return;


//
Key = 0;

//
void
fastcall TForml::EditlChange(TObjt *Sender)
{
// OK ,
// ()
if ( Editl->Text.Length() == 3)
Buttonl->Enabled = true,else
Buttonl->Enabled = false;

// OK
void
fastcall TForml::ButtonlClick(TObject *Sender)
{
isRight();

// ,
//

//
void
fastcall TForml::TimerlTimer(TObject *Sender)
rem--;
Label4->Caption = IntToStr(rem);


if

1_

(rem == 0 )

{
// , ,
Timerl->Enabled = false;
Editl->Enabled = false;
Buttonl->Enabled = false;
MediaPlayerl->Stop();
ShowMessage(" , "
" \"
"\"\" - " + intToStr(pw) );

//
void

fastcall TForml::MediaPlayerlNotify(TObject *Sender)

{
/*
Notify true ( Play
Notify true),
Notyfy */
if (Timerl->Enabled)
/* ,
. . */
MediaPlayerl->Play();
}
//
void
fastcall TForml::FormClose(TObject *Sender,
TCloseAction SAction)
{
Timerl->Enabled=false ;
MediaPlayerl->Stop();
MediaPlayerl->Close();

142

1.

Compact Disk Player ( 1)


Compact Disk Player . , -,
CD, , ()
(. 1.44).
Compact Ds
ic Player
1. 3:08
2:47

. 1.44.

,
. . 1.45 ( MediaPiayer ).
Timer!

Shape! Label! Label2

SpeedButtoni SpeedButton2 SpeedButton3


. 1.45. Compact Disk Player ( 1)
// Play/Stop
Graphics::TBitmap *bmPlay;
// Play
Graphics::TBitmap *tmStop;
// Stop
_fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)

143

{
fcmPlay = new Graphics::TBitmap();
hmStop

= new Graphics::TBitmap();

// Play/Stop
fcmPlay->LoadFromResourceID((int)HInstance,101);
fcmStop->LoadFromResourceID((int)HInstance,102);
//
SpeedButton2->Glyph->Assign(bmPlay);

void

fastcall TForml::FormCreate(TObject *Sender)

{
MediaPlayer->Notify = true; // Notify

//
// ,
^define MINUTE(ms) ((ms/1000)/60)
#define SECOND(ms) ((ms/1000)%60)
// Label 1
void

fastcall TForml::TrackInfo()

{
int ms; // ,
AnsiString st;
Track

= MCI_TMSF_TRACK(MediaPlayer->Positicn);

MediaPlayer-XFimeFonnat = tfMilliseconds;
ms = MediaPlayer->TrackLength[Track];
MediaPlayer->TimeFormat = tfTMSF;
st = IntToStr(SECOND(ms));
if ( st.LengthO 1)

144

1.
st

= "" + s t ;

st = " "+ IntToStr(Track) +


". "+ IntToStr(MINUTE(ms)} + ":" + st;
Labell->Caption = st;
}
//
void
fastcall TForml::MediaPlayerNotify(TObject *Sender)
{
switch ( MediaPlayer->Mode )
{
case mpOpen: //
{
SpeedButtonl->Enabled

false;

SpeedButton2->Glyph->Assign(bmPlay);
SpeedButton2->Tag

0;

SpeedButton3->Enabled
Label2->Caption

false;

"00:00";

/*
*/
Timer->Enabled

= True;

}
}
MediaPlayer->Notify

= true;

// :
//
void

fastcall TForml::TimerTimer(TObject *Sender)

{
int

trk;

//

745

int min, sec;

//

AnsiString st;
if ( MediaPlayer->Mode == mpPlaying ) //
{
//
trk

= MCI_TMSF_TRACK(MediaPlayer->Position);

if ( trk != Track ) //
{
Tracklnf();
Track

trk;

if ( Track > 1 )
SpeedButtonl->Enabled

true;

//
// "."

if ( Track == MediaPlayer->Tracks)
SpeedButton3->Enabled

false; //
// "."
//

//
min

= MCI_TMSF_MINUTE(MediaPlayer->Position);

sec

= MCI_TMSF_SECOND(MediaPlayer->Position);

st.printf("%d:%.2d",min,sec);
Label2->Caption = st;
return;

/ *
AudioCD,
,

Mode == mpOpen.
..

Mode == mpStopped

+ -

> 1 */

if ( (MediaPlayer->Mode == mpStopped) &&


(MediaPlayer->Tracks > 1) )

146

1.

{
//
Timer->Enabled = false;
SpeedButton2->Enabled = true,-;
SpeedButton2->Tag = 0;
SpeedButton3->Enabled = true;
MediaPlayer->Notify = true;
// CD
MediaPlayer->TimeFormat = tfMilliseconds;
int ms = MediaPlayer->Length;
AnsiString st = "Audio CD. : ";
st = st + IntToStr(MINUTE(ms));
st = st + ":" + IntToStr(SECOND(ms));
Labell->Caption

= st;

MediaPlayer->TimeFormat = tfTMSF;
Labell->Visible = true;
Track = 0;
return;

// AudioCD
if (( MediaPlayer->Mode == mpOpen )

||

(MediaPlayer->Mode == mpStopped) &&


(MediaPlayer->Tracks == 1))
{
Labell->Caption

" AudioCD" ,-

if ( Labell->Visible )
else

Labell->Visible

= false;

Labell->Visible

= true;

147

//
void

fastcall TForml::FormClose(TObject *Sender,


TCloseAction &Action)

{
MediaPlayer->Stop();
MediaPlayer->Close();

//
void

fastcall TForml::SpeedButtonlClick(TObject *Sender)

{
MediaPlayer->Previous(); //

MediaPlayer->Previous(); //

if ( MCI_TMSF_TRACK(MediaPlayer->Position) == 1 )
SpeedButtonl->Enabled

false;

if ( ! SpeedButton3->Enabled )
SpeedButton3->Enabled

true,-

TracklnfoO ;
Label2->Caption = "0:00" ;

//
void

fastcall TForml::SpeedButton3Click(TObject *Sender)

{
MediaPlayer->Next();
//
// Next

if ( MCI_TMSF_TRACK(MediaPlayer->Position) ==
MediaPlayer->Tracks )
SpeedButton3->Enabled
if (!SpeedButtonl->Enabled
Tracklnf();
Label2->Caption = "0:00";

false,-

) SpeedButtonl->Enabled = true;

148

1.

//
void

Play/Stop

f a s t c a l l T F o r m l : : S p e e d B u t t o n 2 C l i c k ( T O b j e c t *Sender)

{
if ( SpeedButton2->Tag == 0 ) {
// Play
MediaPlayer->Play();
SpeedButton2 ->Glyph->Ass ign (bmStop) ;
SpeedButton2->Hint = "";
SpeedButton2->Tag

1;

//SpeedButton3~>Enabled -

true; //
// " "

MediaPlayer->Notify
Timer->Enabled

true;

= true;

Tracklnf();
}
else {
// Stop
SpeedButton2->Glyph->Assign(bmPlay);
SpeedButton2->Hint = "";
SpeedButton2->Tag

MediaPlayer->Notify

0;
=

true;

MediaPlayer->Stop();
Timer->Enabled

false,-

Compact Disk Player ( 2)


Compact Disk Player, , , . 1.46 . 1.47, -. ,
(. 1.47),
,

( shapei).
. 1.9. ,

149

shape2, .
MediaPiayer , Compact Disk Player ( 1). cursor shapei crDrag.
Shape2

Shapei Label! Label2


-iDlxl
Track 0
0:00-

SpeedButtoni SpeedButton2 SpeedButton3 SpeedButton4


. 1.46. Compact Disk Player ( 2)

. 1.47. Compact Disk Player ( 2)

1.9.

BorderStyle

bsNone

Color

clFuchsia

TransparentColorValue

clFuchsia

TransparentColor

true

int px,py; // ,
// Shapei
void
fastcall TForml::ShapelMouseDown(TObject *Sender,

150

1.
TMouseButton Button, TShiftState Shift, int X, int Y)
// ,
//
= X;
= Y;

// Shapel
void

fastcall TForml::ShapelMouseUp(TObject *Sender,


TMouseButton Button, TShiftState Shift, int X, int Y)

{
Forml->Left = Forml->Left + X - px;
Forml->Top = Forml->Top + Y - py;

/ /
void

Off

()

. f a s t c a l l T F o r m l : : S p e e d B u t t o n 4 C l i c k ( T O b j e c t *Sender)

{
//
MediaPlayer->Stop();
Forml->Close() ;

Video

Player

Video Player, . 1.48


. 1.49 ,
AVI MPG. ,
Eject (speedButtoni).
speedButton2 , .
.
, .

151

, , .
* Vd
i eo Pa
l yer

. 1,48. Video Player

SpeedButtoni

SpeedButton2

MediaPlayeri

OpenDialogi

. 1.49. Video Player

152

1.

// ,
// ,
#define MINUTE(ms) ((ms/1000)/60)
#define SECOND(ms) ((ms/1000)%60)
//
Graphics::TBitmap *fcmPlay;

// Play

Graphics::TBitmap *fcmPause;

// Pause

fastcall TForml::TForml(TComponent* Owner)


: TForm(Owner)
{
kmPlay

= new Graphics::TBitmap();

fcmPause = new Graphics::TBitmap();


// Play/Stop
bmPlay->LoadFromResourceID((int)HInstance,101);
bmPause->LoadFromResourceID((int)HInstance,102);
//
SpeedButton2->Glyph->Assign(bmPlay);
MediaPlayerl->Display = Forml;

//
void
.fastcall GetFrameSize(AnsiString f, int *w, int *h)
{
if ( f.Pos(".avi") == 0 )
{
// mpg-
*w = 352;
*h = 240;
return;

// *** AVI- ***

153

//
struct

AVI-

char

RIFF[4]; // RIFF

long int nu_l15]; / /


char

AVIH[4]; // AVIH

long int nu_2[9]; //


long int w;

//

long int h;

//

} header;
TFileStream *fs;

//

/*
:
TFileStream *fs = new

TFileStreamff, fmOpenRead); */

fs = new TFileStream(f,fmOpenRead) ;

//
//

fs->Read(&header, sizeof(header));

//
//

*w = header.w;
*h = header.h;
delete fs;

// Eject ( )
void

fastcall TForml::SpeedButtonlClick(TObject *Sender)

{
int fw, fh;

//

int top,left; //
int sw, sh;

/,/ (, )

int mw, mh;

//
// ( )

1.

154

float kw, kh; // -


float ;

//
//

OpenDialogl->Title = " ";


OpenDialogl->InitialDir = "";
OpenDialogl->Filter =
" |*.avi;*.mpg;*.mpegI"
"AVI|*.avi|MPG|*.mpg|MGEG|*.mpeg";
if ( ! OpenDialogl->Execute() )
return; //
/* , ,
. */
if ( MediaPlayerl->FileName == OpenDialogl->FileName )
return;
/* .
"", . ,
. */
II
GetFrameSize(OpenDialogl->FileName,&fw, &fh);
//
mw = Forml->ClientWidth;
mh = Forml->Panell->Top-10;
if ( fw < mw )
kw = 1; //
else kw = (float) mw / fw;
if ( fh < mh )
kh = 1; //
else kh = (float) mh / fh;

155

//
if ( kw < kh )

= kw;
else = kh;
//

sw = fw * ,- / /

sh = fh * ; / /

left = (Forml->ClientWidth - sw) / 2;


top = (Panell->Top - sh) / 2;
MediaPlayerl->FileName = OpenDialogl->FileName;
MediaPlayerl->Open();
MediaPlayerl->DisplayRect = Rect(left,top,sw,sh);
/*
, ( )
*/
Forml->Canvas->FillRect(Rect(0,0,ClientWidth,Panell->Top));
SpeedButton2->Enabled = true; // Play
//
//
MediaPlayerl->TimeFormat = tfMilliseconds;
int ms = MediaPlayerl->Length;
AnsiString st = IntToStr(SECOND(ms));
if ( st.Length() == 1)
st = "0" + st;
st = IntToStr(MINUTE(ms)) + ":" + st;
Labell->Caption = st;
Label3->Caption = "0:00";
//
SpeedButton2->Glyph->Assign(bmPause);

. 1241

156

1.

SpeedButton2->Hint = "Pause";
SpeedButton2->Tag = 1;
SpeedButtonl->Enabled = False; // Eject
MediaPlayerl->Play();
Timerl->Eriabled = t r u e ;

// Play/Stop (/)
void

fastcall TForml::SpeedButton2Click(TObject *Sender)

{
if (SpeedButton2->Tag == 0)
{
// Play
SpeedButton2->Glyph->Assign(bmPause);
SpeedButton2->Hint = "Pause";
SpeedButton2->Tag = 1;
SpeedButtonl->Enabled = False; // Eject
//
MediaPlayerl->Play();
Timerl->Enabled = true;
}
else

// Stop

{
MediaPlayerl->Stop();
SpeedButton2->Glyph->Assign(bmPlay);
SpeedButton2->Hint = "Play";
SpeedButton2->Tag = 0;
SpeedButtonl->Enabled = True; // Eject
Timerl->Enabled = false;

//
void
fastcall TForml::MediaPlayerlNotify(TObject *Sender)

157

{
if ( ( MediaPlayerl->Mode == mpStopped ) &&
( SpeedButton2->Tag == 1))
{
Timerl->Enabled false;
SpeedButton2->Glyph->Assign(bmPlay);
SpeedButton2->Hint = "Play";
SpeedButton2->Tag = 0;
SpeedButtonl->Enabled = True; //
// Eject

/* Pain
() ,
, , ,
,
Video Player. */
void _fastcall TForml::FormPaint(TObject *Sender)
{
if ( MediaPlayerl->Mode == mpStopped )
{
MediaPlayerl->Position = 1;
MediaPlayerl->Position = 0;

//
void
fastcall TForml::FormClose(TObject *Sender,
TCloseAction &Action)
{
MediaPlayerl->Close();

void

fastcall TForml::TimerlTimer(TObject *Sender)

158

1.

//
// MediaPlayerl->TimeFormat = tfMilliseconds;
int ms = MediaPlayerl->Position;
AnsiString st = IntToStr(SECOND(ms));
if ( st.Length() == 1)
st = "0" + st;
st = IntToStr(MINUTE(ms)) + ":" + st;
Label3->Caption = st;

, . 1.50,
AVI- Animate.
. , . , Animate , .
W'j

Animaei
: !

Buttoni

Play

if!?1 - delpN,avl;:

: 36 ; 90x45

. 1.50.

159

bool loaded = false; //


//
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
/*
, */
try
{
Animatel->FileName = "delphi.avi",}
catch (Exception &e)
{

Forml->Caption = " - " + Animatel->FileName;


loaded = true,Labell->Caption =
": " + IntToStr(Animatel->FrameCount) +
"

: " + IntToStr(Animatel->Width) +
"x" + IntToStr(Animatel->Height);

//
void

fastcall TForml::FonnActivate(TObject *Sender)

{
if ( loaded)
//
//
Animatel->1(1,Animatel->FrameCount,1);

160

1.

// Play
void _fastcall TForml::ButtonlClick(TObject *Sender)
if ( loaded)
//
//
Animatel->Play(1,Animatel->FrameCount,1);


C++Builder ,
. BDE- ADO-.

BDE Borland Database Engine.

ADO ActiveX () Microsoft.

,
BDE-, ,
Borland Database Engine (BDE). BDE
C++Builder.

, BDE , . , (Alias)
BDE Administrator.

()
Database Desktop SQL Explorer. (Alias) .


, CD.
Borland InstallShield Express,
C++Builder.

162

1.


, . 1.51,
BDE
Paradox. adrbk.db (. 1.10).

, , ,
() Name. adrbk. BDE Administrator.

T a b l e , D a t a S o u r c e DBGrid

. 1.11, 1.12, 1.13 .


1.10. adrbk
(adrbk.db)

Name

A (Alpha)

25

Phone

A (Alpha)

20

Cell

A (Alpha)

20

Email

A (Alpha)

30

. /j

BitBtnl

Button2

J E-mail

DataSourcel

Quervi

DBOridi

. 1.51.

163
1.11.
Tablel

DatabaseName

adrbk

TableName

adrbk.db

,
1.12.
DataSourcel

DataSet

Tablel

1.13.
DBGridl

DataSource

DataSourcel

Columns[0] FildName

Name

Columns[0] Title.Caption

Columns[1] FildName

Phone

Columns[1] Title.Caption

Columns[2] FildName

Cell

Columns[2] Title.Caption

Columns[3] FildName

Email

Columns[3] Title.Caption

E-mail

(, , , ) (FindForm)

(BitBtnl). (FindForm) . 1.52.

164

1.
-JnJjiJ

. 1.52.
/ / ***

()

# i n c l u d e " F i n d _ . h " / /
//
void

***

f a s t c a l l TMainForm::FormShow(TObject *Sender)

{
// adrbk ,
try
{
Tablel->Open();
}
catch (EDBEngineError &e)
{
ShowMessage(" : "
" adrbk\n" +
.Message );
Button2->Enabled = false;
BitBtnl->Enabled = false;
CheckBoxl->Enabled = false;

//
void

fastcall TMainForm::BitBtnlClick(TObject *Sender)

165

{
FindForm->Tag = 0;
FindForm->ShowModal();
if ( FindForm->Tag )

//

{
//
// ,
//
Queryl->SQL->Text =
"SELECT * FROM adrbk WHERE Name LIKE \042%" +
FindForm->Editl->Text

+"%\042";

// \042 -
if ( CheckBoxl->Checked )
ShowMessage (Queryl->SQL->Text);
Queryl->Open(); // ()
if ( Queryl->RecordCount != 0)
DataSourcel->DataSet = Queryl;
else
{
ShowMessage (" "
" : " + FindForm->Editl->Text);
DataSourcel->DataSet = Tablel;

//
void
fastcall TMainForm::Button2Click(TObject *Sender)
{
// -
DataSourcel->DataSet = Tablel;

//

166

1.

void

fastcall TMainForm::FormClose(TObject *Sender,


TCloseAction SAction)

{
Tablel->Close();

//

*** ***

//
void

fastcall TFindForm::FormShow(TObject *Sender)

{
Editl->SetFocus(); //
//

// ( )
void

.fastcall TFindForm::ButtonlClick(TObject *Sender)

{
Tag = 1; //
Close();

//
void
f a s t c a l l TFindForm::EditlKeyPress(TObject *Sender,
char &Key)
{
if ( Key == 13) Buttonl->SetFocus(); //
//

(. 1.53)
BDE.

167

I i xl

3 990,00.

(+4 ).
120x70. :
.

[
(
670,00. , . : 2,5
9,00. . . : ,
3 990,00 (+4 ).
530,00. , 14, 40 . :
2 590,00. 614,40 . : , I
870,00.: . : .
75,00. . : . :

[: 3

. 1.53.

"" stock.db (. 1.14).


. 1.14. stock (stock.db)

Title

A (Alpha)

50

Price

$ (Money)

Memo

A (Alpha)

100

Image

A (Alpha)

30


(
BMP)

stock. BDE Administrator.

168

1.

. 1.54,
. 1.15, 1.16, 1.17, 1.18.

DBEdH
i
JDBEdG
i
DBMemol

" ' !'" ' i " ' . j

[ |Image

. .1

. 1.54.
1.15. Tablei

DatabaseName

stock

TableName

stock.db

1.16.

DataSet

Tablei

DataSourcei

169

1.17. DBGridi

DataSource

DataSourcel

Columns[0].FildName

Title

Columns [0] . T.itle.Caption

Columns[1].FildName

Price

Columns[1].Title.Caption

Columns[2].FildName

Memo

Columns[2].Title.Caption

Columns[3].FildName

Image

Columns[3].Title.Caption

Image

1.18.
DBEdi t DBMemo

DBEditl.DataSource

DataSourcel

DBEditl.DataField

Title

DBEdit2.DataSource

DataSourcel

DBEdit2.DataField

Price

DBMemol.DataSource

DataSourcel

DBMemol.DataField

Memo

/ /
void
fastcall TForml::FormShow(TObject *Sender)
{
try
{
Tablel->Open(); //

1.

170
catch ( EDBEngineError &e)
{

ShowMessage(" "
" stock");

//
void

fastcall TForml::DataSourcelStateChange(
TObject *Sender)

{
if ( DataSourcel->State == dsBrowse)
StatusBarl->Panels->Items[l]->Text = "";
else
StatusBarl->Panels->Items[1]->Text = ""

// At'terScroll
// ( )
void

fastcall TForml::TablelAfterScroll(TDataSet *DataSet)

{
AnsiString Picture;
if ( Tablel->RecNo != -1)
StatusBarl->Panels->Items[0]->Text =
": " + IntToStr(

Tablel->RecNo );

/*
FieldValue. Image
,
. */
try {
Picture =
Tablel->Database->Directory +
DataSet->FieldValues["Image"];

171

catch (EVariantTypeCastError &e) {


Imagel->Visible = false;
return;
}
ShowPhoto(Picture);
else
StatusBarl->Panels->Items[O]->Text = "";
StatusBarl->Panels->Itemsf1]->Text = "
Imagel->Visible = false;

// Imagel
void
{

fastcall TForml::ShowPhoto(AnsiString Picture)


try
.{
Imagel->Picture->LoadFromFile(Picture);
}
catch ( EFOpenError &e)
{
// ,
Imagel->Visible = false;
return;
}
Imagel->Visible = true;

//
void

fastcall TForml::FormClose(TObject *Sender,


TCloseAction SAction)

172

1.

if (Tablel->State == dsEdit )
/ /

Tablel->Post(); //

ADO Microsoft Access.


(, ).
(, ),

, " ", " "
" ". , " " ,
, ,
" " (. 1.55).

-XJ

31 2004 ,


.12.2004
J03.01.2005

I +

, , 16; 00
(). 12:00

SQL

. 1 . 5 5 . ,

173

"" (Planner.mdb) schedule (. 1.19).


. 1.56, . 1.20, 1.21, 1.22, 1.23.
ODBC:

Microsoft Access Driver (*.mdb);

. DPlanner;

Planner.mdb.
. 1.19. schedule
"" (Planner.mdb)

aDate
aTask

/
, 50

()

{
Label! ;
Label2

")*!

I!

|', |'.

|!:'.", ','. ',".. [

. 1.56.

SQL

1.

174

1.20. ADOConnectionl

ConnectionString

Provider=MSDASQL.1;
Persist Security Info=False;
Data Source=DPlanner

DSN=DPlanner
1.21. ADODataSeti

Connection

ADOConnectionl

CommandText

SELECT * FROM schedule ORDER BY aDate

1.22.

DataSet

ADODataSeti

DataSourcel

1.23.

DataSource

DataS ourcel

Columns[0].FlldName

aDate

Columns[0].Title.Caption

Columns[1].FildName

aTask

Columns[1].Title.Caption

#include <DateUtils.hpp>
#include <ComObj.hpp>

// : EOleException

DataGridi

175

AnsiString stDay[7] =

("","","",
"","","",""} ;

AnsiString stMonth[12] = {"","","",


"","","","",
"","","",
"",""};
void

fastcall TForml::FormShow(TObject *Sender)

{
TDateTime Today, //
NextDay; // ( )
Word

Year, Month, Day; // , ,

Today Now ();


DecodeDate(Today, Year, Month, Day);
Labell->Caption = " " + IntToStr(Day) + " " +
stMonth[Month-1] + " " +
IntToStr(Year) + " , " +
stDay[DayOfWeek(Today) -1];
Label2->Caption " ";
/* , , ,
, ,
, - */
switch ( DayOfWeek(Today) ) {
case 6

: NextDay = Today + 3; break; //

case 7

: NextDay r Today + 2; break; //

default : NextDay = Today + 1; break;

176

1.
ADODataSetl->CommandText =
"SELECT * FROM schedule WHERE aDate BETWEEN DateValueC"
FormatDateTimeC'dd/iran/yyyy", Today) +
"') AND DateValue('" +
FormatDateTime("dd/mm/yyyy",NextDay) +
"') ORDER BY aDate";
// , SQL-
if ( CheckBoxl->Checked) ShowSQLO;
// ODBC,
// EOleException
try
{
// (
// SQL- ADODataSetl->CommandText
ADODataSetl->Open();

catch ( EOleException &e)


// EOleException ,
// ^include <ComObj.hpp>

I
ShowMessage(
" . Planner.mdb "
" \ ODBC "
" dplaner"

Buttonl->Enabled = false;
Button2->Enabled = false;
Button3->Enabled = false;

177

Button4->Enabled = false;
return;

if ( ! ADODataSetl->RecordCount )
ShowMessage("
" .");

//
void
fastcall TForml::ButtonlClick(TObject *Sender)
{
AnsiString today = FormatDateTime("dd/inm/yyyy",Now());
Forml->Label2->Caption = "";
ADODataSetl->Close(); //
//
ADODataSetl->CommandText =
"SELECT * FROM schedule WHERE aDate =
DateValue('" + today +"')";
if ( CheckBoxl->Checked) ShowSQLf); //
ADODataSetl->Open(); //
//

//
void
fastcall TForml::Button2Click(TObject *Sender)
{
AnsiString tomorrow = FormatDateTime("dd/mm/yyyy"
Now () +1 ) ;
Label2->Caption = "";

1.

178
ADODataSetl->Close() ;
//
ADODataSetl->CornmandText =

"SELECT * FROM schedule WHERE aDate = DateValue('" +


tomorrow + " ' ) " ;
if ( CheckBoxl->Checked) ShowSQLO;
ADODataSetl->Open();

//

if ( ! ADODataSetl->RecordCount )
{
ShowMessage(" "
"!");

//
void

fastcall TForml::Button3Click(TObject *Sender)

{
// " " -
// ( )
TDateTime Present, eWeek;
Label2->Caption = " ";
Present^ Now ; // Now -
eWeek = EndOfAWeek(YearOf(Present),WeekOf(Present));
/*

StartOfWeek,

DateUtils.hpp
*/

EndOfAWeek,

YearOf WeekOf

(.

iinclude

179

ADODataSetl->Close();
ADODataSetl->CommandText =
"SELECT * FROM schedule WHERE aDate BETWEEN DateValue('" +
FormatDateTime("dd/mm/yyyy", Present) + ."') AND DateValuef1" +
FormatDateTime("dd/mm/yyyy",eWeek)+"') ORDER BY aDate";
if ( CheckBoxl->Checked) ShowSQLO;
ADODataSetl->Open();
if ( ! ADODataSetl->RecordCount )
ShowMessage(" "
" .");
}
//
void
fastcall TForml::Button4Click(TObject *Sender)
{
ADODataSetl->Close();
ADODataSetl->CommandText =
"SELECT * FROM schedule ORDER BY aDate";
if ( CheckBoxl->Checked) ShowSQLO;
ADODataSetl->Open();
Label2->Caption - ", ";
}
// SQL-
void
fastcall TForml::ShowSQL(void)
{
ShowMessage ( ADODataSetl->CommandText );

, . 1.57, , Windows.

: 1
11


1
1

1 1
1 22

1
1
111
1 1I
122
1
1

**
. 1.57.

181

, ,
, Internet.
. 1.58, 1.59 .
.
. 1.24.

. 1.58.

, , .
,
.
:

-.
C++ Builders .
-.; -. 2005.
hUp:\\ww bhv.ru
OK

. 1.59.
1.24.

Name

About

BorderStyle

bsToolWindow

Position

poOwnerFormCenter

182

1.

II *** ***
#include <stdlib.h>

//
//

#include <time.h>
# include "SaperAbout.h"
TMain *Main; //
#define MR 10 // -
#define MC 10 // -
#define NM 10 // -
int Pole[MR+2][+2]; //
// 0..8 -
// 9 -
// 100..109 -
// 200..209 -
int nMin;

// -

int nFlag;

// -

int status = 0 ; // 0 - ; 1 - ; 2 -
//
//
#define LEFT 0

// X

#define TOP

// Y

#define W

40

//

#define H

40

//

// - ""
void
fastcall NewGame();
//


void

183

fastcall Open(int row, int col);

//
void
fastcall TMain::FormMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int x, int y)
{
if ( status == 2 ) return,if ( status == 0) status = 1;
x -= LEFT;
-= TOP;
if (x > 0 && > 0)
{
//
//
int row = y/H + 1;
int col = x/W + 1;
if (Button == mbLeft)
{
if ( Pole[row][col] == 9 )
{
Pole[row][col] +=100;
status = 2 ;

//

ShowPole(status);
}
else if

( Pole[row][col] < 9 )

{
Open(row,col);
ShowPole(status);

else if (Button == mbRight)


{
nFlag++;

184

1.
if ( Pole[row][col] == 9 )
nMin++;
Pole[row][col] += 200;

//
if (nMin == NM ScSc nFla
g == NM)
status = 2 ;

//

ShowPole(status);
else Kletka(row, col, status);
}

// - OnCreate
//
void

fastcall TMain::FormCreate(TObject *Sender)

{
// - ,
// , -3.
// Open
// .
for ( int row=0; row <= MR+l; row++)
for ( int col=0; col <= MC+l; col++)
Pole[row][col] = -3;
NewGameO;

// ""

ClientWidth = W*MC;
ClientHeight = H*MR+TOP+1;

// Paint
//
//
void

fastcall TMain::FormPaint(TObject *Sender)

7S5

ShowPole(status);

//
void
fastcall TMain::ShowPole( int status)
{
for ( int row = 1; row <= MR; row++ )
for ( int col = 1; col <= MC; col++ )
Kletka(row, col, status);

//
void
fastcall TMain::Kletka(int row, int col, int status)
{
int X = LEFT + (col-1)* W; .
int = TOP + (row-1)* H;
if (status = = 0 ) //
{
// -
Canvas->Brush->Color = clBtnFace;
Canvas->Rectangle(x-l,y-l,x+W,y+H);
return;
}
// (status = 1) (status = 2)
if ( Pole[row][col] < 100 )
{
//
Canvas->Brush->Color = clBtnFace;

//
//
Canvas->Rectangle(x-1,-1,x+W,+);
if (status == 2 && Pole[row][col] == 9)
Mina( x, y ) ; // ,

186

1.
return;

//
Canvas->Brush->Color = clWhite;

//

Canvas->Rectangle(-1,-1,x+W,+);
if

( Pole[row][col] == 100 ) // ,
//
return;

if ( Pole[row][col] >= 101 && Pole[row][col] <= 108 )


{
Canvas->Font->Size = 11;
Canvas->Font->Color = clBlue;
Canvas->TextOutA(x+3, y+2,
IntToStr(Pole[row][col] -100 ));
return;

if ( Pole[row][col] >= 200 )


Flag(x, y ) ;
if (Pole[row][col] == 109 ) // !
Canvas->Brush->Color = clRed;
Canvas->Rectangle(x-1,y-1,x+W,y+H);
if (( Pole[row][col] % 10 == 9)

&&

(status == 2)

Mina( x, y ) ;

//
// ,
void

fastcall Open(int row, int col)

187

{
if (Pole[row][col] -- 0)
{
Pole[row][col] = 100;
// / ,
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) ;.
}
else
// -3
if (Pole[row][col] < 100 && Pole[row][col] != -3)
Pole[row][col] += 100;

// -
void

fastcall NewGame()

{
/ / - ,
// ,
//

//
/ /
int

(
-3.

Open

row,col;

for (row=0; row <= MR+l; row++)


for (col=0; col <= MC+l; col++)
Pole[row][col] = -3;
for (row=l; row <= MR; row++)

3. 1241

188

1,
for (col=l; col <= ; col++)
Pole[row][col] = 0;

//
time_t t;

//

srand((unsigned) time(&t)); //
int n = 0; // -
do
{
row = rand % MR +1;
col = rand % MC +1;
if ( Pole[row][col] != 9)
{
Pole[row][col] = 9;

while ( n < 10) ;


// -
int ;
for ( row = 1; row <= MR; row++)
for ( col = 1; col <= MC; col++)
if ( Pole[row][col] != 9 ) {
=0;
if ( Pole[row-1][col-1] == 9 ) k++;
if ( Pole[row-1][col]
== 9 ) k++;
if ( Pole[row-1][col+1] == 9 ) k++;
if ( Pole[row][col-1]

== 9 ) k++;

if ( Pole [row] [col+1]


== 9 ) k++;
if ( Pole[row+1][col-1] == 9 ) k++;
if ( Pole[row+1][col]
== 9 ) k++;
if ( Pole[row+1][col+1] == 9 ) k++;
Pole[row][col] = k;

189


status = 0 ; //

riMin = 0 ;

//

nFlag = 0 ;

//

//
void
fastcall TMain::Mina(int x, int y)
{
Canvas->Brush->Color = clGreen;
Canvas->Pen->Color = clBlack;
Canvas->Rectangle(x+16,y+26,x+24,y+30);
//
Canvas->Rectangle(x+8,y+3 0,x+32,y+34);
Canvas->Pie(x+6,y+28,x+34,y+44,x+34,y+36,x+6,y+36);
//
Canvas->MoveTo(x+12,y+32); Canvas->LineTo(x+28,y+32)
//
Canvas->MoveTo(x+8,y+36);

Canvas->LineTo(x+32,y+36)

// ""
Canvas->MoveTo(x+20,y+22); Canvas->LineTo(x+20,y+26)
// ""
Canvas->MoveTo(x+8, y+30); Canvas->LineTo(x+6,y+28);
Canvas->MoveTo(x+32,y+30); Canvas->LineTo(x+34,y+28)

//
void
fastcall TMain::Flag( int x, int y)
{
TPoint p[4]; //
//

190

1.

[0].=+4;

[0] y=y+4;

[1].=+30;

[1] =+12;

[2].=+4;

[2] =+2 ;

//
Canvas->Brush->Color = clRed;
Canvas->Pen->Color = clRed; // >
//
Canva s->Polygon(p, 2);

//

//
Canvas->Pen->Color = clBlack;
Canvas->MoveTo(p[0]., p[O].y)
Canvas->LineTo(x+4,y+36);
TPoint m[5];

//

m[0].x=x+8; m[0].y=y+14;
m[l].x=x+8; m[l].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;
Canvas->Pen->Color clWhite;
Canvas->Polyline(m,4);
Canvas->Pen->Color = clBlack;

//
void

fastcall TMain::NlClick(TObject *Sender)


NewGame();
ShowPole(status);

191

// "?"
void

fastcall TMain::N4qlick(TObject *Sender)

About~>ShowModal();

// "?"
void

fastoall TMain::N3Click(TObject *Sender)

{
/*
hh.exe,
Windows. mappid
. */
WinExecChh.exe -mapid I saper.chm", SW_RESTORE);

// *** ***
// URL- ( Label5)
void

fastcall TAbout::Label5Click(TObject *Sender)

{
/* ShellExecute
- (URL-) ,
ShellExecute (AboutForm->Handle,
"open",
"http:\\\\www.bhv.ru",
NULL, NULL)
URL- .
ShellExute (char*)
null terminated , Caption AnsiString.
Ansi (char*)
c_str ()
*/

192

1.

// , Labels
ShellExecute(About->Handle,"open",Label5->Caption.c_str(),
NULL,NULL,SW_RESTORE);

}
// OK
void

fastcall TAbout::ButtonlClick(TObject *Sender)

{
ModalResult = mrOk;

15
"15". .
15 ,
1 15. 4x4, . (. 1.60). , ,
, (. 1.61).

14

15 11 17

10 11 12

12

13 10

. 1.60.

13 14 15
. 1 . 6 1 .

15 .
. 1.62.

193
&

'

- I r l x i

1 0

11

1 5

1 3

1 2

14
.1..1,1.1.;..,.'.

. 1.62. 15
#include "math.hpp" // Randomize RandomRange
//' 48x48
#define WC 48
tdefine 48
byte pole[4][4]; //
byte ex,ey;

//

fastcall TForml::TForml(TComponent* Owner)


: TForm(Owner)
{
Forml->Font->Size = 12;

//
void
fastcall TForml::FormShow(TObject *Sender)
{
NewGame();

//
void
fastcall TForml::NewGame()

194

1.

//
ClientWidth = WC * \4 ;
ClientHeight = HC * 4;

//' ()
int = 1;
for (int i = 0; i < 4; i++)
(int j = 0; j < 4; j++)

for

pole[ i][j] = k++;


Mixer()i

//

ShowPole();

//

//
void
fastealI TForml::Mixer()
int xl,yl; //
int x2,y2; //
int d;

//

Randomize() ;
xl = 3; yl = 3; // . stp
for ( int i = 0; i < 150; i++)

// -

do {
x2 = xl;
y2 = yl;
/* , ,
*/
d = RandomRange(1,5);
switch ( d ) {

795

case I: x2--; break;


case 2: 2++; break;
case 3: 2 ; break;
case 4: y2++; break;
} while ( (x2 < 0) | | (x2 >= 4) | | (y2 < 0)

| (y2 >=

4)) ;
/* ,
*/
pole[yl][xl]

pole[y2][x2]

1[2][2];

16;

xl = 2;
1 = 2;
//
ex =

xl;

= yl;
}
//
void

fastcall TForml::ShowPole()
int x,y; //
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
x = j * HC;
= i * WC;
if <pole[i][j] != 16 ) {
Canvas->Brush->Color = clBtnFace;
Canvas->Rectangle(x,y, x+WC-1, y+HC-1);

/96

1.
Canvas->TextOutA(x+15,+10,
IntToStr(pole[i][j]));
}
else {
Canvas->Brush->Color = clBtnHighlight;
Canvas->Rectangle(x,y, x+WC-1, y+HC-1);

bool Finish(); // ,
//
void
fastcall TForml::FormMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X,
int Y)
{
int cx,cy; //
ex = X / WC;
cy = Y / HC;
//
i f ( ( a b s ( c x - e x ) = = 1 & & - = = 0 ) ||
( abs(cy - ) == 1

& & - = = 0 ) )

{
// (,) (,)
pole[ey][ex] = pole[][];
pole [] [] = 16, = ;
= ;
ShowPole();
//
if ( Finish () )
{
ShowPole();

197

int r = MessageDlg (" !\ ?",


mtInformation, TMsgDlgButtons

mbYes

mbNo, 0);

if ( r == mrNo )
Forml->Close(); //
else
{
NewGame();
ShowPole();

/* ,
( ) */
bool Finish()
{
bool result;
int row, col;
int = 1;
result

true; //

for (row = 0; row < 4; row++)


{
for (col = 0; col < 4; col++)
if ( pole[row][col] == )
else {
result = false;
break;
}
if ( ! result ) break;

198

1.
return ( r e s u l t ) ;

// Paint
void

fastcall TForml::FormPaint(TObjesct *Sender)

ShowPole();

" " (Puzzle)


"15", , , (. 1.63). . , .

. 1.63.

BMP, ,
, . bmp,

199

.

btnp.
. 1.64.

. 1.64.
#include "math.hpp" // Randomize RandomRange
// WxH
#define W 4
#define H 4
int we, he; //
byte pole[H][W]; //
byte ex,ey;

//

bool GameOver;
AnsiString fn; // bmp- ()
TSearchRec SearchRec; //
fastcall TForml::TForml(TComponent* Owner)
: TForm{Owner)
{
pic = new Graphics::TBitmap();

1.

200
//
void

fastcall TForml::FormShow(TObject *Sender)

{
NewGame();

//
void

fastcall TForml::NewGame()
static int Tag = 0;
//
if (( ParamCountO == 0 ) && (Tag == 0 )) Tag = 1;
switch ( Tag )
case 0 : // -
fn = ParamStr(1);
Tag = 1;
break;
case 1:

// bmp-

FindFirst("*.bmp",faAnyFile,SearchRec);
fn = SearchRec.Name;
Tag = 2;
break;
c a s e 2 : / /

bmp-

if ( FindNext(SearchRec) != 0)
FindFirst("*.bmp",faAnyFile,SearchRec);
fn = SearchRec.Name;

201


break;

//
try {
pic->LoadFromFile(fn);
}
catch (EFOpenError &e)
{
MessageDlg(" ",
mtWarning, TMsgDlgButtons () mbOKmbHelp, 0) ;
return;

//
we = pic->Width / W;
he = pic->Height / H;
//
ClientWidth = we * W;
ClientHeight = he * H;
// ()
int k = 1;
for (int i = 0; i < H; i++)
for

( i n t j = 0; j < W; j++)
poleti][j]

= k++;

GameOver = false,Mixer();

//

ShowPole();

//

202

1.

//
void

fastcall TForml::Mixer()

int xl,yl; //
int x2,y2; //
int d;

//
\

Randomized ;
xl = 3; yl = 3; // . stp
for ( int i = 0; i < 150; i++)

// -

{
do {
x2 = xl;
2 - yl;
// , ,
//
d = RandomRange(1,5);
switch ( d ) {
case 1: x2--; break;
case 2: x2++; break;
case 3: y2--; break;
case 4: y2++; break;
}
} while ((x2 < 0) || (x2 >= W) ||
(y2 < 0) ] | (y2 >= H)) ;
/* ,
*/
poletyl][xl]

= pole[y2][x2];

pole[y2][2]

16;

203


xl = 2;
yl = 2;
};
//
ex =

xl;

= yl;

//
void

fastcall TForml::ShowPole()

TRect src, dst; //


//
int sx,sy;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; jj++)
{
/ /

//

//

sx = ( ( p o l e [ i ] [ j ] - D

% W) * we;

sy = < ( p o l e [ i ] [ j ] - D

/ H) * h e ;

src = Bounds(sx,sy,we,he);
dst = Bounds(j*wc,i*hc,we,he);
if ((

pole[i][j] != 16 ) || GameOver )

//
Canvas->CopyRect(dst,pic->Canvas,src);
else
{
//
Canvas->Brush->Style = bsSolId;

204

1.
Canvas->Brush->Color = :lBtnFace;
Canvas->Rectangle(dst);

if ( N6->Checked )
/
t

//
Canvas->Brush->Style = bsClear;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
Canvas->TextOutA(wc*j,hc*i, IntToStr(pole[i][j]));

//
void

fastcall TForml::FormMouseDown(TObject *Sender,


TMouseButton Button, TShiftState Shift, int X, int Y)

{
int cx,cy; //

cx = X / wcj
cy = Y / heMove (ex,cy); //
//

bool Finish(); // ,
// ,
//
void __fastcall TForml::Move(int cx, int cy)

205


{
if

( ( abs(cx - ex) == 1
( abs(cy - ) == 1

& & - = = 0 ) ||
& & - = = 0 ) )

{
// (,) (,)
pole[ey][ex] = pole[][];
pole[][] = 16;
= ;
= ;
//
ShowPole();
if ( Finish () )

{
GameOver = true;
ShowPole();
int r = MessageDlg (" ! "
" ( )?",
mtInformation,
TMsgDlgButtons()

mbYes

mbNo, 0);

if ( r == mrNo )
Forml->Close(); //
else
{
NewGame();
ShowPole();

// , ( )
//
bool Finish()

206

1.

bool result;
int row, col;
int = 1,result

true; //

for (row = 0; row < H; row++)


{
for (col = 0; col < W; col++)
if ( pole[row][col] - )
else {
result = false;
break;
}
if ( ! result ) break;
}
return (result);

// Paint
void

fastoall TForml::FormPaint(TObject *Sender)

{
ShowPole();

//
void

fastcall TForml::NlClick(TObject *Sender)

{
NewGame ();

//


void

207

fastoall TForml::N3Click(TObject 'Sender)

{
WinExec("hh.exe puz zle.chm", SW_RESTORE);

/ /

v o i d _ f a s t c a l l TForml::N4Click(TObject *Sender)
{
WinExecChh.exe -mapid 3 p u z z l e . c h m " , SW_RESTORE)

/ /
void

f a s t c a l l TForml::N6Click(TObject *Sender)

{
N6->Checked = ! N6->Checked;
ShowPcle() ;

" "
. .
,
. , . .
, . "".
"" , .
, ,
.
(. 1.65). , "".
.
. ,
,
, . , ""
.

208

1.

'



"" .


,


.

. 1.65.

, ,
.
(. 1.66).
""
( )
:
,
.

v '
. 1.66.

. 1.67.

, .

209

. 1.67.
# i n c l u d e <Math.hpp>

#define

MAX_SIZE

#define

MAX_H

#define

MAX_W

/ / idefine
int

DEBUG

/ /

32 / /

/ /

- 8x8

< 100 - ,

Pole[i][j]

//

Pole[MAX_W][MAX_H]; / /
/* Pole[i][j]

>= 100 < 200 -

( );
Pole[i][j] >= 200 -
*/
Graphics::TBitmap

*Pictures;

//

int np;

//

int nf;

// - ()

int no;

//

TPoint openl;

// 1-

TPoint 2;

// 2-

i n t W,H;

/ / -

//
int WK, ;

W 2-

// ()

210

1.

TForml *Forml;
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)

void

fastcall TForml::FormCreate(TObject *Sender)

int np; // - pictures


Pictures

new Graphics::TBitmap();

try {
Pictures->LoadFromFile ("pictures .bmp") ;
catch (EFOpenError &e)
ShowMessage(" .");
return;

/* pictures . ,
.
, 8,10,12,14 15 :

*/

8
10

16
20

4x4
4x5

12

24

14

28

4x6
4x7

15

30

5x6

211

P i c t u r e s - > H e i g h t - l ; / /

WK = ;

/ /

np = P i c t u r e s - > W i d t h / WK;
if

( np < 15)
H

4;

e l s e H = 5;
W =

(np*2)/H;

// ()
ClientHeight
ClientWidth

=
=

H * ;
W * WK;

//
Timerl->Enabled
Timerl->Interval

False;

= 200;

NewGame();

//
void

fastcall TForml::NewGame()

{
/* Pole .
,
i Pole */
int r;

//

int buf[MAX_SIZE];
/* buf[i] , i
Pole */
int i, j ; //

212

1.

/ /

Pole

// 0 , - -

//

tor (i = 0 ; i < np;


buf[i]

0;

Randomize!); //
for (i = 0; i < H; i++)
for (j = 0; j < W; j++) {
do
r

{
= RandomRange(0,np);

} while ( buf[r] = = 2 );
Pole[i]tj]

r;

//

buf[r]++;
}
//
nf = 0;

//
void

fastcall

TForml::ShowPole()

{
int row, col;

for ( row = 0; row < H; row++)


for (col = 0; col < W; col++)
Kletka(row,col);

//
void

fastcall TForml::Kletka(int col,int row)

213


{
int , ;

// ()

TRect src, dst; //


//

//

(col)*WK;

(row)*HK;

if

( P o l e [ c o l ] [ r o w ] >= 200 ) {

/* .
*/

//
Canvas->Brush->Color =
Canvas->Pen->Color

clBtnFace;

clBtnFace;

C a n v a s - > R e c t a n g l e ( x , , x+WK-2, y+HK-2);


return;

if

( ( P o l e f c o l ] [ r o w ] >= 100) && ( P o l e f c o l ] [ r o w ] < 200) ) {


/ / -
// Pole[col,row]
//
src

=- + 100,

100 -

//

Pictures

= B o u n d s ( ( P o l e [ c o l ] [ r o w ] - 1 0 0 )*WK,0,WK,HK);

/ /
dst

()

= Bounds(,,-2,WK-2);

/ /

214

1.
Forml->Canvas->CopyRect(dst,Pictures->Canvas,src);
//
Canvas->Pen->Color =

clBlack;

Canvas->Brush->Style

= bsClear;

Canvas->Rectangle(x,,x+WK-2,y+HK-2);
return;

if ( (Pole[col][row] >= 0) && (Pole[col][row] < 100)


// ,
{
Canvas->Brush->Color = clBtnFace;
Canvas->Pen->Color = clBlack;
Canvas->Rectangle(x,,x+WK-2,y+HK-2);

#ifdef DEBUG
// -
Canvas->Font->Color = clBlack;
Canvas->TextOut(x+l5,y+15, IntToStr(Pole[col][row])
#endif

//
void

fastcall TForml::FormMouseDown(TObject *Sender,


TMouseButton Button,
TShiftState Shift, int X, int Y)

{
int col;

//

int row;

//

col = X/WK;
row = Y/HK;

215

if ( Pole[col][row] >= 200 )


// '
return;
if ( no == 0 ) //
{

1;

openl.

col;

open 1.

row;

//
Pole[openl.x][openl.]

+=

100;

Kletka(openl.x,openl.);
return;

if

( no == 1 )

{
/ / ,
2.

col;

2.

row;

/ /

//

if

( ( o p e n l . == 2.) && ( o p e n l . == 2.) )

return;

else
{

= 2 ; / /

Pole[open2.x][2.]

+= 100;

K l e t k a ( 2 . , 2 . ) ; / /

216

1.
// , ?
if ( Pole[openl.x][openl.] == Pole[open2.x][open2.] )
//
{
nf++;
= True; / /

Forml->Timerl->Enabled
//
//

""

On Timer

};
return;

if

( no == 2 )

{
/ / 2
//

//

//
Pole[openl.x][openl.]

-= 100;

Pole[open2.x][open2.y]

-= 100;

Kletka(openl.x,openl.);
Kletka(open2.,2.);

// openl
openl.

= col;

openl.

no

1;

row;
//

//
Pole[openl.x][openl.]

+=

100;


Kletka(openl.x,openl,y);

//
void

fastcall TForml::TimerlTimer(TObject *Sender>

{
/* .
. */
Pole[openl.x][openl.]

+= 100;

Pole[open2.x][2.]

+=

100;

0; //

//
Kletka(2.,2.);
Kletka(openl.,openl.);
//
Forml->Timerl->Enabled

false;

if ( nf == W*H/2 )
{
//
Canvas->Font->Name

"Tahoma";

Canvas->Font->Size

16;

Canvas->Font->Color = clBlue;
Canvas->Font->Color =

clBlack;

Canvas->TextOut(100,160,"Game Over!");
Canvas->Font->Size

= 10;

Canvas->TextOut(120,210,"() .., 2005")

217

218

1.

// Paint
void

fastcall TForml::FormPaint(TObject

*Sender)

{
ShowPole();

//
void

fastcall TForml::NlClick(TObject

*Sender)

{
NewGame();
ShowPole() ;

/ /
void

f a s t c a l l TForml::N3Click(TObject *Sender)

{
WinExec("hh.exe dpic.chm", SW_RESTORE);

// /
void

fastcall TForml::N4Click(TObject

*Sender)

{
WinExecChh.exe -mapid 3 d p i c . c h m " , SW_RESTORE) ;

(. 1.68)
.
,
.
(
. 1.69).

.

219
:


(~

. 1.68. .

-
-.
.
-!
-, .
5
-.
4
, , -?
:
32 1
. 1.69. ()

8 . 1241

220

1.

isaak.jpg



1836
, :
21
I.
1812 .

32 1
herm.jpg




() -
31



, , I, :
330


320
, -.
, - .
- .
I
210

. 1.69.

()

221

. , , ,
( ). .
.
,
( ,
). .
.
. 1.70.
, , , .
I :
Labeli

Imagei

Buttoni

OK

. 1.70.
// *** ()
//
struct TVopros {
AnsiString Vopr;

//

222

1.
AnsiString Img;

// ( -)

AnsiString Otv[4]; //
int

nOtv;

// -

int

rOtv;

//

class TForml : public TForm


{
published:
TLabel *Labell;

// ,

Tlmage *Image1;

//

TButton *Buttonl; // OK /
void

fastcall FormActivate(TObject *Sender);

void

fastcall ButtonlClick(TObject * Sender),-

private:
// -
TRadioButton *RadioButton[4];
//
void

fastcall RadioButtonClick(TObject *Sender);

void

fastcall ShowVopros(TVopros v ) ; //

void

fastcall EraseVopros(void);

//

public:
fastcall TForml(TComponent* Owner);

// *** ***
#include <stdio.h>

// sscanf

iinclude <jpeg.hpp>

//
// jpg-

#pragma package(smart_init)
#pragma resource "*.dfm"

223


TForml

*Forml;

int f;

//
//
//

int level[4];

// - ,
//

AnsiString mes[4];//
TVopros Vopros;

//

int otv;

//

int right = 0 ;

// -
i

// ,
int Getlnt(int f);

//

int GetStringfint f, AnsiString *st); //


//
fastcall TForml::TForml(omponent* Owner)
: TForm(Owner)
{
int i;
int left = 10;
//
// ,
tor (i = 0; i < 4; i++ )
{
//
RadioButton[i] = new TRadioButton(Forml);
//
RadioButton[i]->Parent = Forml;
RadioButton[i]->Left = left;
RadioButton[i]->Width = Forml->

224

1.
ClientWidth - left - 20;
RadioButton[i]->Visible = false;
RadioButton[i]->Checked = false:
// Click
RadioButton[i]->OnClick = RadioButtonClick;

void

fastcall TForml::FormActivate(TObject *Sender)

{
AnsiString st;
//
int n = ParamCount();
if ( n < 1 )
{
Labell->Font->Style = TFontStyles() fsBold;
Labell->Caption = " "
" ";
Buttonl->Tag = 2;
return;

/ /
f = FileOpen(ParamStr(1), fmOpenRead);
if ( f == -1 )
{
Labell->Font->Style = TFontStyles() fsBold;
Labell->Caption = " " +
ParamStr(1);
Buttonl->Tag = 2;
return;

225


//

G e t S t r i n g ( f , & s t ) ; / /

Forml->Caption = st;
GetString(f, &st); //
Labell->Width = Forml->ClientWidth - Labell->Left -20;
Labell->Caption = st;
Labell->AutoSize = true,//
for (int i=0; i<4; i
level[i] = Getlnt(f);
GetString(f, &mes[i]);

/ /

bool GetVopros(TVopros *v)


{
AnsiString st;
int p;

// =1,

if ( GetString(f, &(v->Vopr)) != 0 )
{
/ * - ,

*/
v->nOtv = G e t l n t ( f ) ;
v->rOtv = G e t l n t ( f ) ;
p = Getlnt(f);
if (p) / /
GetString(f,&(v->Img) );

226

1.
e l s e v->Img = " " ;
//
for (int i = 0; i < v->nOtv; i
{
GetStringff,&(v->0tv[i])
}
return true;
}
else return false;

//
void

fastcall TForml::ShowVopros(TVopros v)

{
int top;
int i;
//
Labell->Width = ClientWidth - Labell->Let -20;
Labell->Caption = v.Vopr;
Labell->AutoSize = true;
if (v.Img != "") //

I
/* ,
*/
int RegHeight =

Buttonl->Top

- (Labell->Top + Labell->Height +10)


- (RadioButton[l]->Height + 10) * v.nOtv;
Imagel->Top = Labell->Top + Labell->Height + 10;
//

227


Imagel->Visible = false;
Imagel->AutoSize = true;
Imagel->Picture->LoadFromFile(v.Img);
if (Imagel->Height > RegHeight) //
//
{
Imagel->AutoSize = false;
Imagel->Height = RegHeight;
Imagel->Proportional = true;
}
Imagel->Visible = true;
//
top = Imagel->Top + Imagel->Height + 10;
}
else //
top = Labell->Top + Labell->Height + 10;
//
for (i = 0; i < v.nOtv; i++)
{
RadioButton[i]->Top = top;
RadioButton[i]->Caption = v.0tv[i];
RadioButton[i]->Visible = true;
RadioButton[i]->Checked = false;
top += 20;

//
void
fastcall TForml::RadioButtonClick(TObject *Sender)
{
int i =0;
while (

! RadioButton[i]->Checked )

1.

228
otv = i+1;

// ,
Buttonl->Enabled = true;

//
void

fastoall TForml::EraseVopros(void)

{
Imagel->Visible = false,- //
//
for (int i = 0; i <4; i
RadioButton[i]->Visible = falseRadioButton[i]->Checked = false;
}
//
Buttonl->Enabled = false;

// //
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
bool ok; // -
switch (Buttonl->Tag) {
case 0: //
//
//
GetVopros(&Vopros);
ShowVopros(Vopros);
Buttonl->Caption - "";

229


Buttonl->Enabled = false,Buttonl->Tag = 1;
break;
case 1: //^

if (otv == Vopros.rOtv) //
//
right++;
EraseVopros();
ok = GetVopros(&Vopros);
if ( ok )
ShowVopros(Vopros);
else
//
{
FileClose(f);
//
AnsiString st; //
int i; //
Forml->Caption = " ";
st.printf(
" : %i\n",right

//
i = 0; // ,
//

//
while (( right < level[i]) && (i < 3))

st = st + mes[i];

1.

230

Labell->Caption = st;
Buttonl->Caption = "OK";
Buttonl->Enabled = true;
Buttonl->Tag = 2;
}
break;
case 2: // OK
Forml->Close(); //

// GetString
// - -
int GetString(int f, AnsiString *st)
unsigned char buf[300]; // ()
unsigned char *p = buf;
int n;

//

// - ( - FlleRead)

int len = 0; //

n = FileRead(f, , 1 ) ;
while ( != 0 )
if ( * == '\')

n = FileReacHf, , 1 ) ; / /
break;
len++;

'\'

231

n = FileRead(f, p, 1);

* = '\0';
if ( len !=0) st->printf("%s", buf)
return len;

//
int Getlnt(int f)
{
char buf[20];

// ()

char *p = buf;

//

int n;

// - ( - FileRead)

int a;

// ,

n = FileRead(f, p, 1) ;
while ( (* >= '0') && (* <= '9') ScSc (n > 0) )
{
++;
n = FileRead(f, p, 1) ;

if ( * == ')
n = FileReadff, , 1); // '\'
* =

' \0 ;

//
sscanf(buf,"%i", &);
return a;

232

1.

-2
-2 (. 1.71)
.
(. 1.72).
* ?
;
" "
" "
* "!

. 1 . 7 1 . - 2


, ,
, Windows .
:! $\\ l\Exam.exe "economics.xml" V I

. 1.72.

XML-
(. 1.73). head description

233

. q .
text q , right
. .
level : score , , text .
, , .
. 1.73 "".
<?xml version="1.0" encoding="Windows-1251"?>
<test>
<!></1)>
<description>Ceiii4ac
.
.</description>
<qw>
<q text="Kapn :" src ="marks.jpg" right="3">
<>" "</>
<>" "</>
<>""</>

<q text="KorAa ?" src ="" right="1">


<> </>
<> </>
<> </>

<q text="Hoy-xay :" src ="" right="3">


<></>
<> </>
<> (, )</>
</q>
<q text="CTaBKa :" src ="" right="1 ">
<> </>
<> </>
<> </>
. 1.73. ()

234

1.

</qw>
<levels>
<level score="4" text = " - ."/>
<level score="3" text = " - .7>
<level score="2" text = " - ."^
<level score="0" text = " - !"/>
</levels>
</test>
. 1.73. ()

-2 . 1.74. XMLDocument XML-: ,


.
. , , Labeli.

RadioButtonl, RadioButton2

RadioButton3 -

.
RadioButton4
.

f* RadioButfcnl
RadioButtorfi
RadioButtorS
RadioButton4

. 1.74. -2

235


int nQuery = 0; //

int nRight;

//

int Right;

//

int Sel;

// ,

static int mode = 0 ; //0

// (
// 1 -

// 2 -

//
void

fastcall TForml::FormActivate(TObject *Sender)

{
if (ParamCount() = = 0 ) {
Labell->Caption = " "
" ";
mode = 2;
return;

XMLDocumentl->FileName = ParamStr(l);
try
{
//

XML-

XMLDocumentl->Active = True;
}
catch

(EDOMParseError &e)

{
Labell->AutoSize = True;
Labell->Caption = " " +
ParamStr(l) +
"\nMessage: " + .Message;
mode = 2;

236

1.
return;
Forml->Info(); //

//
int

fastcall TForml::Qery(int i)

//
RadioButtonl->Visible = False;
RadioButton2->Visible = False;
RadioButton3->Visible = False;
RadioButton4->Checked = True;
Button3->Enabled = False;
// qw
_di_IXMLNode qw = XMLDocumentl->
DocumentElement->ChildNodes->
Nodes[WideString("qw")];
if ( i > qw->ChildNodes->Count -1 )
return -1;

nQuery++; //
/* q - .
text q -
g - */
_di_IXMLNode q = qw->ChildNodes->Nodes[i];
/* Text qw - ,
right - */

237

//
Labell->AutoSize = false;
Labell->Width = ClientWidth -20;
Labell->Height = 150;
Labell->Caption q->GetAttribute(WideString("text"));
Labell->AutoSize = true;
Right = StrToInt( q->GetAttribute(WideString("right")));
// "q" ""
//( )
_di_IXMLNode a;
int j = 0; // ""
while ( j < q->ChildNodes->Count )
= q->ChildNodes->Nodes[j];
switch ( j ) {
case 0 : RadioButtonl->Caption = a->Text;
RadioButtonl->Top = Labell->Top +
Labell->Height + 10;
RadioButtonl->Visible = True; break;
case 1 : RadioButton2->Caption = a->Text;
RadioButton2->Top = RadioButtonl->Top +
RadioButtonl->Height + 10;
RadioButton2->Visible = True,- break;
case 2 : RadioButton3->Caption = a->Text;
RadioButton3->Top = RadioButton2->Top +
RadioButton2->Height + 10;
RadioButton3->Visible = True; break;

return 0;

1.

238
//
void

fastcall TForml::Info()

{
Forml->Caption = XMLDocumentl->DocumentElement->
ChildNodes->Nodes[WideString("head")]->Text;
Labell->Caption = XMLDocumentl->DocumentElement->
ChildNodes->Nodes[WideString("description")]->Text;

//
void

fastcall TForml::Button3Click(TObject *Sender)

static int i = 0;

//

int r;

// :
// -1 -

switch ( mode) {
case 0:
= Qery(i++);
mode = 1;
break;
case 1:
// ,
//
if ( Sel == Right) nRight++;
/ /

= Qery(i++);
if ( r == -1 ) //
//
Result();
Button3->Enabled = true;
mode = 2;

239

break;
case 2: Forml->Close(); //

//
void

fastcall TForml::Result()

(
int i = 0;
int score;
_di_lXMLNode Is; // levels
_di_IXMLNode 1;

// level

// level
// score
//
Is = XMLDocrnnentl->DocumentElement->
ChildNodes->Nodes[WideString("levels")]
while ( i < ls->ChildNodes->Count)
{
1 = ls~>ChildNodes->Nodes[i];
score = StrToInt( l->
GetAttribute(WideString("score")));
if ( nRight >= score ) break;

AnsiString mes;
mes.printf(" \"
" : %i\n"
" : %i\n",
nQuery,nRight);

240

1.
mes = mes + l->GetAttribute(WideString("text"));
Labell->Width = Forml->ClientWidth - 20;
Labell->Caption = mes;

//
void

fastcall TForml::RadioButtonlClick(TObject *Sender)

{
Sel = 1;
Button3->Enabled = True;

//
void

fastcall TForml::RadioButton2Click(TObject *Sender)

{
Sel = 2;
Button3->Enabled = True;

//
void

fastcall TForml::RadioButton3Click(TObject *Sender)

{
Sel = 3;
Button3->Enabled = True;

, Windows
,
. , , , etr
. , ,
, , , .

241

. .
,
. . 1.75. , (
Borderstyle bsNone), - , "" . ( ) Mouseup,
.

-lOlxi

:; _sj :: :

3 10 17 24 31
4 11 18 25
5 112|19 26

7
1 8
2 9

13 20 27
14 21 28
15 22 29
16 23 30

. 1.75.
#define BACKGROUND
#undef BACKIMAGE
AnsiString stMonth[12] = {"","","", "",
"","","","",
"","","",
""};
A n s i S t r i n g stDay[7] = {"","","", " " , " " , " " , " " } ;
/ /

dd.rm

242

1.

AnsiString holiday =
"01.01;02.01;07.01;23.02;08.03;01.05;09.05;07.11;12.12;";
Word aYear, aMonth, aDay; // , ,
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
{
DecodeDate (Now() , aYear, aMonth, aDay) ,UpDownl->Position = aMonth;
#ifdef BACKIMAGE
//
backimage = new Graphics::TBitmap();
try {
backimage->LoadFromFile("back.bmp");
}
catch (EFOpenError &e) {
return;
}
#endif

//
// : 01, 02 ..
AnsiString

fastcall IntToStr_(int i)

{
AnsiString s;
if ( IntToStr(i).Length() = = 1 ) s = "0"+IntToStr(i);
else s = IntToStr(i);
return s;

// Paint -
void
fastcall TForml::FormPaint(TObject *Sender)

243

{
Word aDayOfWeek; //
AnsiString st;

// dd.mm

int x, ,
dx< dy, //
,;

//

int i;
= 50; = 40;
dx = 20; dy = 20;
Caption - " " + IntToStr(aYear);
#ifdef BACKGROUND
Canvas->Brush->Color = clBackground;
#endif
#ifdef BACKIMAGE
Canvas->Draw(0, 0,backimage) ,#else
Canvas->Pen->Color = Canvas->Brush->Color;
Canvas->Rectangle(O,O,ClientWidth,ClientHeight);
#endif
//
Canvas->Brush->Style = bsClear;
Canvas->Font->Size = 12;
Canvas->Font->Color = clBlack;
Canvas->TextOutA(xO,yO-35, stMonth[aMonth-1]);
Canvas->Font->Size = 10;
// -
= - 30;

1.

244
= ;
for ( i = 0; i < 7; i++)
{
if ( i < 5 )

Canvas->Font->Color clBlack;
else
Canvas->Font->Color clRed;
Canvas->TextOutA(x,y, stDayfi]);
+= dy;

/* ,
*/
aDayOfWeek = DayOfTheWeek( EncodeDate(aYear,aMonth,1))
x = xO;
= yO + dy * (aDayOfWeek-1);
for ( i = 1; i <= DaysInAMonth(aYear,aMonth); i++ )
{
// ,
st = IntToStr_(i) + "." + IntToStr_(aMonth);
if ( holiday.Pos(st) 1=0 )
Canvas->Font->Color = clRed; //
else

//
if ( aDayOfWeek < )
Canvas->Font->Color = clBlack;

else

//

Canvas->Font->Color = clRed;
Canvas->TextOutA(x,, IntToStr(i));
if ( i aDay) {

245


//
//
Canvas->Brush->Style = bsClear;
Canvas->Pen->Color = clGray;
Canvas->Rectangle(x-3,y-1,x+dx-2,y+dy-1);

if ( aDayOfWeek != 7 ) {
+= dy;
aDayOfWeek ++;
}
else {
aDayOfWeek =1;
x += dx;
= yO;

// UpDown
void

fastcall TForml::UpDownlClick(TObject *Sender,


TUDBtnType Button)
switch (UpDownl->Position) {
case 0 : UpDownl->Position = 12; aYear--; break;
case 13: UpDownl->Position = 1;

aYear++; ,- break;

aMonth = UpDownl->Position;
Paint(); //
}
//
void
f a s t c a l l TForml::ForrriMouseUp(TObject *Sender,
TMouseButton Button,
TShiftState Shift, int X, int Y)

1.

246

// ,
//
Forml->Left = Forml->Left + X;
Forml->Top = Forml->Top + Y;

//
void

fastcall TForml::FormKeyDown(TObject *Sender,


WORD &Key, TShiftState Shift)

if ( Key == 27) // <Esc>


F o r m l - > C l o s e ( ) ; / /

(. 1.76) .

17:21

18:00

. 1.76.

, ,
(). .

247

, , ( ), ,
(System Tray) (. 1.77).
, (. 1.78),

, .
11 I7--23 |
. 1.77.


. 18:00
17:23

X .

. 1.78. ,
,

. 1.79,
. 1.25.

UpDowni
UpDown2

Buttoni

PopupMenui

Timeri

. 1.79.

1.

248

1.25.

UpDownl.Min

UpDownl.Max

23

UpDownl.Wrap

true

UpDownl.Hint

UpDownl.ShowHint

true

UpDown2.Min

UpDown2.Max

59

UpDown2.Wrap

true

UpDown2.Wrap

true

UpDown2.Hint

// *** (AlarmForm.h) ***


#define WM_MYTRAYNOTIFY (WM_USER + 123)
class TForml : public TForm
{
__published:
TTimer *Timerl;
TEdit *Editl;
TButton *Buttonl;
//
TGroupBox *GroupBox2;
TLabel *Labell; //
TLabel *Label2; //
TLabel *Label3; //

249


//
TGroupBox *GroupBoxl;
TLabel *Label4; //
TLabel *Label5; //
TLabel *Label6; //
//
TUpDown *UpDownl; //
TUpDown *UpDown2; //
TPopupMenu *PopupMenul,- //
TMenuItem *N1; //
TMenuItem *N2; //
void

fastcall ButtonlClick(TObject *Sender);

void

fastcall TimerlTimer(TObject *Sender);

void

fastcall UpDownlClick(TObject *Sender,

void

TUDBtnType Button);
fastcall UpDown2Click(TObject *Sender,
TUDBtnType Button);

void

fastcall NIClick(TObject *Sender);

void

fastcall N2Click(TObject *Sender);

// *** ***
// System Tray
void

fastcall CreateTrayIcon(int n, AnsiString Tip);

// System Tray
void

fastcall DeleteTrayIcon(int n ) ;

protected:
// WM_MYTRAYNOTIFY,
// , System Tray
void
fastcall MYTRAYNOTIFY(TMessage &Message);

250

1.
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_MYTRAYNOTIFY, TMessage,
MYTRAYNOTIFY)
END_MESSAGE_MAP(TControl)

private:
public:
fastcall TForml(TComponent* Owner);

// *** AlarmForm.cpp ***


include "DateUtils.hpp"
#include "ShellAPI.hpp"

// Shell__NottifyIcon

#include "mmsystern.hpp"

// PlaySound

int cHour, cMinute;

//

int alrHour, alrMinute; //


//
AnsiString

fastcall mm(int m)

{
if (m <= 9)
return "0" + IntToStr(m);
else
return IntToStr(m);

/
fastcall TForml::TForml(TComponent* Owner)
: TForm(Owner)
//

251


cHour = HourOff Now() );
Labell->Caption = IntToStr (cHour) ,
cMinute = MinuteOf( Now() );
Label3->Caption = mm(cMinute);

/ /
void

System

Tray

fastcall TForml::CreateTrayIcon(int n, AnsiString Tip)

{
TNotifylconData nidata;
/* nidat,
System Tray */
nidata.cbSize = sizeof(TNotifylconData);
nidata.hWnd = Forml->Handle; // ,
//

nidata.uID = n; // (
//
//
nidata.uFlags =

NIF_ICON + NIF_MESSAGE + NIF_TIP;

/*
,

WM_MYTRAYNOTIFY

( . AlarmMainForm.h ) */
nidata.uCallbackMessage = WM_MYTRAYNOTIFY;
//
nidata.hlcon = Application->Icon->Handle;
// ( )
StrPCopy(nidata.szTip,Tip);
Shell_NotifyIcon(NIM_ADD, &nidata);

9 3. 1241

//

1.

252

// System Tray
void
fastcall TForml::DeleteTraylcon(int n)
TNotifylconData nidata;
nidata.cbSize = sizeof(TNotifylconData);
nidata.hWnd = Forml->Handle;
nidata.ulD = n,- // ,
// (
// )
Shell_NotifyIcon(NIM_DELETE, &nidata);

//
void

fastcall TForml::ButtonlClick(TObject *Sender)

{
AnsiString st;
alrHour = UpDownl->Position;
alrMinute = UpDown2->Position;
if ( ( alrHour == cHour ) && (alrMinute <= cMinute)
( alrHour < cHour ) )
{
AnsiString st;
int r;
st.printf(
" %i:%1\ %i:%i",
cHour,cMinute,alrHour,alrMinute
r = MessageDlg(st, mtWarning, TMsgDlgButtons()

mbOK mbCancel, 0) ;

if (r == mrCancel) return;

253

st = ". " + IntToStr(alrHour) + ":" +


mm(alrMinute);
CreateTraylcon(1,st);
Forml->Hide();

//
void

fastcall TForml::TimerlTimer(TObject *Sender)


if ( Forml->Visible )
//
if ( HourOf( Now() ) != cHour) {
cHour = HourOf( Now() );
Labell->Caption = IntToStr(cHour);
if ( MinuteOf( Now() ) != cMinute) {
cMinute = MinuteOf( Now() );
Label3->Caption = mm(cMinute);
// /
Label2->Visible = ! Label2->Visible;

else
TDateTime t = Now();
if ( (alrHour == HourOf(t) ) &&
(alrMinute == MinuteOf(t)) )
PlaySoundCnotify.wav", 0, SND_ASYNC) ;
DeleteTraylcon(1); // System Tray
Forml->Show();
}
}
}

254

1.

// UpDownl ()
void

fastcall TForml::UpDownlClick(TObject *Sender,


TUDBtnType Button)

{
Label4->Caption = IntToStr(UpDownl->Position);

// UpDown2 ()
void

fastcall TForml::UpDown2Click(TObject *Sender,


TUDBtnType Button)

{
Label6->Caption = mm(UpDown2->Position);

//
// WM_MYTRAYNOTIFY
void

fastcall TForml:rMYTRAYNOTIFY(TMessage ^Message)

{
TPoint p;
if

( Message.LParam == m_RBUTTONDCWN )

{
GetCursorPos(&p);
SetForegroundWindow(Application->MainForm->Handle);
Forml->PopupMenul->Popup(p.x,p.y);

//
void

fastcall TForml::NlClick(TObject *Sender)

{
Timerl->Enabled = false;
Forml->Show();
DeleteTraylcon(1); // System Tray

255


//
// ( )
void
fastcall TForml::N2Click(TObject *Sender)
{

Forml->DeleteTrayIcon(l); // System Tray


Forml->Close();


, C++Builder, obj, tds, (~bpr, ~dfm, ~h, ~cpp) .
() (. 1.80).
. 1.81.

! ,
; ++, (obj, tds)
(~bpr, ~dfm, ~h, ~cpp)
I .
1

:
...

|
-2J-XI

(F:)
S Q

Documents and Settings

- p HOS

I G J HIS
: - Q H2S
ffl-f*1 Inetpub
Si Q Program Files
$ - Q TEMP
ffl -CJ vbrkit
ffi WINNT
d VAMAHA
..$(1 WnmnAICT-niACW

. 1.80. .

1.

256
*

,
C++Builder, (obj, tds)
(~bpr, ~dfrn, ~h, ~cpp)
..
:
: : "
'
: *!

Label3
Buttoni

Button2
Memol

. 1 . 8 1 .

clear. : , . , clear ,
. , (
) clear,
.
#include <FileCtrl.hpp> // , SelectDirectory
AnsiString aDirectory; // ,
// ( C++Builder)
AnsiString cDir;

//

AnsiString FileExt;

//

int n = 0;

//

257

// ( )
void

fastcall TMainForm::ButtonlClick(TObject *Sender)

{
if ( SelectDirectory(" ","", aDirectory))
{
//
Label3->Caption = aDirectory;
Button2->Enabled = true; //
//

//
//

void

fastcall Clear(void)

TSearchRec SearchRec; //
cDir = GetCurrentDir()+"\\";
if ( FindFirst("*.*", faArchive,SearchRec)

0)

do {
//
int p = SearchRec.Name.Pos(".");
FileExt = SearchRec.Name.Substring(p+1,MAX_PATH);
if ( ( FileExt[1] =='-') || ( FileExt == "obj" )
|| ( FileExt == "tds" )
)
{
MainForm->Memol->
Lines->Add(cDir+SearchRec.Name);
DeleteFile(SearchRec.Name);

1.

258

while ( FindNext(SearchRec) == 0);


//
if ( FindFirst("*", faDirectory, SearchRec) == 0)
do
if ((SearchRec.Attr & faDirectory) ==
SearchRec.Attr )
//

// !!!

if (( SearchRec.Name != "."

) &&

( SearchRec.Name != ".." ))
//
ChDir (SearchRec. Name) ;
//
Clear();
//
ChDir("..");

while ( FindNext(SearchRec) = = 0 ) ;

//
void

fastcall TMainForm::Button2Click(TObject *Sender)

{
Memol->Clear();
ChDir(aDirectory);

// Memol
// ,
//

Clear();

//
//

259


Memol->Lines->Add("");
if (n)

Memol->Lines->Add(" : " + IntToStr(n));


else
Memol->Lines->Add(" , "
" .");

, . 1.82, ( ) .
:

.=.13

1
2 .. C++Builder.
3
4
5
6
7
8
9
10

98,00

| -

490,00

'): 490 .

i ]

. 1.82.

void

f a s t c a l l TForml::FormCreate(TObject *Sender)
/ / ***

***

StringGridl->Options

g o E d i t i n g / /

1.

260

goTabs;

// <Tab> -

//
StringGridl->Cells[O][0] =
StringGridl->Cells[l][0] = " ";
StringGridl->Cells[2][0] = " ";
StringGridl->Cells[3][0]

-";

StringGridl->Cells[4][0] =

";

//
StringGridl->ColWidths[0] = 30;
StringGridl->ColWidths[l] = 250;
StringGridl->ColWidths[2] = 80;
StringGridl->ColWidths[3] = 50;
StringGridl->ColWidths[4] = 80;
//
for ( int i = 1; i < 11; i++)
if (i < 10)

. ,

StringGridl->Cells[0)[i] = "

" + IntToStr(i);

else
StringGridl->Cells[0][i] = IntToStr(i);
int w = 0;
for (int i = 0; i < StringGridl->ColCount; i
w += StringGridl->ColWidths[i];
// StringGrid
//
StringGridl->Width = w + StringGridl->ColCount + 1 ;
StringGridl->Height =

StringGridl->DefaultRowHeight * StringGridl->
RowCount + StringGridl->RowCount + 1;


#include

261

"Printers.hpp"

/ /
void

f a s t c a l l T F o r m l : : B u t t o n 2 C l i c k ( T O b j e c t *Sender)

{
TPrinter *Prn; //
#define LEFT_MARGIN 2 // 2
#define TOP_MARGIN

2 // 2

float dpix, dpiY,- // X Y


float , ky;

// .
// X Y

//
int [5]; //
int xl,yl,x2,y2; //
int , ; //
int i, j;
/* ,

,

, .,
.
, 300 dpi,
3.125, . .
- 96 dpi */
Prn = Printer () ,/* - GetDeviceCaps
. LOGPIXELSX - - X

262

1.
dpiX

= GetDeviceCaps(Prn->Handle,LOGPIXELSX);

dpiY

= GetDeviceCaps(Prn->Handle,LOGPIXELSY);

kx

dpiX / Screen->PixelsPerInch;

ky

dpiY / Screen->PixelsPerInch;

px

LEFT_MARGIN / 2.54 * dpiX;

py

TOP_MARGIN

/ 2.54 * dpiY;

// ""
[0]

= ;

for (i = 1; i < 5; i++ )


p[i]

p[i-l] + StringGridl->ColWidths[i-l]* kx + i;

Prn->BeginDoc(); //
//
Prn->Canvas->Font->Name

Labell->Font->Name;

Prn->Canvas->Font->Size

Labell->Font->Size;

Prn->Canvas->TextOut(px,py,Labell->Caption);
// - StringGridl

= + Labell->Font->Size * 2 * ky;

xl

px; yl

py; //

Prn->Canvas->Font->Name

StringGridl->Font->Name;

Prn->Canvas->Font->Size

StringGridl->Font->Size;

x2

p[4] + StringGridl->ColWidths[4]* kx;

y2

py + StringGridl->RowCount *
StringGridl->RowHeights[l] * ky;

for ( j = 0; j < StringGridl->RowCount; 'j

263

//
for (i = 0 ; i < StringGridl->ColCount; i
Prn->Canvas->TextOut(p[i],py,
StringGridl->Cells[i][j]
// ->
Prn->Canvas->MoveTo(p[0],py);
Prn->Canvas->LineTo(x2,py);
}
= + StringGridl->RowHeights[j]* ky;

//
for ( i = 0; i < StringGridl->ColCount; i++ )
{
Prn->Canvas->MoveTo(p[i],yl);
Prn->Canvas->LineTo(p[i],y2);
}
//
Prn->Canvas->MoveTo(x2,yl);
Prn->Canvas->LineTo(x2,y2);
//
Prn->Canvas->MoveTo(xl,y2);
Prn->Canvas->LineTo(x2,y2);
= y2 + 0.5 / 2.54 * dpiY; // 1 - 1 .
Prn->Canvas->Text0ut(p[3],py,Label2->Caption);
Prn->EndDoc();

/ /

//

264

1.

void

fastcall TForml::ButtonlClick(TObject *Sender)

{
float summ;
surran = 0;
for ( int i = 1; i < 11; i++)
{
// ,
// StrToFloat ()
try
{
summ += StrToFloat(StringGridl->Cells[4][i]);
}
catch (Exception &e)

Label2->Caption - ": " + FloatToStr(summ) + " .";


}

,
.


. ,
1000 ., .
. 1.83.
Label , ,
. , ,
.

{.}'.

< *

..

.'

. 1.83.

266

1.


.
: = * ( / 360) * ( / 100),
: ; ( );
().
. 1.84.
/ <_
(.) () .-'!
{ )

. 1.84.


, .
10
. . 1.85. Labeli
, Label2 .

Labeli

Label2

. 1.85.

267


,
.
. 1.86.
1 jK
(./^

; ; ( 1 )


;:

()

[\

'.'.'..','.'.

'

...

. 1.86.



.
. 1.87.

(] 1

(
|
J

*
f*4

. 1.87.

. 1241

1.

268

,
(). . 1.88.

()

f*1

()

"

Ok

. 1.88.

,
.
. 1.89.

-101*1

_JJ
. 1.89.

269

, electr.txt
( ).
. 1.90.
[^


ok

. 1.90.

, ( Memo)
electr.txt.


, ,
.

,
.
. 1.91. .

Labeli Label3 Label2


. 1.91.

1.

270

,
(. 1.92).

. 1.92.

,
.


,
(. 1.93). .

. 1.93.

271

, , , , ,
(. 1.94).
-

' .


( USD)

360

270

1 17"

19"

. 1.94.


,
,
" ? ?"
. 1.26.
1.26.

( )

40%

30%

22%

1.

272

1.26 ()

( )

3%

3%

1%

1%

, ""
(. 1.95).
.

. 1.95.

,
( ; ; ; , )
.

( )
, () .

273

,
. , ,
, , . :
, .
. 1.96.
-

. 1.96.

, .
, inputBox.

""
.
, ,
( , : , ,
, , ).
. Paradox ( rash.db)
Database Desktop.

. 1.97.

1.

274

Date

(Summ

I Cat

Si.L

. 1.97.

2
Borland C++ Builder


Borland
C++ Builder.


( TForm) . (. 2.1) .
2.1. ( TFcrm)

Name

Caption

Top

Left

Width

Height

ClientWidth

() , . .

ClientHeight

() , . .

278

2.1 ()

BorderStyle

. (bsSizeable), (bsSingle)

(bsNone). ,

.
. ,
.

Borderlcons

. , .
biSystemMenu,
b i M i n i m i z e , biMaximize b i H e l p .
biSystemMenu , b i M i n i m i z e ,
biMaximize , b i H e l p

icon

Color

. ,
. ,

Font

, " " , . Font Font ,


.
Font
( )

Canvas

C++ Builder. .

Borland C++ Builder

279

Label

Label (. 2.1)
. (. 2.2) .

I Standard j
|

.j-jj

g r s ) is? e

. ". i _ ___,_._
label

g g

-,

. 2 . 1 . Label
2.2. Label ( )

Name

Caption

Left


Height

width
Autosize

Wordwrap

, ,
, ( A u t o s i z e f a l s e )

Alignment

.

( t a L e f t J u s t i f y ) , (taCenter)
( t a R i g h t J u s t i f y )

280

2
2.2 ()

Font

, .
(Name),
( s i z e ) , ( s t y l e )
(color)

ParentFont


, .
t r u e , ,

Color

Transparent

. t r u e
( , Color)

visible

( f a l s e )
(true)

Edit

Edit (. 2.2) /
. . 2.3.
Standard |
Edit

. 2.2. E d i t /

Borland C++ Builder

281

2.3. Sdi t
( /)

Name

. ,
,

Text

Left

Height

Width

Font

ParentFont


, .
t r u e , ! Font
Font

Enabled


.
f a l s e ,

visible

( f a l s e )
(true)

Button

Button (. 2.3)
. . 2.4.

282
Standard |

Button
. 2.3. B u t t o n
2.4. Button
( )

Name

Caption

Left


Height

Width
Enabled


.
t r u e , . f a l s e , , ,
c l i c k

visible

( f a l s e ) (true)

Hint

, ( , showHint t r u e )

ShowHint

(true) ( f a l s e )

Borland C++ Builder

283

Memo

Memo (. 2.4) , .
. 2.5.
Standard [

|. gjLaJ 1* 1
Memo

. 2.4. Memo
2.5. Memo

Name

Text

, Memo.

Lines

, .
.

Left

Height

Width

Font

ParentFont

284

RadioButton

RadioButton (. 2.5)
,
. . 2.6.
,
RadioGroup.
Standard I

RadioButton
. 2 . 5 . R a d i o B u t t o n

2.6.

RadioButton

Name

Caption

checked

, : , checked = t r u e , ,
Checked= false

Left

Height

width

Font

ParentFont

Borland C++ Builder

285

CheckBox

CheckBox (. 2.6)
().
. 2.7.

fStindard]

||

| il
CheckBox
. 2.6. CheckBox
2.7. CheckBox

Name

Caption

Checked

, : ( ""),
Checked t r u e ; (
""), Checked f a l s e

State

. Checked,
,
. : cbChecked ();
cbGrayed (, );
cbUnChecked ()

AllowGrayed

, : AllowGrayed
f a l s e , ; A l l o w Grayed t r u e ,

Left

286

2
2.7 ()

Height

width

Font

ParentFont

ListBox

ListBox (. 2.7) , .
. 2.8.
\ Standaid I

L&l lx <s ||;'

ListBox
. 2.7. L i s t B o x
2.8.

ListBox

Name

Items->Strings

(
)

Count

Sorted

(true) .

Borland C++ Builder -

287
2.8 ()

Itemindex

(
).
,

Left

Height

Width

Font

ParentFont

ComboBox

ComboBox (. 2.8)

. . 2.9.
Standard
A'jar
-

<?<

:~J

ComboBox
. 2.8. ComboBox
2.9. ComboBox

Name

Text

, /

288

2
2.9 ()

Items->Sbrings

- (
)

Count

Itemlndex

, .
,
2

Sorted

(true)

DropDownCount

.
DropDownCount,

Left

Top

Height

( /)

Width

Font

ParentFont

StringGrid

StringGrid (. 2.9) ,
. . 2.10.

Borland C++ Builder

289

"ST

StnngGrid
. 2 . 9 . S t r i n g G r i d

2.10.

StringGrid

Name

ColCount

RowCount

DefaultColWidth

DefaultRowHeight

FixedCols

FixedRows

Cells

.



.
. , c o l
row,
cells[col][row]

GridLineWidth

Left

Top

290

2
2.10 ()

Height

Width

Options.goEditing

, t r u e , f a l s e

Options.goTab

(true) (false)
<>

Options.
goAlways ShowEdi tor


.
f a l s e , , , , <Fr2>

Font

ParentFont

Image

image (. 2.10)
, BMP (
JPG, JPEG #inciude <jpeg.hpp>). image . 2.11.
| Additional]

| &
Image
. 2 . 1 0 . Image

Borland C++ Builder

291

2.11. image

Picture

Width, Height

.

AutoSize, S t r e c h P r o p o r t i o n a l f a l s e ,

Proportional

.
, A u t o S i z e
f a l s e

Strech

( )
.
,

AutoSize

Center


,
.
f a l s e , , t r u e

Visible

, , ,
,

Canvas

Timer

Timer (. 2.11) OnTimer.


. 2.12.

292

2
_j System i
' 1

Timer
. 2 . 1 1 . T i m e r

2.12. Timer

Name

Interval

OnTimer.

Enabled

. ( t r u e )
( f a l s e )
OnTimer

SpeedButton

SpeedButton (. 2.12) ,
. . 2.13.

SpeedButton
. 2 . 1 2 . S p e e d B u t t o n

2.13. SpeedButton

Name

Glyph

, .
(. 2.13)

Borland C++ Builder

293

2.13 ()

NumGlyphs

Glyph

Flat

F l a t ( ). t r u e ,

Groupindex

. ,
,
: .
,
Groupindex

Down

.
, Groupindex

AllowAllUp

. t r u e ,

Left

Height

width
Enabled


.
t r u e , . f a l s e ,

visible

( f a l s e ) (true)

Hint

, ( , ,
ShowHint true)

ShowHint

(true) ( f a l s e )

294

>

. 2.13. Glyph: ,
Play/Stop

UpDown

upDown (. 2.14) ,
- .

. . 2.14.
Wn
i 32 !
1

...:... -

iJFurqr 3 G ~ ] ^

1
UpDown

" "" -

. 2.14. UpDown
2.14. vpDown

Name

Position

. up () Down
().
Min ,
Increment

Min


Position

Borland C++ Builder

295
2.14 ()


Position

Increment

, P o s i t i o n

Associate

( E d i t /
), P o s i t i o n .
,
P o s i t i o n

Orientation

". ( u d v e r t i c a l )
( u d H o r i z o n t a l )

ProgressBar

ProgressBar (. 2.15) ,

, , () ,
. . ProgressBar
. 2.15.

J T

i w ' 53 F
ProgressBar
. 2.15. ProgressBar
2.15.

ProgressBar

Position

,
() . ( )
P o s i t i o n

296

2
2.15 ()

Min

P o s i t i o n

Position

step

()
P o s i t i o n Value s t e p i t

Smooth

.
( f a l s e )

StatusBar

statusBar (. 2.16) () , (
).
.
statusBar . 2.16.
! Win32

| -par ef |
StatusBar
. 2.16. StatusBar
2.16.

statusBar

Panels

TStatusPanel (. 2.17),

StatusBar

simplePanel

, .
t r u e , , , , SimpleText

Borland C++Builder

297
2.16 ()

simpleText

, ,
(
SimplePanel true).
, , , Text
Panels
2.17.

rstatusPanel

Text

width

.
,
(
StatusBar)

Animate

Animate (. 2.17) , , AVI.


. 2.18.

i
An
m
i ae
t

. 2.17. Animate
2.18. Anima te

Name

298

2
2.18 ()

FileName

AVI,
,

StartFrame

StopFrame

Activate

Color

( ""),

Transparent

""

Repetitions

MediaPlayer

MediaPlayer (. 2.18) , .
. 2.19.
J System~]_

MediaPlayer
. 2.18. M e d i a P l a y e r
2.19.

MediaPlayer

Name

Borland C++Builder -

299
2.19 ()

DeviceType

. ,
MediaPlayer. : d t A u t o S e l e c t
, dtvaweAudio , dtAVivideo , dtCDAudio CD-

FileName

AutoOpen


,

,
(
Panel)

Display

VisibleButtons

. .

Table

Table (. 2.19)
. . 2.20.

I BDE
Table
. 2.19. Table
2.20. Table

Name

. I241

300

2
2.20 ()

Da t aba seName

,
( ),
.

TableName

( ),

TableType

.
Paradox (ttParadox), dBase (ttDBase),
FoxPro (ttFoxPro) (ttASCii)

Active

, (
). t r u e

Query

Query (. 2.20)
, SQL- .
. 2.21.

Query
. 2.20. Query

2.21. Query

Name

DataSource ( ) , , , DBGrid

Borland C++ Builder

301
2.21 ()

SQL

SQL-
( )

Active

t r u e

RecordCount

DataSource

DataSource (. 2.21)
, Table Query,
(DBEdit, DBMemo
DBGrid). . 2.22.
I Data Access |
I; k

-is, l i r a ; XML 3 W I y r :

DataSource
. 2.21. DataSource
/
2.22. DataSource

Name

.
, , ,

DataSet

, (Table Query)

DBEdit,

DBMemo,

DBText

DBEdit DBMemo (. 2.22) , DBText . . 2.23.

302

2
Data Controls

''
DBText

DBMemo
DBEdit

. 2.22.
2.23. DBText, DBEdi t DBMemo

Name

DataSource

DataField

DBGrid

DBGrid (. 2.23) . . 2.24.


ppala Controls

% il

DBGrd
i
. 2.23. DBGrid

2.24. DBGrid

Name

DataSource


( DataSource)

Borland C++ Builder -

303
2.24()

Columns

columns
TColumn,
(. 2.25)

Options.dgTitles

Options.dglndicator

.
, ,

Options.dgColumnResize

Options.dgColLines

Options.dgRowLines

2.25. TColumn

FieldName

Width

Font

Color

Alignment

.
( t a L e f t J u s t i f y ) , (taCenter)
( t a R i g h t J u s t i f y )

304

2
2.25 ()

Title.Caption

Title.Alignment

.
( t a L e f t J u s t i f y ) , (taCenter)
( t a R i g h t J u s t i f y )

Title.Color

Title.Font

DBNavigator

DBNavigator (. 2.24)
, , .

DBNavigator
. 2.24. DBNavigator


(. 2.25, . 2.26). . 2.27.

. 2.25. DBNavigator
2.26.

DBNavigator

nbFirst

nbPrior

Borland C++ Builder

305
2.26 ()

nbNext

nbLast

I 4-1

nblnsert

-\

nbDelete

]
"

nbEdit

nbPost

, ,

Cancel

nbRefresh

I
J

2.27.

DBNavigator

Name

DataSource

,
.
( Database),
( Table) ( Query)

VisibleButtons

306

Canvas
canvas ( image),
(. 2.28)
. , (. 2.29).
2.28. Canvas

TextOut(x,y,s)

s
(, ). Font , ,

Brush

Drawfx,y,b)

(, )
.
T r a n s p a r e n t , t r u e , ,

,

LineTo(x,y)

MoveTo(x,y)

PolyLine(pl)

.
p i
TPoint. ,
.

Borland C++Builder --

307

2.28 ()

Polygon(pi)

.
p i
TPoint.
. ,
Brush

Ellipse
(xl,y,x2,y2)

, .
x l , y l , x2 2
, .
(1.1)

(2,2)

(2.2)

A r c ( x l , y l , x 2 , y 2 ,

,,4,4)

. x l , y l , 2,
2 , , 2, 2, , 4 .
(, )
(4, 4). () ,
Brush

(xi.yi)

(1.1)

308

2
2.28 ()

Rectang l e ( x l , , 2,2)

. x l ,
y l , 2 2 . , Brush

RoundRec
(xl,yl,x2,y2,x3,y3)

. x l , y l , x2 2
, - . ,
Brush

(2.2)

2.29. Canvas

Transparent

""
Draw. t r u e , ,

,

Pen

(.
. 2.27),
,

Borland C++ Builder

309
2.29 ()

Brush

Brush (.
. 2.28),
,

Font

Font , (, , , ),

Canvas. (. 2.30) , ,
.
2.30.

Color

( c l B l a c k ; clMaroon ; clGreen ; c l o i i v e ;
clNavy -; c l P u r p l e ; c l T e a l
-; c l G r a y ; c l s i l v e r ; clRed ; clLime ; c l B l u e
; c l F u c h s i a -; clAqua ; c i w h i t e )

style

() . : p s S o l i d
; psDash ( );
psDot ( ); psDashDot
( ); psDashDotDot (
); p s c l e a r (, , , )

width

. 2

370

Brush

Brush canvas. Brush (. 2.31) , ,


.
2.31. TBrush ()

color

style

() ( b s S o l i d
; b s C l e a r ;
bsHorizonta! ; b s V e r t i c a l
; bsFDiagonal
; bsBDiagonal ; bsCross - , ; bsDiagCross )

(. 2.322.35).
.


2.32.

InputBox{,
,
)

,
.
. " ",
. . ,

Borland C++Builder

311

2.32 ()

ShowMessage(s)

ShowMessage ,

s
MessageDlg(s,t,b,h)

s ,

. t :
mtWarning ; m t E r r o r
; m t l n f o r m a t i o n ;
m t C o n f i r m a t i o n ; mtCustom
( ).
b ( )

(mbYes, rnbNo, mbOK, mbCancel, mbHelp,


mbAbort, mbRetry, m b l g n o r e mbAll).

h
,
Help <F1>.
, 0.
: mrAbort, mrYes,
mrOk,
mrRetry,
mrNo,
mrCancel,
m r l g n o r e m r A l l ,


2.33.

abs(n)

sqrt(n)

()

312

2
2.33 ()

rardom(n)


-1 (

r a n d o m i z e ( ) , )

sin(a)

cos()

tan()

a s i n ( n ) , acos (n),
atan(n)

( ), ,

,
, #Include <math.h>.
.
(*. 1415256) /180, , 3.1415926 "". 3.1415926
M_PI. M_PI math.h.


2.34.

IntToStr(k)

FloatToStr()

Borland C++Builder

313
2.34()

FloatToStrF(n,f,k,m)

, . : f ; ; .

: f f G e n e r a l ;
ffExponent ; f f F i x e d
; ffNumber
; f f Currency .
: 7
s i n g l e , 15
Double 18 Extended

StrToInt(s)

,
s

StrToFloat(s)

,
s



TDateTime,
.
Dayof,
weekof, Monthof ,
#include

<DateUtils.hpp>.

2.35.

Now ()


TDateTime

DateToStr(dt)

,
dd.mm.yyyy

314

2.35 ()

TimeToStr(dt)

hh:mm:ss

DayOf(dt)

( ), ,

MonthOf(dt)

, ,

WeekOf(dt)

, ,

YearOf(dt)

DayOfWeek(dt)

,
: 1 , 2
, 3 . .

StartOfWeek(w)

HourOf(dt)

MinuteOf(dt)

SecondOf(dt)

DecodeDate(dt,y,m,d)

, ,

DecodeTime(dt,h,m,s,ms)

(, ,
),

FormatDateTime(s,dt)

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

Borland C++ Builder

315

2.36.

Onclick

OnDblciick

OnMouseDown

OnMouseUp

OnMouseMove

OnKeyPress

OnKeyDown

. KeyDown OnKeyPress , ,
, (
OnKeyUp)

OnKeyUp

OnCreate

(, ).
,

OnPaint

, , , , .
()

OnEnter

OnExit

, .

316

2.37.

EConvertError

,
.

EDivByZero

. ,

EZeroDivide

.
,

EFOpenError

, ,
LoadFromFile.
,
,

EInOutError

, ,
( r e s e t )

EDBEngineError

, , SQL-


CD-ROM
CD-ROM C++Builder,
.
(. 1) .
, Windows.

CD-ROM ( , Borland
C++Builder Version 6). , , , ( ODBC).
, ,
.
1. CD-ROM
()

CD Player

CD-.

.
MediaPlayer

CDP

CD-.

.
MediaPlayer,

318

1 ()

()

MEdit

. RichEdit, MainMenu, ToolBar,


SpeedButton, OpenDialog, SaveDialog,
,

MIDI

60
MediaPlayer
MIDI-. " ", , ,

Player

- . MediaPlayer,
Play/Stop

Spending

, (tabl.grd).

StringGrid.
!

"Spending" "", ""


VideoPlayer

VideoPlayer
AVI MPG

AVI-
Animate.

( ) . "" -
. ,
, ,

CD-ROM

319

1()
()

. ,
System Tray ,

( LineTo, TextWidth, TextOutA)



Internet

Internet ,
Internet Explorer
-

"".

ADOConnection,
ADODataSet,
DataSource,
Table DBNavigator. "" (Planer.mdb)
ODBC dpianner

"
". BDE Table Qery,
DBGrid DataSource. (adrbk.db)
adrbk (Type: Standard, Default Driver: Paradox).

BDEAdministrator

Windows

Windows , Windows\Media. MediaPlayer


( Pie,
Rectangle,
TextOutA)


. ,
. . ,

320

1 ()
()

. C l i c k

_2

-2


CheckBox


.
TextBox Label. ,


ComboBox

(5 "".

, D a t a S o u r c e , D B G r i d , D B E d i t , DBMemo.

Paradox.
, BDE
Administrator, stock (Type:
Standard; Default Driver: Paradox)


. ComboBox,

,

C++Builder, (obj, tds)
(~bpr, ~dfm, ~h, ~cpp) .

.
, .
pictures.bmp

CD-ROM

321

1 ()
()

- ,

( Meteo.bpr)
meteo.txt .
, . ( Meteolnfo.bpr)
(meteo.txt)

,
bmp-.
, ,
(
)

jpg-. L i s t B o x ,
OpenDialog, Image

^?


JPEG, ,
.
.

-

. ,

Timer

322

1 ()
()

TextBox Label,
EZeroDivide (
)

"15" (
). bmp-,
, ,
,

,
, . RadioButton


.
hip ,

_2


. \ ,

,
.
Puzzle.bmp

- .
,

CD-ROM

323

1 ()
()

, .
.
. "",
. "", ""

.
txt-. .
peterburg.txt. .
,
|

_2

.
XMLDocument ( XML-).
.
bat- (.
economics.bat)

,
( )

Brush 309, 310

Pen 308, 309

Canvas 278, 291


ClientHeight 278
ClientWidth 278
X

Transparent 308

XML- 232

311
312

:
81, 114
118
57

:
AVI 150
CD 142
MIDI 138

128
WAV 124
150
:
62
259
:
81, 306
306

:
115
114
109
100

104
114
84
87
93
82
121

:
128, 255
181
33
307

:
CD 142
MIDI 138
128
PlaySound 246
WAV 124

:
EConvertError 316
EDB Engine Error 166
EDivByZero 316
EFOpenError 316
EZeroDivide 316
EZerroDivide 12

308
311
309
:
ADOConnection 172

325

ADODataSet 172
Animate 158, 297
Button 281
CheckBox 18, 285
ComboBox 21, 28, 65, 287
DataSource 162, 166, 301
DBEdit 166, 301
DBGrid 162, 166, 302
DBMemo 166, 301
DBNavigator 304
DBText301
Edit 280
Form 277
Image 100, 290
Label 6, 279
ListBox 33, 128, 286
MainMenu75, 180
MediaPlayer 125, 138, 298
Memo 255, 283
MonthCalendar 62
Open Dialog 33, 75
PopupMenu 246
ProgressBar 51, 295
Queiy 162, 300
RadioButton 16, 284
RichEdit 75
SaveDialog 75
SpeedButton 75, 128, 142, 292
StaticText 36
StatusBar 54, 296
StringGrid 70, 259, 288
Table 162, 166, 299
TextBox 6
Timer 48, 291
Tool Bar 75
TrackBar 128
Up Down 246, 294
XMLDocument 232
43, 218

326

312
307

306
306
306

43
:
TextHeight 82
TextWidth 82
307

148, 241
307

246
308
308

128

312
312

58
60
HLP 58

1.

:
62
255
62
65, 218
:
Abs 311
Arc 312
Cos 312
DateToStr313
DayOf314
DayOfWeek 314
Decode Date 314
DecodeTime 314

ExtractFileName 33
ExtractFilePath 33
FileClose 62
FileCreate 62
FileDelete 255
FileOpen 62
FileSeek 62
FileWrite 62
FindFirst 33, 129, 255
FinclNext 33, 129, 255
FloatToStr312
FloatToStrF 313
FonnatDateTime 314
HourOf314
InputBox 310
IntToStr312
MessageDlg 311
MinuteOf 314
MonthOf314
Now 313
ParamCount 232


ParamStr 232
PlaySound 246
R a n d o m 312
R a n d o m i z e 198
R a n d o m R a n g e 198
ReadFile 65
SecondOf314
Shell Execute 57
ShowMessage 311
Sin 312
Sqrt 311
StartOfWeek314
StrToFloat 313
StrToInt 313
TimeToStr314
WeekOf314
WinExec 58

327
YearOf314

1
:
309
308

:
XML- 232
65, 218

307

\"

30 000
it- ?


softIine
-direct!

?
IT?
-,
?
, -.
, IT
? Soft Line9 -direct .
, . IT-
.
, : ,
.
.
, .
SoftUne'-direct (Microsoft, Unux, Novell, Apple). Soft!jne*-direct
:
Softlinc'-dircct Standard Edition
Softline*-direct Professional Edition
SoftUne'-direci Enterprise Edition

!
SoftLine*-Direct .: +7(095)232-00-23
www.softline.ru

" ^ ^

, ,
7 ( 0 9 5 ) 2 3 2 - - 2 3
W wjw

Вам также может понравиться