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

.

C++

Borland C++Builder 5.0

I-Press
- 2001

.
C++
Borland C++Builder 5.0
I-Press

.
.
;
:

ISBN 5-93650-013-6 ( *)

., 2001
I-Press, 2001
, 2001

00219 11.10.99. 10.11.2000.


70x100/16. . . . 17. . 1000. 1064
, 105484. . , . 16- , . 21, . 1.


199034, .-, 9 , 12

?
?
C++?
?
Borland C++ Builder?
?

1.
Borland C++Builder 5
C++Builder

Borland C++Builder
C++Builder

?


(Object Inspector)



11
12
13
14
16
16

18
18
22
23
25
25
26
26
27
27
28
28
28
31
31

2.




Edit ( )
Label ( )
Button ( )


?
++

?
C++Builder


++











,
float
double
long double

34
34
34
34
35
35
37
38
38
39
40
40
41
42
43
44
45
46
47
49
50
52
52
52
55
56
57
57
59
59
61
61
63
64
64
64
65
67

3.

67
69
70
71
74
79

80

80
81
83
85

4.

86

5.



86
86
89

90
90
90
93
94

6.

96

96
97
99

7.







101
101
102
102
102
103
106
107
108

8. .
?




















9.
-











,

110
111
111
111
112

115
117
118
118
118
119
119
119
120
121
122
123
125
125
127
130

132
132
133
134
135
137
138
139
141
141
142
144
145
145




















++

10.
?









?


?



146
148
149
149
151
151
151
152
153
153
154
155
156
158
159
159
159
161
162

163
163
164
164
165
166
166
167
168
170
170
170
171
171
172
174
175
176
177


















-2
?









1 1 .
?
++







178
179
179
180
181
183
185
186
187
187
187
189
191
192
193
194
199
200
200
201
202
203
204
208
213
214
215
217
217
217
218
218
220
220
222
224
224
226



C++Builder

229
232
233

12. ,

233


Standard

Additional



Win32

235
235
235
235
236
236
236
236
237
238
238
238
239
239
239
239
240
240
240
240
241
241
241
242
242
242
243
244
244
244
245
245
246
246







System



OLE-
Dialogs
!
C++Builder

13.
Borland C++Builder


10

247
247
247
248
248
248
248
249
249
250
252
253
255
255
255

262
262
262
263
263
263
263
264
264

266


?
, ,
, Windows,
. 400 ,
- ,
,
, .

{) . ( ), ,
, .
, , , , ,
, :
;
;
,

.
, . ,
.

11

?
( , ),
, . , .
, , .
- . ,
, .
, ,
,
.
,

! .

.
. ,
. , ,
, .
:
,
: .
.
, . , . (
Borland C++) . ,
, (
), , , ,
. ,
.

12

C++?

, , . , ,
, .
, , . ,
.
,
. :
.
, .
. , ,
3 0- 20-,
, .
, , .
. , ,
, :

,


( >
<), , .
. ,
60%
( ).

. .

C++?
++ 1983 .

. ++ -

13

_ ^

.
, ++

, , , , ,
, , . ++
.
++ . , .
, Windows
++.

?
++ , , , .
, .
.
, ++ Windows.
++, Windows .
,
, , , . Windows ,
, .
.
Windows, . . ,
, .
,
++, , .
,
++ .

14


, ,
Windows Linux.

.
++ Windows,
! ,
.
(, . .)
( ),
.
, ,
.

(RAD-), ,
, , .
, , , ,
Windows ( RAD- ), .
. RAD-
:
, ,
.
, :
;
;
;
- ,
, .
RAD- -. , , , .

15


( , ,
) , ! , Windows,
, .
, .
(, ) .
, shareware. , .

Borland C++Builder?
Borland C++Builder, 2000 ,
++ Windows. 200
, . Borland C++Builder Microsoft
Visual C++, RAD-,
a Microsoft Visual Basic, .
, C++Builder,
, MS Visual Basic.
C++Builder
.
RAD- Borland Delphi,
, C++Builder.
Delphi C++,
, - ObjectPascal. , Borland C++Builder
++, !

?
, RAD-, . 500 , 32 .

16

?
, , , ( ++ )
.
Windows 95 Windows 98, Windows NT.
,
Windows 9x. , , , ,
.
Windows NT, C++Buitder - ,
. ,
, Windows 98,
Windows 98,
, . , , C++Builder,
Windows 9x Windows NT.
, .

C++ . , ,
, .
:
17 , 1024x768.
:
15 , 800x600.
:
15 , 1024x768.

17

1.
Borland C++Builder 5
Borland C++Builder,
() .
.
1. .
Borland C++Builder .
, , - , Windows .
instalt.exe .
2. ( C++Builder
). C++Builder (. . 1), , , 543
( ).
3. C++Builder
. .
4. , Next ().
5. Next
() .

18

Borland C++ Builder 5

. 1.
6. . ,
C++Builder 5, ,
. , ,
, .
, Yes
.
7.
, Next
()...
8. ... :

(Typical);

(Compact);

(Custom);

(Full).

(Typical).
.
(Compact) . (Custom)

19

1.
, , .
(Full) ,
550 .
, .

9. ,
Microsoft Office (MS Office 97 MS Office 2000)
C++Builder
, Word, Excel . .
10. ( ) (. . 2).

. 2.

11. , ,
. ,
,
Install VisiBroker For C++Builder.
,
() InterBase.
,

20

Borland C++ Builder 5


, Install InterBase Client.
, ,
. , , ,
:
/ , /, / , /, $
, , :

Pentium II/450/64/10/500
, ,
, ?
,
(). ,
Borland C++Builder.

12. Next (), . .


,
Agree ().
13. (. . 3) , C++Builder. Browse (),
. , C++Builder,
.
Inprise (, Borland Delphi), , .
, , .
C++Builder , (Req:) (Avail:).
, Next ().

21


Select Component Directories
leas t Ihe location where you would Sfce to install the
jrogtam
Bjovgse..
Req: 315159 .
Avaa:2323BK

gram riles 1
ICVPmgramFle
i s.
R* :6742K "
Avail :S4574
sred files
.e \laigsv3etnfi\.Borland Shared
Avail :84574
I and S6L Links
e- MangsSdep
l h-^E ortand S hae
i c^BDE
q

Infu...

Avail:292^)6K
abase Desktop Req :3831
CAPsegtan Filss\Bo-lndTat2base Desktop

Cancel

PMC. 5.
14.
,
C++Builder . , Next ().
15. Install ()
.
. , 10 .
readme.txt
C++Builder. Next ().
16. .
Finish () Windows.

C++Builder
, .
Borland C++Builder
Borland C++Builder 5.

22


C++ Builder , .
Help,
.


(IDE) .
. Borland
C++Builder 5 (. . 4):
C++Builder;
(Object Inspector);
;
.

.-'* i Builder -

1 tf.' Search iew ErajecJ B-r> icmocsit Qetobase j.cals help j<>JJ''
|2 & ' Q

e ^ S

l^bf'

5tMiard j Addliaiai ] ^r,321 Swterr 1 Da's ! - Zoriinl* . i l l .

a OBerhes
l | Eventi
l
P'
j
Ackm

AiQfi
bue
faisa

-o'-i
2
33S

[T SizaCcnihw ^ j
Madided

Insert

. 4. IDE

23

1.
, , :

(Class Explorer);

.
Uniti cpp
Project! -Classes

cpp

j#prsga hdcstop
-j^mclude "UnitI. h"
|//
:'j#pragiaa package smaKt_ir,iL)
;#pr&gitia r e s o u r c e ' " . d f t n "
ITForral *Foriul;
f a s t c a l l TForml: :TForrfll(TCoHiponent* Owner)

5 S fModifflsd*

4 J
Insert

. 5-
. , ,
.
, ,
. . ,
,
, .
, ,
C++Bui'lder C++BuUder Direct.
,
Web- Inprise (www.inprise.com),
, Borland C++Buuder
. .

24

Borland C++Builder

Borland C++Builder
C++Builder
,
. .
:
;
;
,
;
Buildor 5- Project]
Erojact
'f* Edit Seordi

Ban jjatabese
^
Wb32|

la Centred

Q'

,
, .
.
Standard

Sw*tem| Data Access! Date Controls

, .
, :
Standard Windows;
Additional ,
Windows;
Win32 Windows 9x;
System (,
);
Internet , ;
Data Access ;
Data Controls ;

25

].
ADO
Windows- Microsoft
ActiveX Data Objects (ADO);
InterBase InterBase
Inprise;
Midas ,
;
InternetExpress Internet
;
FastNet , ,
;
Decision Cube ;
GReport ;

Dialogs Windows;

Win 3.1 Windows 3.1;


Samples , ;

ActiveX ActiveX- (ActiveX , Microsoft. Borland C++Builder 4


);

Servers ,
Word, Excel, PowerPoint, Outlook .


?
Windows,
(, , , , . .).
,
Windows , .
.

SHIFT+F12 .

26


.

( ). ,
. , ,
C++ Builder .
,
.
. , , Button
.
( )
, ( )
.
, , ,
.
,
,
.
, .
C++Builder Windows.
, ,
. ,
NMPOP3,
,
Microsoft
Outlook Express. , Web-.
,
().


.
.
.

27


.
.
Word ,
, .
C++Builder , , ,
.

(Object Inspector)
. .


, ,
, , ,
, . .
, ;


( ) .
. ,
, .
F11.


, .
, ,
,
Windows. , , , . .

28


,
. ,
Button 1 !, , OnClick () Button 1.
,
Edit 1 ,
OnChange (). , Editi .


.
.
, ( )
. , ,
.
:
(Properties)
(Events),
, , . ( ),
.
C++Builder. , , ,
, .
, .
, Autosize , false (, ) true ().
AutoSize
true.
Autosize ,
.
. , ,

Fortnl TForml
Plopeitwj ] Evsritsf
AtftveContm!

.d

!
' AutoSe
i
fefee
' _B>Mode
SordecSMe fesSeeatJe
aormi
F
2E9
"CteriWifc 338
2 hidden

Action
Altgn

alNotse

AutaScroS

true

AtioSee

tiue
jfalse

BSordetfcom
BcsdefWicfth

"a

Caption

Cctor"

iQeBtrface

29

1.
BorderWidth,
5.
, ,
- , .
, , ,
Borderlcons. + .
,
Borderlcons , . BorderWidth
.
, . , , Font (),
, . ,
BorderWidth,
,
. , ,
Height ( )
-11. , Font
Style (
).

DtagMode
Enabe
ld
BFort
Cbaiset
Coo
lr
Height
Name
Pilch

See

Style
FormStyle
Height
HefcConterf
HeipFIa
Hint

jdmManual
*
Mrue
lUSBK
ZJ
.DEMULT^CHi
'dutadowTt
'MS Saris Serf
'jpDefauR

'
j]
tsSojmal
,300
a

JBuOop

j ^ H

Hajop .
1

. . - Font ()

30


. - , -
. ,
, ( ),
. -|
- *
. OnAcbvste
OnCanResae
-.
Font
OnCiose
Windows .
O
Copn
m
ie
On
rC
tetrxatn
F
od
pfi
(Events) DnCreata
, , OnDWCtek
DnDaacbvaca
.
QnDestroy
OnDockDrop

OnDockQver '
QnDragOrop
.
OiCragOver


(. . 4 5).

F12. , , :

++.
. .
.



(. . 7). ++,

. , C++Builder
.
-
,
!
, 95% .

31

cHt

)mwProjectBtmSomponentQatobaseToolsjjelp|||<Non8>

Daia CsntWfe 1

. i nc1ude <vc1.h>
hdrscop
;#include " U n i t i . h "
I//
;#pragws package (smart ir.it)
-^pragma resource " s .dfm"
iTForiml *Forml;

.TFormi -Uniti .h (11)

1: :TForral (TCotnponenc11 Owner!


: TFocrn [Owner)

i i o , ,

10:40

. 7.

Windows
,
.
,
. ,
, O+Builder. !
++, .
.

,
( , TForm 1) .
, (11) (Uniti.h)
TFormi.

32


.
. , Properties (),
Code Insight (
), Tooltip symbol insight ( )
.
,
. Word , ++ .

33

2.

,
. , Borland C++Builder
, Windows
. . ,
. Borland C++Builder .
.
.


(
), . , ,
Windows ( )
-, Windows ( ).
.



.
, ,
( ), . . ,

34

Edit ( )
,
, , .


.
, , .
, .
, . - , , ,
.
, ? . -
Borland C++Builder, , .
: .
, , .

Edit ( )
( F12).
( Standard) ,
, . -
Edit.

Edit

. Edit!
,

, .

, .

,,-' Hoiml

,
-

35

2.
.
, , . . .

. . , ,
.
, , .

. ,
, .


. , .
Edifl. ,
Edit2 .
,
. ,
, . , ,

.
1, Edit 1.
2.
Properties ().
3. Text (). , .
, ,
.
, .
4, Text ()
Edit 1 0 (
, , , ).

36

[Object Inspector
JEditl TEdti
Properte
i s j verts|
j~ ParentBSM
i odTtrue
' PaentCoo
l i
Pae
i ntFont iiue
'! Pae
intSQ
fi wHsSue
Passwod
fC3aii m
| PopupMenu
I ReacQ
i rty false
, TabOrde 0
| Taaq
bSo
tp Hue
0
iI ^
Tap
' Vsibte
; WkMi
j*2 hidden

32
hue
121

EEI

i 3

Edit ( )
Text . .
Editl ( Name ) ( Text). , , .
, ?
. Name ()
Editl Dollars. C++Builder
.
Name C++BuiLder.
, .
, , .
, ,
, Rate ( ), -
0. .

Label ( )
?
. , Labal
,
,
.
(Label) .
Label 1 Text , . ? Caption ().
C++Builder.
Label 1 Caption
. . ,
Label 1 AutoSize ( ). , AutoSize,
True False.

37

2.

. 8.
True False
++, C++Builder.
True - , , . False , , .
, (, . 8),
.
, .

Button ( )
,
. Button , Label 1,
, , TotalButton ( Name),
> ( Caption).
, .
, . , ,
,
TotalButton.


, . , .
, , -
. , ,


. ,
, .

, . , . .

Save All ( ). ,
(
++ .).
Uniti.
Save Uniti
Projects

2} Lib

: (
:

jC~+Builcer unit (".]

. 9.
Calc, .
, (
.BPR), ,
. CalcProject
.


++,
. :
.

39

2.
.
,
, , , !
++,
, , ,
, , .
TotalButton. , ,
,
, ,
TotalButton.
++. , .
{...},
. ,
.
, .
, ,
Dollars Rate, Label 1.
Dollars - . ?!!

.
: , , ,
, , ( , ) .


, , . , .

40

?
, ,
( ). , ,
. , . ,
.
, ,
, : Undefined symbol < >.
, - .
, , ,
.

{...} . , , , (
).
++ , _.
.
++.

Cat
ListBox
Windows99
ge33iv5HsY8Ys
ilOO
++:
( );
football

game ( );

1 ( ).

41

2.

.
++ :
----;
8 ++
;.
. DollarsNum.
++ , int ( integer ). :
{int

DollarsNum;

++
++
. . ,
, ,
. , , int.
++ . ,
int Int , int
, Int .
Borland C++Builder

,
. , i n t DollarsNum; a
imt Dol 1 arsNum;, imt ( C++Builder
, ), ,
.

++ .

, C++Builder
. , ,
(Edit) TEdit. ,
C++Builder -

42

, ,
TFormi. , ,
.

DollarsNum, Dollars. , DollarsNum
, number_of_dollars
dollars,
.

, ,
, , . , C++Builder
( , ). . ,
Microsoft Visual C++ (Class,
).


DollarsNum . RateValue, .
:
int
int

DollarsNum;
RateValue;

:
int

DollarsNum,

RateValue;

DollarsNum, RateValue int.


. :
int

RateValue;

int

DollarsNum;

RateValue,

DollarsNum;

:
int

43

2.

, ,
, .
, - ,
,
, .
.
, , ,
. ,
.
/*
, */ .

.
:
/*

.
*/
/* */
, , .
//.
// .
DollarsNum :
i n t DollarsNum;

//

,
, ,
.
. . :
i n t DollarsNum;

//

DollarsNum

. ,
. :

44

?
/* DollarsNum
RateValue */
:
/* */
Result, :
int Result;

++, , ,
. TEdit.
, TEdit ,
.

:
int

DollarsNum;

int

Result,

DollarsNum,

RateValue;

: Multiple declaration for < > ( - ),


, DollarsNum .

?
, . ,
DollarsNum RateValue.
Windows C++Builder
. DollarsNum RateValue,
, .
, , , int,
.
, TEdit : ,
; , , . ++ .

45

2.
++.
Windows
++. , , ,
.
. , TButton. Windows C++Builder
.
,
.
, . , , TButton, :
TButton my_button;
( C++Builder ). (
, ) .
,
. ( ) TEdit Dollars,
, , ,
.
,
, .
Dollars? Dollars ( ) TEdit ( Edit ).
,
, ,
TEdit.
C++Builder
++.
, C++Builder (Edit Label Button ), .
-

46

?
.
, :
int Edit Label, Button;

int TEdit;

int TLabeL;
.
, TEdit
Text. , ,
DollarsNum 12 3, Text
, .
,
. ,
, . , .
? . ,
, ( ,
, ) . Dollars, Rate,
TotalButtom, , Name ().
. , , . ,
, ,
, .
, Name
. ,
Name Dollars
( , !),
. Dollars.
>, , Name. :
Dollars->Name
Rate,

Rate->Text

47

2.
.
, Caption Label 1

Labell->Caption
( ),

, .
Name TEdit ( Edit), ,
.
, , 100, 100,
C++Builder.

C++Builder
( ) . , .
, .
,
, , .
( ) , ,
.
StrTolntO {StrToInt String To Integer).
. , , . StrTolnt(),
, int ( ).


?
. ? , , . ( ,
). . ,
. StrTolntO int.
? ++ ,
, ( ), -

48


. , .
. , StrToInt
. ,
.
StrToInt StrToInt
Dollars. ,
, Dollars>Text, ,
StrToInt :
StrToInt(

Dollars->Text


, StrTolntf) Dollars
. ?
, , .
, ,
++, . (, , ).

,
. ,
, .
:
= ;
,
I

10;

I, , :
int

I;

DollarsNum , StrTolnt(). ,
, :
DollarsNum = S t r T o l n t f

Dollars->Text

);

49

2.
RateValue :
RateValue = S t r T o I n t ( Rate->Text

);

. . ,
++ , :

<<+ ();

- ();

* ();

V ();

().
, , . DollarsNum
RateValue Result :
R e s u l t = DollarsNum * RateValue;
++:
= ( + z) / 2 + 10;
_123 = * + Y2000( d l , 1 2 ) - 32000;
Y2000( d 1,12 ) ,
.

++
++ . . , Rate Value, S t r To
I n t 1 0 0 0 . - >
Dollars->Text,
Dollars-

>Text

->
{) ++, , = () - (-

50

C++

). ,
. ++ ,
, , =.
.
:
Dollars -> Text

Dollars->

Text

Dollars

->Text


Dollars
->
Text

. ( ).
. ,
Result = DollarsNum * RateValue;

:
Result=DollarsNum*RateValue;
, , ( ):
int

Result;DollarsNum=StrToInt(Dollars->Text};

, . :
intResult;
, ,
int .
.
.
.

51

2.


, Result. (, - ),
Label!. ,
Text, Caption, .
,
, Label 1.
Caption? .
, , . .
Result , Caption . ?
lntToStr(), , .
:
Labell->Caption = IntToStrf

Result

);

( ,
) :
{
int

DollarsNum,

int

Result;

DollarsNum

RateValue;

StrToInt(

RateValue

Result

DollarsNum

StrToInt(

Labell->Caption

Dollars->Text
Rate->Text

);

);

RateValue;

IntToStrf

Result

);

++ ,
. .



++ ,
.
.

52



Save All ( ) Project
MakeCalcProject ( CalcProject)
CTRL+F9. C++Builder
Background Compiling (
), . 10,
.

Add tc Project Shift+F* 1


emcvg from Project..
^ Import Type bibrejy..
(* And lc Repository..
J5| View SDurca
Lenguagss

T5 onpite Unit
Alt*F3
C++Builder 5 . Information for Ca:cProject
' Maks Ail Projess
, - *5 Build All Pro-.BBs
,
options.
3hflCtrl*F11
. Windows,
. , , , ,
. ,
Tools Environment ( )
Preferences () Background Compilation ( ).
Project () , Compiling () ++; Current Line (
) ,
, ; Total
Lines: ( ) ,
++.

. 10.

53

2.
Errors: (),
Warnings: (), Hints: ().
C++Builder ,
,
. ,
DollarsNum RateValue, RateValue , :
int DollarsNum,

int

RateValue;

Result;

DollarsNum = StrToInt{ Dollars->Text );

Result = DollarsNum * RateValue;

RateValue
, .
, .
. , , - . ,
R e s u l t = 2;
R e s u l t = DollarsNum * R a t e V a l u e ;

R e s u l t = 2;
, Result 2, DollarsNum *
RateValue.
. ,
.
() , ,
.
.
C++Builder , ,

54


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

, ,
,
.


.
.OBJ. . ,
Calc.cpp
Calc.obj. .
Calc.exe.
.
,
StrTolnt(). , LIB ( Library ).
, ,
.
, Windows. , , ,
,
++.
, Compiling () Linking (). , , Borland C++Builder
.
. , , , ,
.

55

2.
,
.
, - (Linker). .
,
-:
. . ,
C++Builder Done: Make,
. , , .
Done: There are errors , ,
- .
.
, .


, . Compiling (),
, Run () F9. Borland C++Builder . ,
. 11.
Ifj-ormi

"5

. 11.

100 (100 ), 30
( 30 ), >. , , 3000 . . 12.

56

. 12.

. . ,
Windows Borland C++Builder, , - .



, , :
, . .
. Label ( ),

. ,
Label 1 Delete () Label 1 .
Edit ( ). Roubles.
,
. C++Builder
, , ,
. , ,
, Caption Label 1, ,
, Text Roubles:
Roubles->Text = I n t T o S t r ( R e s u l t

);

57

2.
. ,
. ,
.

Dollars Rate , .
ConvertButton, <.
.
.
Dollars
Rate, , Roubles
Rate.
RoublesNum.
, , . ,
TotalButton, Windows ( CTRL+C),
( CTRL + V)
:
{
int

RoublesNum,

int

Result;

RoublesNum -

RateValue;

StrToInt(

Roubles->Text

R a t e V a l u e = StrToInt(

Rate->Text

Result

RateValue;

= RoublesNum /

Dollars->Text

IntToStr(

Result

);

);

);

Dollars.
,
, . ,
- , . ,

58


Result = DoliarsNum * RateVaLue;
DolLarsNum HaRoubLesNum * /, ,
,
, , , , ,
.


Result?
, TotalButton,
,
.
, ++ ,
, .
, .
,
, ,
. , ,
{...} ,
. . (, ) .
Result
, .


. , Form 1,
.
Calccpp.
.

( , C++Buitder ). , ,
,
.
59

2.
, ?
, . , ,
,
. , , .
:
//
{//
int T;
= 1;
{//
float ;
- 3.14;
}//
// 1
{//
double ;
- 3.3333;
{//
int T;
= 50;
}//
// 3.33
}//
// 1
} //
/*
*/

60


F9 ( ). C++Builder
, ,
, .
, .
3 0 ( ), 3 000 (
), <.
100. ! .

. 13.

, ,
1000, ,
33 (). ? , ! ,
1000 33 , .
, 33,33333...


, int, , ,
-2 147 483 648 2 147 483 647, . ++ ,

( ). 33,3333 33.
-2147 483 648
2 147 483 647?
61

2.
, Pentium 32-.
? , , 0 2 3 2 -1,
0 4 294 967 295 ( ++ , unsigned
long). , -2 147 483 648
2 147 483 647.
++ . , Borland C++BuiLder.
, , .
. C++Builder
, ,
int64,
-9 223 372 036 854 775 808 9 223 372 036 854 775 807.
.
. , int64,
i64, :
3000000000i64
!
:
3000000
3000000000164
:
3 000 000
3,000,000
, - ?
++ , C++Builder (
), (!):
int

i;

i = 3000000000;
?

62

3000000000
int -1 294 967 296. ,
, , !
, ,
, 3000000000, 4 294 967 296 2.

++ .
, , , , , . ,
++ ,
,
.

,
, ,
?
,
, , .
++ .
.
;
. 67+24 0 . 66+25

, (
);

, ,
; + .

:
3000000000 = 9

10 - 11
0.03000000003 = -12

63

2.

, , ++, , .

++
(- , , ). ,
-:
123.45
1.23452
1234.5-1
, () ,
.

float
++ float ( ).
1.18-38 3 .438.
?
, 38 .
, .
, 120 .

double
double ( ),
2,23~308 1.798.

long double
, 120 . , -
. ? , C++Builder
long double ( ), 3 . 4-4932
1 . 2 4 9 3 2 . .

64


.
, 7-10 , 1,23456789
1,234567412 . .
float double , ,
,
float.
, ,
. , ,
, , .
++ , ,
.
, .
, ++ , 80- ,
.
, ,
++,
,
, ,
.


. int float.
,
.
.
Replace All ( ). CTRL+R,
,
, . 14.
Text to find: ( ) i n t ,
lntToStr(), Replace
with: ( ) : f l o a t ( ), Origin
( ) Entire scope ( )
Replace All ( ).
, :

65

2
(Replace Text

" sensitive
" i*$mie words only

<"" gackwatd

" on feolace
-Scoper

ram cursor

Cancel

. 14.

float
float

RoublesNum,

RateValue;

Result;

- , , float,
CTRL+Z ( Undo , Windows)
.
, lntToStr() StrTolnt(), .
, , .
? , 1,0 1.
,

. , 1,0
, 3,14 3
, .
( ), , ,
, , .

66


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

int m;
m = (int)3.14;
, m
3.

, .
. :
float x;
= 5; //
, ++
, . , , , float double
( ).
:

int N ;
N = (int)(5.5 + 4.4);
( 5 . 5 + 4 . 4 ) , 9,9, int ( 9, ).


, :

int ;
N = (int)5.5 + 4.4;
,
5.5, .

67

2.
++ ,
(
).

2*2 + 3*3
,
. ++ , , .
++ ,
. ( i n t ) 5 . 5 + 4 . 4
5.5 + 4 .4,
9.9 int.
,
. 2*2 + 3*3 , (int)(5.5 + 4.4).



. ,
, .
, lntToStr<) StrTolnt()
, ,
. int , . FloatToStr() StrToFloat{)
( ) lntToStr() FloatToStr{), a StrTolntO StrToFloatQ.
( )
.
10 0 (100 ), , 25,5 .

68


, , ++
, Borland C++Builder,
Windows, .
Windows
, Windows
WIN.INI, [intl] sDecimal. Windows . ,
Windows
, :

sDecimal-,
, .

, Windows, ++,
.

2 5 , 5 ( 2 5 . 5 ) .
> 2550 ().
29,9 ? ?
<.
85,2842788696289. ,
( 85,284280936454),
.
1000 30. 33,3333320617676 ( ).


85,2842788696289 . .
C++Builder ?
, ! FloatToStrFQ.
.
:

69

2.
;
( ), ;
,
ffFixed;
, ( ) , (
, 10 );
, ,
.
. ++
. ,
Windows C++BuHder,
,
Windows. FloatToStrF()
, .
, .
, , . ,
C++Builder .
:
Roubles->Text

FloatToStrF(Result,ffFixed,10,2);

Dollars->Text

FloatToStrF(Result,ffFixed,10,2);

, , , 1000 30
33,33.


, ,
. ,
. , 9,9 ,
9 .


, C++Builder , . f!oor(),
, (int).
, .
, :
floor(+0.5)
.
,
: Result .
:
// :
R e s u l t - f l o o r ( DollarsNum * R a t e V a l u e + 0 . 5 );
// :
R e s u l t = f l o o r ( RoublesNum / RateValue + 0.5 );
.
: Call to undefined function floor (
floor).
? , ,
?


, , f loor() .
.
(LIB-),
( , / . .).
C++Builder
. , , ,
?
, ,
, , floor().
. Help
Contents ( ). Index ()
: f l o o r (. . 15).

71

2.

floor, floor!

1
(floor

Headei File
math.h
Category
Math Routines
Syntax

#include <n
double floe
long double

Description
Rounds down,
ffoorfinds the !
floorf\$, the Ion


""

Fbor
Canvas

[boil
flow control routines
[lush sire dm
flush streams
FlushBuffei
TFJer
TReader
T Writer
FlushBulfeis
TBDEDataSe!
FlushSchemaCache
___
i
T Database
Nvover help, database navigator
FMAXEXP
FMdXPOWTWD

ii result

Return Value
floor returns thi

. 15.
, , floor ,
. (. . 16).
^Borland O + Builder Help
;
] ".* | j s

floor, floor!

Header File
math h
Category
Math Routines
Syntax
Slnclude <roach.h>
double Hoot (double y.) ;
long double f l o o d (long double x) ;
Description
Rounds down
floorfinds Ihe largest integer not greater than x
toarfis the long double version, Ft takes a lony double argument and returns a long double result
Return Value
the integer found as a double. Tloorf returns the integer found as a long double.

Puc. 16.
72

: Header File .
. ,
(math.H).
. . ( .).
.
, ,
,
.
, .

. , ,
. . , floor() :
double

f l o o r ( d o u b l e ) ;

. .
, , floor()
:
double

floor(double);

math.h ,
f 1(),
. ,
, , , .
?
:
#include

- >

#include

"-"

,
, ,
(
C++BuiWer).

73

2.
,

.

:
#include

<math.h>

math.h.

.

Calc.cpp.
vcl.h ( Visual Component
Library) Calc.h, .
math.h vcl.h:
#include

<vcl.h>

#include

<math.h>

( F9),
1000 30 33,00.
,
FloatToStrF{) , , , .


, . , ,
:
.
1. . , . ,
8 ( ).
, Tools Environment Options ( > ) C++Builder (. . 17).
Preferences (), Grid size X: (
) Grid size Y: ( ) , , 5. , .

74


Lnvironmorvt Options

Cancel

Hep
l

:. 17.
2.
.
, , .
,
.
. , .
,
Align to grid ( ).

.
3. .
,
Align ().
.

Creation Order...' .
Rip Children ' . >
Addta ftepci&rtory.,.
yiewasTexi
TextPFM

. (Horizontal), (Vertical).
, -

75

2.
. ,
Tops ( ),

No change ( ). , .
4.
, .
,

Size () (
Width) ( Height).

[Alignment

-Wli

ghmft to smallest
<* to largest

<~ Grow to Jerstet


. <~ Heg
i h!.

Caned

Borland C++ Builder 5


. Shrink to smallest ( ) . Grow to largest ( )
.
Width () Height () . .
. , No
change ( ).
/

. 18.

76


, 50 . .
5.
,
.
Ok
<*&*

.
, , , . Windows
. ( ,
). , - ,
TAB . , (

).

,
Tab Order ( ).
Edit Tab Order ( ) . 19.
.
.
TAB ,
.
Edit Tab Order
jQntrate. listed HI tab fade*
Dollars TEdil
Rale' i t
TotalButton- T Button
Roubles'

Cancti

. 19.

77

2.
, .
6.
,
. , . 3, Align ()
Space
equally ( ) Horizontal ( ).

.
,
Center in window ( ).

(. . 20).

! 31

InseH

PMC. 20.

7. , , ,

. ,
, .
(, Label).

78


, (. . 20).
8.
Form 1, Borland + Builder
. ,
, Caption .
. .
.



. , , ,
Calc. 14 , C++Builder. , , ,
.
.

.
.
. , ,
, .
Windows . . :
:\WINDOWS\SYSTEM\sheI132.dll
:\WINDOWS\SYSTEM\pifmgr.dll
:\WINDOWS\SYSTEM\moricons.dll
:\WINDOWS\SYSTEM\progman.exe
.
, , . ,
, C++Builder, 24 !

79

3.

,
. C++Builder File Exit
( ) , CalcProject, C++Builder
. ,
. File Open Project (
) ( CTRL+F11), CalcProject File Reopen (
), , (. . 21).

Edti earchyeiwgrqedBunComponent0aa
fbasec
Irasl

f.-'C++Buildor

. Q blew

f; Siarafad j Adjuonal I Wm32 ! Swieral **)

A fSST

. 21,

80


. 0,
,
.


( F9) , , 1000. (
, ). , C++Builder
(. . 22).
Project CalcP"3JBc?.e*B raisae exception class
EZeroZiNiie sdi rreseaga 'Floating by
zerc'. Prccass stopped Use Step crRt-nto '.^.
OK

. 22.

}' ? ,
RoubiesNum (
1000) RateValue ( 0).
, !
, , . ,
.
Calc cpp
//

__, _*-._____,

void
f a s t c a l l TFornil: :ConvertButtonClick(TCtoject "Sender)
'(
float RoublesNum, RateValue;
float Result;
RoubleaNum - StrToFloat( Roubles->Text );
RateValue - StcToFloat( Rate->Text );
DollaE3->Text - TloatToStrF( Result, J l x e d , 10, 2

iLJ
43 1

"itnsert

. 23. ,

81

3.
, C++Builder ,
, ,
(. . 23).
.
?
,
. , ,
, , .
. ?
, , ,
Windows, (
).

, . F9,
, Floating point division by zero (
), . 24.
iC;jlc|)rojec)
Floating point division by zero

, 24, ,

?
. C++Builder
, . .

-. , , ,
, . ,
Calcexe C++Builder, Windows,
,

82


. , , .

, (, ).
"" is not a valid floating point value ("" ).
, C++Builder.


C++Builder ,
. ,
, .
. , , ,
.
F5. , .
0,'ilc cpp

>

ivoid

fastcaJJL TFctrnl : ConvertButtonClicfc [TOb j e c t 'Sender)

<
float RoublesHuiti, ReteValue;
f i o a t Result;
RoufclesNum = StrToFloatl Roublea->Text );
RateValue = StrToFloatf Rate->Text );

Dollar3->Texc - FloatToStcFf Result, F i n e d ,

10, 2

Puc. 25.

{Breakpoint).
,
, ,
.

83

3.
|
^

,
, ,
.
.
F5
.

, 1000 () . , , ++,
. .

RateValue, ,
(. . 26).
, ? , RateValue
,
.
View Erajsct Qm omponent

. 26.

84


. , ,
CTRL+F2 ( Run Program
Reset), C++Builder ,
. .
, ?

, , C++Builder , , , .

Source hat been modified, ftefctutid?

No (), , , ,
++ . ,
, C++Builder ,
. ,
,
.
.
CTRL+F2.

85

4.

, , . ,
, .
, , . , Result, DollarNum
StrToFloat (
DollarsNum). RateVafue,
. :
Result = floor( StrToFloat( Dollars->Text ) * StrToFloat
( Rate->Text ) + 0.5 );
StrToFloat
! :
f l o a t DollarsNum;
f l o a t RateValue;
float Result;
Result = floor( StrToFloat( Dollars->Text ) * StrToFloat
( Rate->Text ) + 0.5 );
Roubles->Text = FloatToStrF(Result, ffFixed, 10, 2 ) ;


( CTRL+F9). ,
Done: There
are warnings ( ). ?

86


C++Builder
, Project Project Options
( ), Compiler () Warnings () AIL ().
Compiling
ftqec*- 0 ^twoki tie<^boatcsNdess-ub54>tDC:teftoB
i ct tp
Done. Then: ore wommg.
Cuiranllme:
Huts

0 ^Totalities
S Waning^

4 *

173
Q

. 27. Warning
. , , (. . 28).

void
float
float
float

f a s t c a l i TFptml: :TotalButtonCiicK (TObject


RoublesNum;
RatEValue;
Result;

Result = floor ( StcToFloatf DollaL3->Text ) * StrToFloat[ Rate->Tex


Rouble3->Te>:t = FloatToStrF( Result, ffFixed, 10, 2 );

[C++WerningJ Celc cpp(25). WB080'RateValue' is declaied bul never used


[C*+ Warning I C ale cpp(25t' W80S0 'RoublesNum' is declared but nevei used
[C Warning] Caic.cpp[25J WS057 Paiameter 'Sender' never ured
[C+4 Waning] Calc cpp[4G] W6057 Parameter 'Sender' is never used

25 I

Insert

Puc. 28.
,
. .
"RateVafue" is declared but never used
"RateValue" , . , ,
87

4.
RateValue ( DollarsNum)
. ? , RateValue .
, .
Parameter
"Sender" is never used ( Sender ). ,
Sender TotaLButtonCLick ConvertButtonClick
. , , ,
C++Builder .

Compiler Warnings Selected ()
Warnings
. ,
, , .
, :
float Result;
Result = floor( StrToFloat( Dollars->Text )
StrToFloat( Rate->Text > + 0.5 );
Roubles->Text = FloatToStrF(Result,

ffFixed, 10, 2) ;

Sender.
? Result
.
Result f 1():
Roubles->Text = F l o a t T o S t r F ( f l o o r ( S t r T o F l o a t
(Dollars->Text) * StrToFloat(Rate->Text) + 0 . 5 ) ,
f f F i x e d , 10, 2 ) ;
Result ,
.
( ! )
.

88

(!) ++,
,
.

?
, ( , ),
- ++? , ,
,
. ? (
) .
, . , , , .
,
(RoublesNum, RateValue), .
, (
),
. ,
, .
! ,
, .
++.
5-10 , .
,
.
, ! , , , ,
. ,
++. , .

89

5.

.
, , ,
, ,
float. , .
, .

++ . , , ,
, .


, . Roubles Rate
StrToFloat().
, , ,
EConvertError.
,
( Exception ). C++Builder 5 .

90


,
- , (Help).
StrToFloatQ ,
, EConvertError.
, . , ,
.
. ,
,
, . , RoatToStrF()
- ,
"NAN".

. , try,
:
try
{
Roubles->Text

FloatToStrF(

floor(StrToFloat(Dollars->Text)

StrToFloat(Rate->Text) + 0 . 5 ) , ffFixed, 10, 2 ) ;


}

c a t c h {), :
c a t c h (const - &)
:
c a t c h (const E C o n v e r t E r r o r &)
, ( ) EConvertError.
:

91

5.
try

Roubles->Text = FloatToStrF(
floor( StrToFloat( Dollars->Text
StrToFloat( Rate->Text ) + 0.5 )
ffFixed, 10, 2 );
}
catch (const EConvertError &)
/*
*/
?
. ,
,
,
, ,
.
Windows ,
ShowMessage() .
, , ++ . :
" ++"
, :
"" ( , )
, . ,
\ ( ):
" \" ,
\". "
, C++ ,

ShowMessageQ:

92


catch

( c o n s t E C o n v e r t E r r o r &)

ShowMessage("
");


, , C++Builder ( , ). ,
( )
, ,
. 29.

CalcpFOject
' ' ,
,._-

. 29. ,

? StrToFloat()
StrToFloat{ Roubles->Text) , EConvertError. StrToFloatO ,
( try), ,
EConvertError (
c a t c h ) . , try .

93

5.

try , , catch, . . ,
catch-.



? , . ++ catch-,
.
catch- (
), EConvertError
, , EOverflow ( ), . :
try
Roubles->Text = FloatToStrF(
floor(

StrToFloat( Dollars->Text

StrToFloatf Rate->Text ) + 0.5 ),


ffFixed, 10, 2 ) ;

catch (const EConvertError &)


ShowMessage("
">;

catch (const EOverflow &


ShowMessage("
");

94


1 el 0 0 0 (
), 1,
, , {).
, catch- ,
, catch-, try.

95

6.


StrToFloat().
. ,
atoi(), ++ , . ,
, , .
( string.h),
,
, ,

.
C++Builder AnsiString.
,
, ,
, .
--Builder 3 ,
, , ,
.

++ . :
(Caption), (Name), (Text)?

96

TButton TEdft,
.
, , ,
- : , ,
, .
, , . ,
.
, , . , , .
++ .
.(), " . "
, open ( ) . ( ,
) .
. ,
A. Get Width () , .
, ++, .

, , . , .() ,
, true,
, false, .

ErrorCode = .();
:
.();
, ( ), , .


, , ,
, , , ? , , Roubles->Text. ?
4 3 1064

97

6.
,
, ,
,
.. Roubles
Calc.h,
,
Open Source/
Header File ( / )
CTRL+F6.
Calc.h
:
TEdit

Qcse Page
Open Ftie at CLiratr
NJsw Sdtf Wn
i dow
Add Tc-Oo item...

Sir.VCtri+T

Paste
Iaggle EookmeK
is

OtrirV

Oeoug
Message View
view EvplDrer

*
S-^CtrKE

*Roubles;

, () Roubles TEdit ( Edit).


Roubles TEdit, *. .
C++Builder TEdit (Properties) Text. :
p r o p e r t y A n s i S t r i n g Text - {read=GetText,
write-SetText};
property ,
Text
( ). AnsiString. (
, AnsiString
), Methods (),
AnsiString.
,
C++Builder .
, ToDouble ( ... ). , ToDouble
,

98


AnsiString () . StrToFloat() ToDoubleQ:
RoublesNum = R o u b l e s - > T e x t . T o D o u b l e f ) ;
,
EConvertError (
ToDoubleO), try- catch-.
, , CTRL+F4.


, , , ?
, . AnsiString c_str(),
AnsiString
, ,
.
atof(). , C++Builder ,
s t r i n g (). string to
floating-point conversions ( )
atof{). ( ) AnsiString (
c_str()) double.
,
( ):
RoublesNum = a t o f ( R o u b l e s - > T e x t . c _ s t r ( )

) ;

.
?
atof () . errno. ,

99

6.
,

errno.h, .
, atof() ,
- ,
ERANGE.
atof() (, EZERO), ERANGE, ,
ERANGE, .

++. , , C++BuiLder.

, atof () , ERANGE. ,
, ( Roubles) , .

++,
( ?), , .
++
.

100

7.

. , ,
C++Builder ,
. , , -2,
, , . ,
, ,
,
. , ,
.
, -
. , Microsoft Internet
Explorer 4.x :
Web- 255 ( ++
unsigned char 0 255;
, , ),
Windows , ( )
.

(,
, ). ,

101

7.

.
. ,
. , ,

.

. .

, .
( ), .
,
.



++ . ++ ( ), .
:
if

( )

- ;

if . , , ,
, .
( , true), ( ,
false). true 1, . false 0, .
++ boot, , true false (
).

02



, ?

:
i f ( )
{

-1 ;
-2 ;
// . .
}
, .

, - , . , ,
.


(
) .

==

!=

>

<

>=

<=

, ( ,
).

103

7.
:
> 5
R a t e V a l u e <= 2 9 . 5
2 != 3
(*3)

<

(+50)

*3
+50. , :
*3 < +50
10, 0, *3 < +50 (10*3 < 0+50) false 0.
. , , .
.
>, >=, <, <= = !=.
,
, .
( ) . , ,
100.
, && ||. && true, , true (
false). ||
true, , true.
:
R a t e V a l u e > 0 && RateValue < = 100
&& j | ,
RateValue .
RateValue 101, :
(RateValue > 0) true;
(RateValue <= 100) false.
true && false f a l s e .

104


(
, ++)?
*3 < +50 > z/3
, ,
+50, *3, +50, z/.
. , ( )
, . C++ ,
.
/
^

++, ,
. ( ) .

, 10, 0, z 120,
:
10*3 < 0+50 > 120/3

30 < 50 > 40
(30 < 50)
, true.
t r u e > 40
++ : ,
t r u e 1,
t r u e > 40

1 > 40
f a l s e ( 0).
true false 1 0! ,
.

105

7.
, *3 < +50 > z/
, Sugest parentheses
to clarify precedence ( ,
).
, , :
(*3

<

+50)

ScEc

(+50

>

z/3)


RateValue
DollarsNum RoublesNum .
:
RateValue > 0 && RateValue <= 100 && RoublesNum >= 0
&& RoublesNum < 100000
RateValue 30, RoublesNum -100, :
30 > 0 && 30 <= 100 && -100 >= 0 && -100 < 100000

t r u e && t r u e && f a l s e && t r u e


, ,
( t r u e && t r u e ) && f a l s e && t r u e
( t r u e && f a l s e ) && t r u e
f a l s e && t r u e
f a l s e .
&& ||
,
, .

false, ,
false && false false false && true false!
C++Builder . , .

.

106


:
Ra-eValue > 0 && R a t e V a l u e <= 100 &&
ChangeRate(RateValue)
ChangeRate() , : RateValue , RateValue
110,
faLse && ChangeRate(RateValue)
, false && -
false. ChangeRate{).
, RateValueQ . . .
.
++, .

. ,

Result :
i f ( RateValue > 0 &&
RateValue <= 100 &&
RoublesNum >- 0 &&
RoublesNum < 100000 )
( ), Result Dollars
:
R e s u l t - f l o o r ( RoublesNum / RateValue + 0 . 5 ) ;
Dollars->Text = FloatToStrF(Result,

ffFixed,

10,

2);

107

7.
:
i f f RateValue > 0 &&
RateValue <= 100 &&
RoublesNum >= 0 &&
RoublesNum < 100000 )
{
Result =

floor{ RoublesNum / RateValue + 0 . 5 ) ;

Dollars->Text = FloatToStrF(Result,

ffFixed,

10,

2);

,
(, 2 00) .
.

, - , . ,
?
, . .


.
,
, ,
== . :
f l o a t , ,

z,-

z = 0;
= 3.1415927;
- 3.1415927;
i f ( == ) 2 = 10;
, 10,
3.1415926,
3.1415929.

108


, ,
.
, ,
(
). , ( ,
; -2 +2, -0,001
+0,001, +3,14 +3,14). 4-5 - 1 ,
- 1 .
++
abs().
,
, :
i f ' a b s ( x-y ) < 0 . 0 0 0 1 ) z - 10;
z , 10,
0,0001. . C++, .

109

8. .

?
- . ,
. ++.
,
, . .-. ,
.
1. ( ,
).
2. 0 .
3. .
4. ( ).
5. 2 , , . ,
. ,
. , .
6. 1,
, .
7. , 100 .

, ++ . ,
, .

110


, ,
.
- .
CalcProject (
C++Builder) File Close All ( ).
, - , C++Builder ,
(. . 30).
(Yes),

Save cheages to- protea CalcProject?1

. 30.

.
, File New Application (
). ,
, C++Builder.
, Save All ( ). ,
.
++ DiceUnit.cpp, DiceProject.bpr.


!
.
,
.
, ,
, .

111

8. .
, ,
! , ,
, , , , .


( , ).
.
1. ( )
( ).
2. , .
3. , : ,
, .
4. , .

, , . 31.
X/ 1
LasfDice
LastHumanScoia LestComputer Score
ComputeiScore : .
GameFn
i tsh

. 31.


Name, :

HumanScore ( );

ComputerScore ( );
Last HumanScore ( );

LastComputerScore ( );
LastDice ( ).

ListBox ()
TotalScores ( ).


. MainMenu .
?
.
C++Builder .
, , , ,
. .
,
.
.
.
1. ENTER
,
Caption.
2.

ENTER
C++Builder .
(.
. 32).

^ropwtw | Everts j
:
'. AutoHotkeyi

meParent

I Btroap
Bteax
f Captitm
^Checked

jfUB

rraNane

0
! .Hint
'All shown

3.

ENTER
. ENTER
(. . 33).

4.


, ENTER , 2 3, (. . 34).

113

8. .
( oiml->MamMenul

'.

. 32.
Foim1->MamMenu1
]

. 33.

. 34.
, Caption.

114


, ,
INSERT. , - ,
, INSERT
Caption ( ).
,
?
&. ,
, :
&
,
, ,
.
, .
, .


, , , Windows
,
.
.
.
1. Win32.
2. ToolBar (
).
3.
(. . 35).
4. , . Additional, SpeedButton
( ToolBar).
.
, , C++Builder.

115

8. .
[V;"'* Builder 5 - DicePr<
Fila Fdit Search V-ew &O|8ct Run CompQnant Qetabosti j.ogls Help

Cab
ECctWiant

7: oral: :.1

v" **-

Tnr'Bail ['""odl

5.

.
1. Glyph , . 35. ,
.
2. Load (), ,
C++Builder, \Borland Shared, \lmages,
\Buttons. .
.
, . -
( ).

3. , .
phonerng.bmp. ,
, .

116

. 36.

4. .
dooropen.bmp,
arrow3r.bmp comppc1.bmp.

,
. Hint.

.



: , ( ).
.
, , , .
, .
.
?
, , , .
, , .

8. .
?
, ,
,
. .
, ,
. .
.
, .

.


:
;
;
, ;
, :
.


:
.


:
;
1,
;
:
;

118


, :
;
.


:
;
, :
;
.



( ) ,
++.
,
File New ( ), New () Unit () . . 37.
" Now Itorrr.;
j
Nw'

Projects
AavtAi j

}
Data Modules
)
MJSief j DcePtojec*

f
j

Farm

me
PackagePo
rejctG
O
ILE
H
aderF
e
li
K
atn
RepotrResou
crW
ezad
irDL SecvrieSecvrieAppSc
ft
e
b
TextThe
radOb
ec
jt W
Ap
p
cia
oitrSevre
LtixarJ
j

Puc. 37.

,
CTRL+S
DiceProject Game.cpp.

119

8. .
.
(, , ),
,
, .. Game.cpp Game.h. Game.cpp
#include

"Game.h"

Game.h,
CTRL+F6.

#endif
.
( ) , ++, :
class

// ,
};

,
( ; ).
(, , , )
. , , ,
. .
,
.
, .


++ public private, . ,

120


, , , .

( , , )
.
( ) public private , (public)
, (private).


.
, GetDiceValuef).
int ( 1 6),
.
LastValue,
.
class

TDice

public:
int LastValue;
int GetDiceValue();
};
Game.cpp , . GetDiceValue() Game.cpp.
, ,
:
int

TDice::GetDiceValue()

, , Game.h
,
, ,
.
int

TDice::GetDiceValue()

121

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


C++Builder randomQ, ,
0 -1.
random(6) +1.
random() Game.cpp stdlib.h:
#include

<stdlib.h>

GetDiceValue() ,
?
return. :
return

_;


, , , return.
return,
. ,
return 10;
= 5;
= 5 UnreachabLe
code ( ).

, , :
// 1 6
i n t TDice::GetDiceValue()
{

LastValue = random(6)+1;
return LastValue;

122


, , , .
,
. ,
. ++, , .
C++Builder , ++. ,
.
( )?
,
, 50 . ,
.


Game.h,
TDice:
class

TPlayer

public:
int Scores, CurrentScores, WinNum;
Scores, CurrentScores WinNum
, ,
.
(public)
?
, - .
( )
fnit{),
. , , . , ,

123

8. .
. ?
++ void,
. , ,
, void:
void

Init();

lnit(), , , TPlayer:
class

TPlayer

public:
int Scores, CurrentScores, WinNum;
void I n i t ( ) ;
};

lnit() Game.cpp :
//
void T P l a y e r : : I n i t ( )

TPlayer .
, ++
:
-1 = -2 = ... = ;
.
TPlayer
:
S c o r e s = C u r r e n t S c o r e s = 0;
WinNum?
, ,
, , , 0 .
?
124



, .
, ,
( , ), . ,
, (),
.
,
- .
:
-();
:
class

TPlayer

{
public:
int Scores, CurrentScores, WinNum,TPlayerf);
void Init f) /

(public) ,
,
, .

Game.cpp , :
TPlayer::TPlayer()
{
WinNum = 0;


, TReferee. TPlayer - -,
TDice , NewGame ( ), ComputerMove
( ) GameFinish ( ):
125

8. .
class TReferee
{

public:
TPlayer Human, Computer;
TDice Dice;
void ComputerMove();
bool GameFinish();
void NewGame () ;
};
GameFinishO true,
100 , false .
, ,
. .
,
, .

NewGame() Game.cpp ,
.
, ,
. , 1,2
3, , ,
,
NewGameQ.
//

void TReferee::NewGame()
{
Human.Init();
Computer.Init();
if( Dice.GetDiceValueO <= 3 }
ComputerMove();

126


ComputerMove() ,
.
, , .
,
. Scores CurrentScores
TPlayer ( Computer). ,

- > . , , . ( ,
) . , Scores, Computer
TPlayer,
Computer.Scores
- , ., >?
.
.
, ,
. , ,
.
,
, ,
. (16-
) (32- ) .
, ,
, .
, , , -
, .
.

127

8. .
- ,
,
( )
, .
,
.
++.
, ,
.
++ , , , . C++Builder 5
CodeGuard ( ). .
, Java,
++, .
, , , > ,
( , ) .
. , ( ).
, ,
,
. ,
,
. .

+ + Builder ( ),
,
>,
..
, ?
. DiceUnit.cpp Forml . Forml
TForml ( ), Forml
*:
TForml *Forml;
128


, Forml
TForml, ,
TForml.
:
int i; // int
int * i; // - int
TPLayer Computer; // TPlayer
TPLayer* Computer;//- TPLayer
:
double * Compute( int * X);
, ,
.
:
//
void

TReferee::ComputerMove()

// :
Computer.CurrentScores = 0;
// , ...
if( Dice.GetDiceValue{) != 1 )
//
Computer.CurrentScores - Dice.LastValue;
// :
Computer.Scores - Computer.Scores +
Computer.CurrentScores;
// ,
// :
Human.CurrentScores = 0;

5 3LIK 1064

] 29

8. .
, Scores Current Scores.
++ :
Computer,Scores

+- Computer.CurrentScores;

<+= , , , .
+=, ++ -=, *= /=.
:
- = 5; // , = - 5;
*= 2; // , = * 2;
/= +1; // , ~ / (+1);
GameFinish(). ,
, , ,
, .
100. :
Human.Scores >= 100 I I C o m p u t e r . S c o r e s >= 100
return,
true false:
//
bool

TReferee::GameFinish()

r e t u r n (Human.Scores >= 100


100) ;

II C o m p u t e r . S c o r e s >=


,
(100), . 100
, , ,
. (Search Replace)
, 100
.

130

100
. ,
.
, . :
c o n s t _ = ;

, ,
.
,
.
_.

GAME_FINISH_SCORE Game.h:
c o n s t GAME_FINISH_SCORE = 100;
GameFinish():
r e t u r n {Human.Scores :>= GAME_FINISH_SCORE I I
C o m p u t e r . S c o r e s >= GAME_FINISH_SCORE);
, .
, , .
.

, , ,
, .

131

9.

-
DiceUnit.cpp.
TFormi (

) Referee TReferee, , .
, ? , .
DiceUnit.h, TForm 1 (
class TFormi) . public: // User declarations ( ) .
, , , Referee:
public:

//

User d e c l a r a t i o n s
fastcall

TReferee

TFormi(TComponent*

Owner);

Referee;

He fastcaU.
C++Builder, . .
DiceUnit.h TPIayer?

132

-
, ( ) , .
DiceUnit.h Game.h (
TPIayer). :
#inelude

"Game.h"

,
,
.


.
, (
). , C++Builder.
.
1.


(. . 38).

2.

(Name) GameExitltem.

3.

.
V , ! 1!

LesHurtanScoc

L aitCoinputerS aoie
ComotiofSca-e
SarAeFnsh

. 38.

C++Builder GameExitltemClick()
TFormi . ,
.

133

9.
Terminate()
Application ( TApplication). C++Builder
.
, -,
. .
Application~>Terminate();
Application , >.



NewGameltem. ( NewGameltemClick())
NewGame() Referee,
.
. ,

.

(
Game.cpp).

.
Showlnfo()
TFormi. Showlnfof)
DiceUnit.cpp:
// :
void

TForml::Showlnf()

DiceUnit.h ( TForml):
void

134

Showlnf() ;


.
LastDice.
,
lntToStr().
, , , ,
lntToStr().
AnsiString, , , ++

, ,
( = ) , (+) ,
++. , AnsiString
*- ( = ) (!=), +, . , " 123" + "45"
"12345".
, ++
, . , const .
,
, .
.
C++Buitder ,


, .

,
.
1. File New ( > ), New () Header File ( ) (. . 39) .
Filei.h.
2. File Save As
( > ), Text.h ( , ,
).

135

9.
New Items
Elaags
*'*
j
I

ActiveX
j
. '

Report
&4

f irre-'t

j
Oats Modules
{
H-Miei
j
DicePrqeet
I
e x

Bwinett
}
|
ram*
!
1.4
I

Lb
i rary

Package

Projecl Group

Resource DLL
Wizard

Service

Service Application

I'-.-;

. 39.
3. . const . , (int)
:
c o n s t A n s i S t r i n g LASTJDICE_STR =
";

"

, .
,
_STR.
4.


#include

"Text.h"

DiceUnit.cpp, DiceUnit.h.

, C++Builder
(, ). , .

C++Bui4der Integrated Translation Environment.

136


LAST_D!CE
LastValue, Dice (
LastValue Dice.LastValue). Dice ,
TReferee. :
Referee.Dice
LastValue :
Referee.Dice.LastValue
, ++, .
Referee Dice TDice:
Referee.Dice
Dice LastValue.
LAST_DICE_STR
intToStr{) :
LAST_DICE_STR + I n t T o S t r ( R e f e r e e . D i c e . L a s t V a l u e )
?
Caption LastDice, .
.
Las~Dice->Caption = LAST_DICE_STR + I n t T o S t r
( R e f e r e e . D i c e . L a s t V a l u e );
:
c o n s t A n s i S t r i n g HUMAN_CURRENT_STR ";
const AnsiString
" ;

HUMAN_ALL_STR

"

"

c o n s t A n s i S t r i n g COMPUTER_CURRENT_STR =
";
c o n s t A n s i S t r i n g COMPUTER_ALL_STR =
" ;

"

"

ShowlnfoO :
L a s t D i c e - > C a p t i o n = LAST_DICE_STR + I n t T o S t r
( R e f e r e e . D i c e . L a s t V a l u e );

137

9.
LastHumanScore->Caption = HUMAN_CURRENT_STR +
IntToStr( Referee.Human.CurrentScores ) ;
HumanScore->Caption - HUMAN_ALL_STR + IntToStr
( Referee.Human.Scores );
LastComputerScore->Caption = COMPUTER_CURRENT_STR +
IntToStr( Referee.Computer.CurrentScores ) ;
ComputerScore->Caption - COMPUTER_ALL_STR + IntToStr
( Referee.Computer.Scores );
ShowlnfoO ,
.
,
Referee.NewGameO ShowlnfoO -
. TFormi
, :
fastcall

TFormi::TFormi(TComponent*

Owner)

: TForm(Owner)
{
Referee.NewGamef);
Showlnf();



EndGameTestO. TForm 1 DiceUnit.h
ShowlnfoO.
void

EndGameTest f ) ;

EndGameTestO GameFinish() TReferee


, , ,
, . TotatScores , .
:
if( Referee.GameFinish() )
GameFinishO bool
, .
138

-
if , .

AnsiString:
AnsiString

s;

,
.
, .
, ,
, . :
i f ( Referee.Human.Scores >= GAME_FINISH_SCORE )
.
100, s (
Text.h:
c o n s t A n s i S t r i n g HUMAN__WON_STR = " " ;
, :
c o n s t A n s i S t r i n g COMPUTER_WON_STR = "
";
(Human Computer).


, ,
, , ,
, . ++
if:
i f (
else

-1;

-2;

-2 , false.
if :
i f ( Referee.Human.Scores >= GAME_FINISH_SCORE )
{

Referee.Human.WinNum += 1;
S = HUMAN_WON_STR;

139

9.
else
Referee.Computer.WinNum +- 1
S = COMPUTER_WON__STR;

, WinNum TPlayer,
Human Computer,
.
. ++ ++. , , Referee.Human.WinNum ,
:
Referee.Human.WinNum ++;
, (
), ++ .
++ .
, , .

s
, .
:
ShowMessage(s);
TotalScores. s , ,
"8 : 5".
WinNum IntToStrO,
:
s

= s + " " + IntToStr(Referee.Human.WinNum) + " : " +


IntToStr
(Referee.Computer.WinNum);

s = s + ;

140

-
. ++,
+, +- (
). , :
s += ;

s +- " " + IntToStr(Referee.Human.WinNum) + " : " +
IntToStr(Referee.Computer.WinNum);


TotalScores . .
TListBox ListBox
. , , .
, , Items () TListBox.
TStrings ( ,
). Add() ().
Add() ( AnsiString) .
TotalScores Items ,
C++Builder, :
TotalScores->Items->Add(s);
TotalScores
s.
, : , ,
. ,
, , .

, ,
.



NewGameltem. -

141

9.
,
.

,
. , . , ,
, .
// , :
i f { Referee.GameFinish()

// , :
Referee.NewGame{);
// :
Showlnf();
}
, ?

, . ,
, else
, .
Text.h:
c o n s t A n s i S t r i n g GAME_NOT_STOP_STR =
";

"

:
else
ShowMessage(GAME_NOT_STOP_STR);

UseDiceltem . UseDiceltemClick.
? ,
. , ,
,
:

142

if f Referee.GameFinishf) )
ShowMessage(GAME_STOP_STR);
GAME_STOP_STR Text-h:
const AnsiString GAME_5TOP_STR = " ";
?
return. ,
UseDiceltemClick(), ,
void (, , ). return
, . :

return;
, .
, , (
, void),
return
.

:
i f { Referee.GameFinish() )
{
ShowMessage(GAME_STOP_STR);
return;
}
, ,
. , ShowMessage() ,
:
c o n s t A n s i S t r i n g ONE_STR =

" " ;

: Text.h.
,
, .

143

9.
:
// ...
i f f Referee.Dice.GetDiceValue()

//
ShowMessage(ONE_STR);
//
// ( )
Referee.ComputerMove();
}

Referee.Human.CurrentScores (
Referee. Dice. LastValue):
// :
e l s e Referee.Human.CurrentScores +=
Referee.Dice,LastValue;
:
Showlnf();

//

EndGameTest(); // ,


Nextltem .
, , ,
, . , , , , ,
, , :
Referee.Human.Scores = Referee.Human.CurrentScores;
Referee.ComputerMove();
Showlnfo();
EndGameTest()
.
,
.
144

-

.
1.

2.


Events ().

3.

OnClick ,
. , .

4.

.
1 NewGameltemClick ( ).
2 GameExitltemGick ().
3 UseDiceltemClick ( ).
4 NextltemClicK ( ).

Hint . , ,
. ,
, ShowHint true.
, , . -
,
.

All shown

,
(. . 40).
. , , ,
, .

. 3 . ( 5), 145

9.
fT-Hlpd E)

* & 1
0
W H D M K 0

3
0

. 40.

. 8,
, ,
. ( 4),
, .

;)

, .
? 4. , , ,
12(8+4), 4. , .
.


C++Builder.
.
. ,
.
,
, 8 , .
C++Builder NextItemClick(), .
F5
.
, ,
(. . 41).
Referee.Human.Score Referee.Human.CurrentScore,
, , 8 4.

146



, , , ,
.
DiceUnit
DfceLJnU of I OtceProtecLcpp j Game }
void

faatc&UL TFcrrrl::NextltercClick;TObject Sender;

if ( Referep.'JwneFinish ()

ShovHessaee (GAItE_3TOP_-3TR) ;
return;

Kefieree.ComputerHove();
Ehovlnio!);
EndGeuneTeat ( ) ;

116: 1

. 41.

,
, ,
. , ,
, F8. , ,
.
Referee.Human.Scores,
, 4 ( 12),
ShowlnfoO .

, .
F9.

, . ,
Referee.Human.CurrentScores Referee. Hu man. Scores.
. = +=:
Referee.Human.Scores

+= R e f e r e e . H u m a n . C u r r e n t S c o r e s ;

, ? .

147

9.
, CTRL+F2, ,
.
12. .
F8 .
F7 , , , , .
,
Referee.ComputerMove();
F7 ComputerMovef).
, NextItemQick().


, , ,
, .
, ?
? ?
, , , , , .
?
, , . randomQ.

. , , , .

.

, , . , C++Builder
randomizeO,
,
random() . randomizeO , :

148

'
randomize();
Referee.NewGame();
Showlnf();
DiceUnit.cpp :
#inelude < s t d l i b . h >
#include <time.h>
. .



, ,
, , . ,
.
.

. ,
ComputerMoveO TReferee .
, ,
: , 20
, (

).

,
, .
,
. . ?
. ++ ( ),
( ) . :

149

9.

for( -1; -; -2 )
-__~;
.
1. 1.
2. () (false),
.
3. ____6 .

4. 2.
5. 2.
, , , , . 1
, .
-1 . .

, ,
.
.
2 .
.
? , :

i n t i ; // -
f or ( i = 1; //
// 1
i <= 5; // ,
// i 5
i ++ ) / /
// 1
{

// ,

150


?
, . (
) , . , , . .
, 20 ( ) , .
:
// , . . .
i f l Dice.GetDiceValueO

!= 1 )

//
C o m p u t e r . C u r r e n t S c o r e s += D i c e . L a s t V a l u e ;
, ,
:
e l s e C o m p u t e r . C u r r e n t S c o r e s = 0;
? , Computer.CurrentScores
, ( , , ),
, .
, , .


for,
break ( :
break;
break,
, for. :
else

Computer.CurrentScores = 0;
break;

151

9.
. ,
20 , ,
, ,
:
// 20 ,
i f f Computer.CurrentScores >= 20 )
//
break;
ComputerMove() :
v o i d TReferee::ComputerMove()
{

int i ;
Computer.CurrentScores - 0;
for( i = 1; i <= 5; i ++ )
{
if ( Dice.GetDiceValueO != 1 )
Computer.CurrentScores += Dice.LastValue;
else
{
Computer.CurrentScores = 0;
break;
}
if( Computer.CurrentScores >= 20 )
break;
}
Computer.Scores += Computer.CurrentScores;
Human.CurrentScores - 0;
}

.
, !

for , .
152


f o r ( ; i < 5; i ++ )
( )

for( i = 1;

i < 5;

i
, :
for( i = 1; i < 5;

i ++;

:
f o r t i = 1; ; i ++ )
,
true,
, break.
.
true, .
Windows.
for. ,

:
for(;;)
{

// ,
break

}
. ,
, for,
, break.



100 ,
.

153

9.
, . , .
File New Form ( ).
Form2.
,
, .

.
InputForrn
( Name),
(
Caption).
Save All

ILJnit.cpp.
Input 100 ( Text), -
Cancel ().
, C++Builder Additional ()
BitBtn ( ), TBitBtn.
.
Kind ( ) bkOk
( ), bkCancel.
.

.
& Pltem ( Name ). .
C++Builder ,
InputForm.

JBi'Bhi TctBtn
Fropeftw j Ettrtt (

1 Km)
bkCK
[ L^out
bkCc
lse *
Ufi
bkH-sm
i'
1
MrtaHesdt gno e
Home
1

bkfiet'u

*renJl ' - - nkYes


i PwntS>Wfp
i
PopL^Menu

-\

Talse""

Al shown



, .
154


( return?)
, ,
, ( ) .
Referee.GameFinish().
,
. ?
++ && ||,
,
! (), ,
,
. ,
true, , :
!

Referee.GaraeFinish{)


Referee.GameFinish() ( , false),
!, false true.
!
booL Itrue false, Ifalse true.


( ) ,
Show() :
InputForm->Show() ;
InputForm ( )
DiceUnit.cpp, 'Unit.h:
tinclude

"iunit.h"

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

155

9.
C++Builder Show() ShowModalQ (
):
InputForm->ShowModal();
InputForm , .

. ,
BorderStyle ( ) InputForm bsDialog
( ).
, ? ShowModal()
mrOk mrCancel. , :
//
i f ( lnputForm->ShowModal()

== mrOk )


Input (, 50 1000).
, ,
input:
// InputForm :
i f ( InputForm->ShowModal()

== mrOk )

int input;
//

input = StrToInt( InputForm->Input->Text );


// :
if( input >= 50 ScSc input <= 1000 )


? GAME_FINISH_SCORE, .
, , , ,
- .

156


,
.
. ( ),

. . ,

, . , ,
, . , , ,

.
,
, , .


GAME_FINISH_SCORE. Game.h ,
TReferee :
int

GAME_FINISH_SCORE;

, , ,
. TReferee
:
GAME_FINISH_SCORE = 100;
,
i f ( R e f e r e e . H u m a n . S c o r e s >= GAME_FINISH_SCORE )
Undefined symbol "GAME__FINISH_SCORE"
( GAME_FINISH_SCORE ).
, GAME_FINISH_SCORE
( ) ,
Referee:
Referee.GAME FINISH SCORE
157

9.

i f f Referee.Human.Scores >= Referee.GAME_FINISH__SCORE )


, InputForm
- 100, ,
. , . ,
( GameFinish),
Showlnfo() :
GameFinish~>Caption = POROG_STR + I n t T o S t r
(Referee.GAME_FINISH_SCORE );
POROG_STR , , Text.h:
c o n s t A n s i S t r i n g POROG_STR = " " ;
Referee.GAME_FINISH_SCORE
Input InputForm, PltemClick() (
) Text input , :
InputForm->Input->Text =
IntToStr{Referee.GAME_FINISH_SCORE);
,
Referee.GAME_F!NISH_SCORE.
Referee.GameFinish()
Referee.GAME_FINISH_SCORE,
, , .
i f ( i n p u t >= 50 && i n p u t <= 1000 )
{

Referee.GAME_FINISH_SCORE = i n p u t ;
Referee.NewGame();
Showlnfo();
}
, input
, ,
:
else
158

ShowMessage (BAD_NUMBER_STR) ;


.
.
.
,
if. , , , :
// ,
if( InputForm->ShowModal() !* mrOk ) return;
int inputinput = StrToInt( InputForm->Input->Text );
if( input >= 50 && input <= 1000 )
{
Referee.GAME_FINISH_SCORE - input;
Referee.NewGame();
Showlnfo();
}
elseShowMessage(BAD_NUMBER_STR);
if , .



, ,
( ) (
,
). Formi Position () poScreenCenter .
( Caption)
.


,
, C++Builder.
.

159

9.
1.


Project Options ( ).

2.

Application ().

3. Load Icon ( ) . . 42.


4.

Windows
. , ,
C++Builder
( ,
). \lmages
\Buttons, \lcons. .
factory .
ProjtJcl Option1.
| Lrk I Artvanced Ljnjtei J Diecto'ies/
Vascninfo j e4ckages j 'stir- ] CORBA j
Fein Apjrfcaaor [ CcncFer | Adarce Conwa
ir
1*.
Help file.

Puc. 42.
. Title

, .
. , ,
.


, , , . , ,
. , -

160


,
. , ( Run-Time Libraries, RTL,
) .
, C++Builder.
RTL , ,
, . , ,
(
36 ).
O+Builder ( ) Debug
Release. .
.
1.
Project > Options ( ).
2. Compiler ().
3. Full debug ( ) Release () , .
4. (Release) , RTL Linker (
) Use dynamic RTL ( RTL).
.
,
.
Advanced Compiler ( ) Instruction set ( ).
386,486, Pentium Pentium Pro. ,

,
. . ,
, .

9.
5. Project Build (
). , Ctrl+F9 () ,
,
.
Build () .
Release Full debug
, ( , . .) .
RTL 91
, ,
Windows 9x.

++
,
, . .
C++Builder,
. .

162

10.
?
,
C++Builder
? , , . ,
,
, , . - , .
, ( ),
, , , 2,..., , N-
, , ,
iV .
, ? , , , , ,

.
++ .

.
,
.

163

10.




. :
_ [ _ ]

, , :
i n t x l , 2,

/* ... */ 2 0;

:
int

[20];

,
20 int. ,
(), ,
+-, int.
++ , .
0, 1,
19. , , .
. ( )

( ) . ,
, , ( ++)
,

. , , 1 ( ), 0. 1 . . ,

, , .
, , .

164


, ,
++ .
/^gk

41

, :

[0]
:
[9]
():
[19]
:
1 = 5;

x[0] = x[i] + x[i+l];


( , ,
).


++
. ,
, . :
l e n = 20;
int x [ l e n ] ;

// !

Constant expression required ( ).


,
, . ++ ,
,
Windows ,
. ,
, ,
.

165

10.



++, , ,
, . , -
,
:
TDice d i c e s [ 1 0 0 ] ;


, { ; ) Dice TDice,
GetDiceValueO .:
Dice.GetDiceValuef)
, , dices?
,
:
d i c e s [ 4 9 ] .GetDiceValueO
49, ++, , ( ).
C++Builder . ,
AnsiString () ()
, , ,
.
:
AnsiString

s;

s - "12345";
s[0] "1", a s[4] = "5".
C++BuiLder , ,
, , [](

). s[0]
AnsiString, . .

166



.

, . , ,
. , : . .
,
++? . ,
,
1024 256 .
:
int

excel

[256][1024];

excel 256 , 1024 int .


(100,100) ( ), :
excel

[100][100]

excel :
int

excel

[1024][256];

(1024 256 ).
, .
, . ,
, X, Y.
(, ) 64 ( X)
128 ( Y) :
int Map [64] [128];

X, Y:
[-4][+1]
.

167

10.
[][]
, ,
.

, , .
,
:
int

World[20][30][10];

++ . , - ( ,
, ). , , .


.
int

x[20][2];

:
[10]

[1]

, , :
[1]

[10]

, , : , 10.
- ( 2*20 -40 ,
1*10 = 10- ,
). ,
( ,
, ).
, . ++ :
int

x[10] ;

= [50];
168


,
.
50- , 10
( , 10*4 int 4 32 ),
50 , ,
, int.
, , :
i n t x[10] ;
[50] = ;
, 50 (50*4 )
. , . ,
- , , , , , , Windows.
++
. .

, C++Builder 5
.
CodeGuard ( ).
, .
CodeGuard Configuration
File Help
[Preferences % Offons | Function Options j Ignored Modules j
is Enacted

J2

*
:

Slacjj^frequency

|7 Statistics
p" Resowcal,9*s

" SendtafiUpulDeDiigStrins

fiepeated

Eras

Lima Durntefdeiior messages

Eua Message Bo
(7 Enable
epfion

jCodeGuard Error

Message _ jCodeJuard detected error(5] in the program A log hie Mill be created

Read debug inlo


Sourae pMh

Cancel

1 6 9

10.
, (
Project Options, CodeGuard) , , ,
.
CodeGuard, Tools CodeGuard Configuration ( > CodeGuard) ,
. , (, Enable ()
"CodeGuard is Enabled").
Code Guard
, , , : [ 5 0 ] = ; .


, . ,
int

x[100];

++:
i n t i,

sum;

sum - 0;

// i -

//

for( i = 0; i < 100; i ++ )


sum += x [ i ] ;
, i 0 99,

100.
,
1,
- .


?
. -, .

170


-, C++Builder,
, , ,
( ). -,

, - (shareware) .


- , ,
C++Builder ( File
Close All), ( File New Application).
, ++ MainUnit.cpp, a
WellProject (Well - ).
.


1. 52 .
2. .
3. 4 11 .
4. .
5. .
6. 60 () .
7. () . .
8. , .
9. , ,
.
10. , .
11. 104 .

171

10.
12.
( , , ,
. .). , .
.
13.
( ,
, . .).
14. ,
5 . , .
15. 5 .
16. ,
, ,
4 , .
17. 3, 2
.
18. , ,
.
, . 36 , .
?
, , 52 , .
Microsoft, cards.dll. \Windows\System.
cards.dll , , .
,
Windows. ,
. , . , cards.dll.

72


, - . Workshop,
C++Builder.
( setup.exe \Workshop\disk1)
( Resource Workshop),
File Open Project ( ),
FileType ( ) DLL, VBX, CPL Library,
cards.dll .
BITMAP ( ) cards.dll
. 1 52 , 53 58 , 678 684 .
(. . 43).
Resource Workshop - cards,dlt

fcNp

id

Ready
. 43. DLL

. .
1. .
2. .
3. Save resource as (
).
4. .bmp.
,
, 58,

173

10.
53

53.bmp,
( 54.bmp).

, , Windows, Microsoft ( Windows).


, ,
cards.dll . - .
, ,
.
, , cards.dll
.
, Windows DLL-. ,
, , cards.dll .
, C++Builder.

- . cards.dll
.


. ,
.
Color () Formi
clGreen.

Piepeies [Event

BorierVaJfr

Form 1
( Caption).
,
.
, WindowState ( )
wsMaximized.

.;

CtenfHeTghf

1 Co
i -

,233
Black
Warcon

A oil
Navy
Purple
Teal
I ^...jy^Gray
I

- J


cards.dll 71x96 .
,
800x600 . ,
.
MainMenu
,
,
.
, ImageList ( ) Win32.
, .

""


ImageList
. , , ,
, .
ImageList .
1. ImageList .
2. ( )
54 (52 , ).

j Litt 'I'-ags-S
zi
Fropertw j TenS*|
; AtocBv
QetWhta

' Merited"" ,fsse


,IL
| Name
Shtrarlr-a^e*
Wd
i th

|
All shown

3. BkColor clWhite (
).
4. DrawingStyle ( ) dsNormal ().
5. Height ( ) 96 ( cards.dll).
6. imageType ( ) itlmage ().
7. Masked (
, ) false ().

175

10.
8. Name ( ) IList (
).
9. Width ( ) 71 ( cards.dll, ).
10. ImageList.
(. . 44).
h-oim1->IList Imagei ist
- Selected

i? O.h

Puc. 44.

Add ()
( cards.dll .bmp) . Images (. . 45).
Forml->IList ImageList
^elected Irna

-aw
r

V
mage's --

- t-i

j d i

gear

. 45.

,
I.bmp, 2.bmp, 52- 52.bmp.

176

, .
,
0 ( ),
Selected Image ( ).

,
. , , .

Transparent Color ( )
cINone ( ),
Fill Color ( ) cINone, Options () Crop ( , ).
,
.
, .
, , .



_, , ( TCard). , ,
, .
( )
(, 52), ,
, ,
( ),
, .
,

.

177

10.

. , ( Project > Add To Project).
( ) File New ( >
) Unit (). CardUnit.cpp.
CardUnit.h
. :
class TCard
{
private:
int
Suit; //
int
Value; // 0- , 1- 2 , 2- 3, ..., 10- ,
11- , 12-
public:
void

Init(int suit, int value);

int

GetSuit();

int

GetValue();

bool is;
};
Suit (,
: 0 , 1 , 2 , 3 ). Value (0 , 1 ,..., 9 ,..., 12 ).
.
52
TCard, , . Suit Value
protected , TCard
. GetSuit() GetValuef). InitQ.

178


Is (public)
. . Is
true, .


:
class

TPack

private:
TCard Cards[PACKJTOTAL];
public:
TPack();
void

Shufflef);

void AddCard(TCard card);


TCard GetCardO ;
TCard GetIndexCard{int i ) ;
bool isCardO ;
,
PACK_TOTAL ( ).
. () , Shutf 1() , GetCard() , (
Is),
GetlndexCardO , IsCardf) ,
.


, () (
, )
(), , ,
, (, 4 ,
8 , ),
:

179

10.
c o n s t SUIT_NUM - 4;

//

c o n s t VALUE_NUM = 1 3 ;

//

?
, .
c o n s t PACK_LEN = VALUE_NUM*SUIT_NUM;
,
.
, , ,
,
.

, . :
c o n s t PACK__NUM = 2;

//

c o n s t PACK_TOTAL = PACK_NUM*PACK_LEN;

//

:
const KING = 12;
const

//

- 0; //

,
.
CardUnit.h, TCard.

CardUnit.cpp.
InitQ.
Is true ().
void

TCard::Init(int

Suit ~ suit;
Value = value;
180

suit,

int

value)

Is = true;
}

, Suit Value, ;
int TCard::GetSuitf) { return S u i t ; }
i n t TCard::GetValuef) { return Value; }


( 0 51, 52 103).
, ,
, ,
, . ( 0 3),
( 0 12). 4*13 - 52 , .
:
int

suit,

value;

:
for( s u i t = 0; s u i t < SUIT_NUM; s u i t ++ )

, ,
suit :
for( s u i t = 0; s u i t < SUIT_NUM; s u i t ++ )
{

forf value = 0; value < VALUE__NUM; value ++ )


// s u i t
value

:
for( s u i t = 0; s u i t < SUIT_NUM; s u i t + +
181

10.
for( value = 0; value < VALUE_NUM; value ++
// suit
value
.
, ,
, .
, , ,
(52 ):
f o r ( pack_num = 0; pack_num < PACK_NUM; pack_num ++ )
f o r ( s u i t = 0; s u i t < SUIT_NUM; s u i t ++ )
f o r ( v a l u e = 0; v a l u e < VALUE_NUM; v a l u e ++ )
{
// suit
// value
}
, - pack_num .
, ? Cards,
card_num,
, , .
:
::()
{
int card_num, pack_num,
card_num =

value;

0;

for(pack_num for(

suit,

0;

suit = 0;

p a c k _ n u m < PACK_NUM;
suit < SUIT_NUM;

for( value = 0; v a l u e < V A L U E _ N U M ;

182

p a c k _ n u m + +)

suit ++ )
v a l u e ++

//
Cards[card_num].Init(suit,

value)

//
card_num ++ ,-

Cards 104 .


, , ,
, .
.
,
.
,
.
( ) (104-) . ,
. ,
, 104, , 1000.
.
void

TPack::Shuffle{)

int n, rnd;
TCard card;
// " "
f o r ! n = 0; n < PACK_TOTAL; n ++ )
C a r d s [ n ] . I s = true;

183

10.
// PACK_TOTAL
f o r ( n = 1; n <^ PACK_TOTAL; n ++ )
{
// 0
// PACK_TOTAL-1
rnd = random(PACK_TOTAL);
//
card = Cards[PACK_TOTAL-1];
// rnd
Cards[PACK_TOTAL-1] = Cards[rnd];
// rnd ,
// :
Cards[rnd] - card;

random() <stdLib.h>,
CardUmt.cpp
#include <stdlib.h>
, (TCard). = ++ .

c a r d = Cards[PACK_TOTAL-1];
, Cards[PACK_TOTAL-1], , card. , < ==,
, .
, <<=, .

184



.
Cards, , , Is
false.
. , 0. 1 . . , ,
Cards, , Is
. Is, true (
), , ,
GetCard() .
, , Is, true, . ,
GetCard() - . ,
.

, .
, GetCard() (
) , , return, , , . ,
, , TCard. Function should return a value (
), .
TCard

T P a c k : : G e t C a r d f)

int

i ;

for( i = 0; i < PACK_TOTAL; i ++ )


if( Cards[i].Is )
{
Cards [i] . Is = false,return Cards[i] ;

185

10.
ShowMessage(" ");
return Cards[ 0 ] ;
}
,
.
TCard T P a c k : : G e t I n d e x C a r d ( i n t i)

return C a r d s [ i ] ;

i Cards.
, Cards,
protected, .

, ,
Cards Is,
false ( ),
. Cards
(, 0 ). Cards ,
, Is true, ( ,
) .
Cards , , ,
.
v o i d TPack::AddCard(TCard

card)

int i ;
for( i = 0; i < PACK_TOTAL; i ++ )
if( !Cards[i].Is &&
Cards[i].GetValue() = = card.GetValue() &&
Cards[i].GetSuit() == card.GetSuit() )
{
Cards[i].Is = true;
return;
}
ShowMessage("He ");

186


, .

Cards, , ( Is true), true,
. , ,
false.
bool

TPack::IsCard()

int i ;
f o r ( i - 0; i < PACK_TOTAL; i ++ )
iff C a r d s [ i ] . I s ) return true;
return f a l s e ;
}
,
CardUnit.cpp CardUnit.h,
, .



.
,
, .
;

.
, , (, 100 15 )
( 20),
.
( , ). , ,
, ,
.

187

10.
,
. , : , , , . ( Well
TCard), ,
:
TCard Well

[5] ;

? , . , Well
5:
TCard

Well

[5][5];

,
, Well , - , ,
.
,
104 (_1_).
PACKJTOTAL:
TCard Well

[5] [5] [PACK_TOTAL] ;


104 ,
5*5*104 , 25 . .
, ? .
5*5*104 = 2600 . TCard int 4 , booL (1 ).
200*(2*4 + 1) = 23400 ,
23 . 64 ! , .
Well TFrom 1
Formi, MainUnit.h, public-.

188


Well , ,
Pack:
TPack Pack;
TFormi TCard
TPack, MainUnit.cpp
MainUnit.h CardUnit.h:
#include

"CardUnit.h"

tinclude

"MainUnit.h"

, ,
( 14-17)
. Cycle:
int

Cycle;

? , ,
, /
, , . ,
- .

IList
( , 0 51) .
:
int

GetPacklmagelndexf) ;

IList ,
int

Getlmagelndex(int

line,

int

pos);

, pos
line ( , : 0 , i ,
2 , 3 , 4 ).
MainUnit.h :
c o n s t BACK_NUM = PACK_LEN;
c o n s t NONE^NUM = PACK_LEN+1;
BACK_NUM, 52, ,
NONE NUM .

189

10.
GetPacklmagelndexO , , , ,
( Is true),
IList, :
*13 +
, IList

, ( ) .
, NONE_NUM,
, .
int
int

TForml::GetPacklmagelndex()
i;

for(

1 = 0 ;

i < PACK_TOTAL;

i ++

i f ( Pack.GetlndexCard(i)-Is )
return Pack.GetlndexCard(i).GetSuit*VALUE_NUM +
Pack.GetlndexCard(i).GetValueO;
return NONEJSJUM;
GetlmagelndexQ .
, ,
Well. ,
Well[line][pos]
. :
for( i = PACK_TOTAL-1;

i >= 0;

i )

i 103 ( 104
, ), 0 >>.
int

TForml::GetImageIndex(int

int

i;

f o r ( i = PACK_TOTAL-1;

i >= 0;

line,

int

pos)

i )

if( Well [line] [pos] [ibis )


return Well[line][pos][i].GetSuitf)*VALUE_NUM +

190


Well[line][pos][i].GetValue();
r e t u r n NONE_NIM;
}


pos line
TCard G e t C a r d f i n t

line,

i n t pos,

bool view);

, ( view
true).
.
TCard T F o r m l : : G e t C a r d f i n t

line,

i n t pos,

b o o l view)

{
int

i ;

for( i = PACK_TOTAL-1; i >= 0; i )

i f ( Well[line] [pos] [i] . I s )


{

// :
iff Iview ) Well[line] [pos] [i].Is = false;
return Well[line][pos][i];

ShowMessage(" " ) ;
return Well[0][0][0];
}
Getlmagelndex()
, (_1_ 1) ,
. , GetCardQ ,
, .
:
v o i d AddCardfint l i n e ,

i n t pos,

bool pack,

TCard c a r d ) ;

card pos line. pack , card ( pack


false) .
191

10.

, (
) , Is false
( ), () . Is , ,
true .
void TFormi::AddCard(int l i n e , int pos, bool pack,
TCard card)
{

if( p a c k & &

IPack.lsCardO

return;

int i;
forf i = 0; i < PACK_TOTAL; i ++ )
if(

! Well[line][pos][i].Is )

{
i f ( pack ) w e l l t l i n e ] [ p o s ] [ i ] = Pack.GetCard();
else

Well [line] [pos] [i] = card,-

Well[line] [pos] [ i ] . I s - true;


return;


.
.
, , TFormi MainUnit.h:
void MoveCard(int l i n e l , int p o s l , int I i n e 2 , int
pos2);
MainUnit.cpp:
void TForrnl: :MoveCard(int l i n e l , int p o s l , int Iine2 ,
int pos2)
{
TCard card;
card = GetCard(linel,
AddCard(line2,

192

pos2,

posl,
false,

false) ;
card);


. pos1 linei
GetCard{) ( view false),
card,
AddCard() pos2 Iine2 (
false).


, , MoveCard(),
. :
v o i d NewGame () ;
(Pack.Shuffle()), Cycle
( ) 5. Is
Well false ( ).
.
4 11 .
AddCard(). 0 ( 0
), (4 , 0 3),
true ( ), card,

.
,
.
MoveCardO 0 0-3 0-3 2 ().
void

TForml::NewGame()

int

i,

j,

p;

TCard card;
card.lnit(0,0);
Pack.Shuffle();
Cycle = 5;

7 . 1064

193

10.
// :
for( i = 0; i < 5; i ++ )
for( j = 0; j < 5; j ++ )
for( p = 0; p < PACKJTOTAL; p ++ )
W e l l [ i ] [ j ] [ p ] . i s = false;
// 4 11 :
for{ i = 0;

i < 4;

i ++ )

for{ j = 0; j < 11; j ++ )


AddCard f 0, i , true, c a r d ) ;
// :
MoveCard(0,

0, 2,

0);

MoveCard(0,

1,

1);

2,

MoveCard(0, 2, 2, 2 ) ;
MoveCard(0,

3,

2,

3);


,
. ShowAII().
void

ShowAll{);

IList,
. Draw(),

IList .
Draw() ( TCanvas).

, , ,
. . , ,
. C++Builder , , .

194



.
TCanvas ( ) C++Builder Canvas.
Draw() ( ,
X , ,
, , ), ,
. ,
.
IList.
Getlmagelndex().
true. , , ( false,
, ).
,
,
, .
MainUnit.cpp,
. , , : X LEFT, . :
( 1). , - () LEFT32, -
13.
//
c o n s t CARD_WIDTH - 7 1 ;
c o n s t CARD_HEIGHT = 96;
//
const LEFT11 = 314;
const = 232;
const LEFT12 = 402;
const TOP12 = 288;

195

10.
const
const
const
const

LEFT13 = LEFT11;
TOP13 = 334;
LEFT14 = 226;
TOP14 = TOP12;

//
const LEFT21 = LEFT11;
const TOP21 = 128;
const LEFT22 = 490;
const TOP22 = TOP12;
const LEFT23 = LEFT11;
const TOP23 = 438;
const LEFT24 = 138;
const T0P24 = TOP12;
//
const LEFT31 = LEFT14;
const TOP31 = 184;
const LEFT32 = LEFT12;
const TOP32 = TOP31;
const LEFT33 = LEFT32;
const TOP33 = 400;
const LEFT34 = LEFT31;
const TOP34 = TOP33;
//
const MAIN_LEFT = 24;
const MAIN_TOP = 10;
//
const INV_LEFT = MAIN_LEFT;
const INV_TOP = MAIN_TOP + CARD_HEIGHT + 20;

196

//

c o n s t SHIFT5 = CARD_WIDTH + 10;


c o n s t LEFT41 = MAIN_LEFT + SHIFT5;
c o n s t TOP41 ~ MAIN_TOP;
(, LEFT23 = LEFT11), .
20 10 ,
.
,
800x600 .
0 0 :
IList->Draw(Canvas,
true);

LEFTll,TOPll,

GetImageIndex(0,0),

:
void

TForml::ShowAl1()

IList->Draw(Canvas,

LEFTll,,

Getlmagelndex(0,0),

IList->Draw(Canvas,
true);

LEFT12,TOP12,

Getlmagelndex(0,1),

IList->Draw(Canvas,
true);

LEFT13,TOP13,

Getlmagelndex(0,2),

IList->Draw(Canvas,

LEFT14,TOP14,

Getlmagelndex(0,3) ,

IList->Draw(Canvas,
true);

LEFT21,TOP21,

Getlmagelndex(2,0),

IList->Draw(Canvas,
true);

LEFT2 2,TOP2 2 ,

GetImagelndex(2,1),

IList->Draw{Canvas,
true);

LEFT2 3,TOP2 3 ,

GetImagelndex(2,2),

IList->Draw(Canvas,
true);

LEFT24,TOP24,

Getlmagelndex(2,3),

true);

true);

197

10.
IList->Draw(Canvas, LEFT31,1, GetImagelndex(1,0),
true);
IList->Draw(Canvas, LEFT32 ,TOP32 , Getlmagelndexd, 1) ,
true) ,IList->Draw(Canvas, LEFT33,TOP33, Getlmagelndex(1,2),
true);
IList->Draw(Canvas, LEFT34 ,TOP34 , Getlmagelndexd , 3) ,
true);
IList->Draw(Canvas, LEFT41,TOP41, Getlmagelndex(4,0
true);
IList->Draw(Canvas, LEFT41+SHIFT5,TOP41,
Getlmagelndex(4,1), true);
IList->Draw(Canvas, LEFT41+SHIFT5*2,TOP41,
Getlmagelndex{4,2), true);
IList->Draw{Canvas, LEFT41+SHIFT5*3,T0P41,
Getlmagelndex(4,3), true);
IList->Draw(Canvas, LEFT41+SHIFT5*4,TOP41,
Getlmagelndex(4,4}, true);
//
if(

Pack.IsCardO

IList->Draw(Canvas, MAIN_LEFT,MAIN_TOP, BACK__NUM,


true);
e l s e IList->Draw(Canvas,
NONE_NUM, t r u e ) ;

MAIN_LEFT,MAIN_TOP,

//
if(

IsCards(3,0)

IList->Draw(Canvas, INV_LEFT,INV_TOP,
Getlmagelndex(3,0) , true);
else IList->Draw(Canvas,
true);

198

INV_LEFT,INV_TOP, NONE_NUM,


:
,
;
,
.
ShowAll(), , - , ,
: ,
, ,
. . , - . ? !

-2
, , C++Builder OnPaint().
, , .
Form 1, Events
OnPaint.
C++Builder FormPaintO,
, , . , , FormPaintO
ShowAII().
void

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

*Sender}

{
ShowAllO ;
}
.
OnPaintf) ,
.
, ,

, Caption.

199

10.
?
ShowAll()
lsCarcls(). , :
bool I s C a r d s ( i n t l i n e , i n t p o s ) ;
true, pos line
. :
bool T F o r m l : : I s C a r d s f i n t

line,

i n t pos)

int

i ;

for( i = 0; i < PACK_TOTAL; i ++ )


iff Well[line] [pos] [i] .Is )
return true;
return false;
}

. .
?
Windows-, .
, , , . ,
, ,
MoveCard{) .

, ?
OnMouseUp. (
OnPaint), C++Builder
:
void
f a s t c a l l TForml::FormMouseUp(TObject
TMouseButton Button,
TShiftState Shift,

200

int X,

int Y)

*Sender,


,
( , , - !),
. .
TMouseButton

Button

TMouseButton . mbLeft , , mbRight


, mbMiddle . Button.

i n t X, i n t Y
, , , , ,
.
.
FormMouseUpO
. , , , .

TShiftState

Shift

,
CTRL, ALT SHIFT. ,
Shift ssAlt, ssShift ssCtrl.
ssDouble , .

TShiftState Contains(), ,
,
( TShiftState), . , ,
CTRL SHIFT, :
S h i f t . C o n t a i n s ( s s D o u b l e ) && S h i f t . C o n t a i n s ( s s C t r l )
Shift.Contains(ssShift)

&&

, FormMouseUpO
, , . ( C++Builder OnMouseDown)
( OnMouseUp). -

201

10.
, , , Windows
FormMouseDown(). FormMouseUpO
, .
FormMouseDown()
, , ,
.


, ,
, . TForm! :
i n t Line,

Pos;

Line , Pos . Line - 1 , , .


Line

Formi:
fastcall

TForml::TForml(TComponent*

Owner)

: TForm(Owner)
{
Line = - 1 ;
}

, , ,
. ,
Line (-1) (
) return .
,
. . , ,
0 0, , ,
, , (LEFT11, 11),

202


(LEFT11+CARD_WIDTH,
TOP11+CARD_HEIGHT):
if { X > LEFT11 &'& X < LEFT11+CARD_WIDTH &&
Y > ScSc Y < TOP11+CARD_HEIGHT )
{ line = 0; pos = 0 ; }
line top.
18. :
if( X > LEFT12 && X < LEFT12+CARD_WIDTH &&
Y > 12 && Y < TOP12+CARD__HEIGHT )
{ line = 0; pos = 1 ; }
. ., , , .


, .
, 18 (18 ), 4 (
):
int

Coords [18] [4] ;


? ,
++ , ,
. , ,
,
( ), :
i n t Coords [18] [4]" =
{LEFT11,,0,0} ,

//

{LEFT12,TOP12,0,1},{LEFT13,TOP13,0,2},{LEFT14,14,
0,3},

203

10.
{LEFT21,21,2,0},{LEFT22,22,2,1},{LEFT23,23,
2,2},{LEFT24,TOP24,2,3},
{LEFT31,TOP31,1,0},{LEFT32,TOP32,1,1},{LEFT3 3,,
1,2},{LEFT34,TOP3 4 , 1 , 3 } ,

//
{LEFT41,TOP41,4,0},{LEFT41+SHIFT5,41,4,1},
{LEFT41+SHIFT5*2,41,4,2},
{LEFT41+SHIFT5*3,TOP41,4,3},{LEFT41+SHIFT5*4,
TOP41,4,4},
{I1W_LEFT, INV_TOP, 3 , 0 }

//

};

41, SHIFT5, + 10 .
Coords . :
c o n s t i n t C o o r d s [ 1 8 ] [4]

= // ...

Coords MainUnit.cpp
.


Coords ,
- .
return.
- ( Line 1),
,
(), .
, Line Pos
.
, Line Pos (
, ),
, Pos Line
pos line, .

204


, ,
.

if ( X > MAIJSLJLEFT && X < MAIN_LEFT+CARD_WIDTH &&
Y > MAIN_TOP && Y < MAIN_TOP+CARD_HEIGHT )
,
Cycle.
, ,
.
, Cycle. .
void

fastcall

TForml::FormMouseUp(TObject

*Sender,

TMouseButton Button,
TShiftState Shift,

int X,

int Y)

{
int

i,

line,

pos;

TCard card;
card.Init(0,0);
//
i f ( Button == mbRight )
{
Line = - 1 ;
return;

// // (4-
// )
if( X > MAIN_LEFT && X < MAIN_LEFT+CARD_WIDTH &
Y > MAIN_TOP && Y < MAIN_TOP+CARD_HEIGHT )
{
int j, k;

205

10.
if( !Pack.lsCard() ) //
// :
{
//
for{ j - 4; j >= 0; j - )
for{ k = 0; k < PACK_TOTAL; k ++ )
if( Well[4][j][k].Is )
{
// :
Well[4][j][k].Is = false;
//
Pack.AddCard(Well[4][j][k]);
}
Cycle -;

iff Cycle <= 0 )


{
//
ShowMessagefPACK_USED_STR)
return;

// "Cycle"
// (4- )
for{ j = 0 ; j < Cycle; j ++ )
AddCard(4, j , true, card);
ShowAlK) ;
return;

206


// , :
line = -1;
for( i = 0; i < 18; i ++ )
i f { X > Coords [ i , 0 ] EcSc X < Coords [i,0]+CARD_WIDTH
ScSc
Y > Coords[i,l] && Y < Coords[i,1]+CARD_HEIGHT
)
{
line = Coords[i,2];
pos = Coords[i,3];

// - :
break;
}
// ,
:
if( line == -1 ) return;
//
if( Line == -1 && IsCards(line,pos) && line i= 1 )
{
Line = line;
Pos = pos;
return;

//
if( Line l= -I && (Line != line II Pos != pos)
CanMoveTo(1ine,pos) )
{
MoveCard{Line, Pos, line, pos);
ShowAlK) ;

207

10.

//
// , :
Line = - 1 ;
}

PACK_USED_STR
Text.h, :
const AnsiString PACK__USED_STR = "
";
MainUnit.cpp:
#include "Text.h"
#include "CardUnit.h"
#include "MainUnit.h"
CanMoveToO, .
, FormMouseUp() ,
, . - , -
FormMouseUp()
, , , .


CanMoveToO .
FormMouseUpO , CanMoveToO .
CanMoveToO TFormi :
bool

CanMoveTo(int

line,

int pos);

line (
) pos ( ), . , ,
Line Pos TFormi.

208


bool true,
.
CanMoveToO
. ,
( ), ,
.
bool

TForml::CanMoveTo(int

line,

int

pos)

// :
i f ; l i n e == 1 )
{

// :
//
if( !IsCards(I,pos) &&
//
GetCard(Line,Pos,true).GetValuef) -- KING &&
//
Line != 1 )
{
/*
: */
int king__suit, i;
//
king_suit = GetCard(Line,Pos,true).GetSuit();
/* ,
: */
for( i = 0; i < SUIT_NUM; i ++ )

209

10.
if{ IsCards(l,i) &&
GetCard(l,i,true).GetSuit{) == king_suit )
// , false
return false;
//
return true;

// :
//
if( Line 1= 1 &&
//
IsCards(l,pos) &&
//
GetCard(Line,Pos,true).GetSuit() ==
GetCard(l,pos,true).GetSuit() &&
//
OnBig(Line,Pos,1,pos,true) )
//
return true;

// :
if( line == 2 )
{
// :
//
210


if( Line == 0 &&
//
pos == Pos &&
//
!IsCards(2,Pos) )
//
return true;
// :
// ,
// :
if( (Line = = 0 1 1 Line == 2 I I Line == 4) &&
//
IsCards(2,pos) &&
//
GetCard(Line,Pos,true) .GetSuitO = =
GetCard (2 , pos , true) . GetSuit () &&
// 1
OnBig(Line,Pos,2,pos,false) )
//
return true;

// :
iff iine == 3 )

211

10.

// :
//
if( HsCards (3,0) &&
/ /
GetCard(Line,Pos,true).GetValuef) == ACE
//
return true;
// :
// ,
// :
if( (Line = = 0 | | Line == 2 I I Line == 4) &&
//
IsCards(3,pos} &&
//
GetCard(Line,Pos,true).GetSuit() ==
GetCard(3 ,pos, true) .GetSuitO &&
/ / 1
OnBig(Line,Pos,3,pos,false) )
//
return true,-

//
return false,-

212



CanMoveTo() OnBig(), ,

. , ,
CanMoveTo(), ,
.

,
. , ++,
, ,
, ,
. . , , .

,
.

OnBigO :
bool OnBigfint
on_big);

11,

int pi,

int

12,

i n t p2,

bool

, .
on_big, true,
.
.
bool TForml::OnBig(int
bool on_big)

11,

int pi,

int

12,

i n t p2,

i f ( on_big &&
G e t C a r d ( l l , p l , t r u e ) .GetValueO = =
GetCard(12,p2,true).GetValueO-1
II
G e t C a r d ( l l , p i , t r u e ) . G e t V a l u e O == KING &&
GetCard (12, p2 , t r u e ) .GetValueO == ACE )
return

true;

i f ( !on_big &
&

213

10.
GetCard(ll,pl,true).GetValueO =
GetCard(12,p2,true).GetValue()+1
GetCard(11,pi,true).GetValueO == ACE &&
GetCard(12,p2,true).GetValueO == KING )
return true;
return false, , , .
.
, , .


GameFin():
v o i d GameFin() ;
, , ,
, 1- () .
GAME_WIN_STR: Text.h:
c o n s t A n s i S t r i n g GAME_WIN_STR =
";

"

,
void TForml::GameFin()
i f ( Pack.IsCard()
int

i,

return;

j;

for( i - 0; i < 5; i ++ }
for(

j = 0 ; j < 5 ; j + + )

i f ( lsCardsfi,j)

) return;

ShowMessage(GAME_WIN_STR);
NewGame();
ShowAll{);

214


?
: ,
, ,
(
FormMouseUpO).


,
randomize(), ,
, :
fastcall

TForml::TForml(TComponent*

Owner)

: TForm(Owner)
{
randomize();
NewGame();
Line = - 1 ;
}

randomizeQ ,
:
# include <stdlib.h>
# i n c l u d e <time.h>
( ).
.

:
Application->Terminate();
:
NewGame{);
ShowAlI();
! . , ,
,
.

215

10.
.
, - .
, ,
.
,
(, ), , , . .

216

11.
?
. , , , .

. C++Builder, , ; , . .
, .
.
: , , , .
.

++
C++ . ,
,

.
/ ,
, ++,
Windows . .
?

217

11.
, , , .
99% - /
, 1%
, .
C++Builder ,
SysUtils (
) .
/ , , ,
, .
:
1.
.
2. .
3. .
. , .




, , , ,
.

. 46.

, : -

218


. Saveltem Loadltem.
C++Builder .
,
, .

int

FileCreate(AnsiString

FileName);


. ,
(,
), , .
- 1 , - (, ).
, FileCreate() ( int), Windows, . (
)
. ,
.
, game.sol,
c:\tmp. MainUnit.cpp:
const

AnsiString

FILE_NAME_STR

":\\tmp\\game.sol";

, ++
\ \\.
++:
int

iFile;

i F i l e = FileCreate(FILE_NAME_STR);
iFile FileCreate(). :
i f { i F i l e == -1 ) { ShowMessage(CANT_CREATE_STR +
FILE_NAME_STR); return; }
, (
Text.h:

219


c o n s t A n s i S t r i n g CANT_CREATE_STR = "
";
, ,
return.


, , .
, , .
bool F i l e E x i s t s ( A n s i S t r i n g FileName);
, , , true.


, ?
MessageBox() Application, .
Windows . MessageBox()
, -, :
MB_ABORTRETRYIGNORE

MB_OKCANCEL

OK

MB_RETRYCANCEL

MB_YESNO

MB^YESNOCANCEL

.
, . ++ |
( ). :

220

MB_ICONWARNING

MB_ICONINFORMATION

I)

( i ]


MB_ICONQUESTION
MB_ICONSTOP

( ?)
( - )

,

MB_YESNO I MB_ICONQUESTION
MessageBoxO 0 (
), , ,
.
IDOK

IDCANCEL

IDABORT

IDRETRY

ID1GNORE

IDYES

IDNO

, MessageBoxO
C++Builder AnsiString.
, MessageBoxO Windows, C++Builder,
char.
Windows , 0. char . MessageBoxO AnsiString,
char (, char *), AnsiString,
c_str().

, .
,
const AnsiString STR = "";
STR AnsiString (
):
STR.c_str()
. .

221

11.
Text.h :
c o n s t A n s i S t r i n g HEADER_STR =

"!";

c o n s t A n s i S t r i n g FILE_EXIST_STR =
";

"

MessageBox():
if(

FileExists(FILE_NAME_STR)

{
AnsiString
text

text;

= FILE_EXIST_STR + FILE_NAME,_STR +

"

?";

if( A p p l i c a t i o n - > M e s s a g e B o x ( t e x t . c _ s t r ( ) ,
HEADER_STR.c_Str(),
M B _ Y E S N O I MB_ICONQUESTI0N)

!= IDYES )

//

return;
FILE_EXIST_STR + FILE_NAME_STR
AnsiString,
c_str():
MessageBox((FILE_EXIST_STR + FILE_NAME_STR).c_str(), ..
.
, MessageBox() , .
++ .

FileWrite(). . ( - iFile),
,
( ), ,
. FileWritef) ,
.

222


, : Cycle, Line, Pos, Pack Well.
, , , ,
.
Cycle,
FileWrite(). ++ &,
, Cycle &Cycle.
&, . , , ,
.
Cycle (
) ? ++ sizeof().
sizeof() , , , =,
+ &. sizeof() , , , sizeof ++.
sizeof() ,
. , sizeof (Cycle),
4 (4 ), sizeof(int) ( int),
Cycle int.
Cycle :
FileWrite(iFile,

&Cycle,

sizeof(Cycle));

,
Pack:
FileWrite(iFile,

&Pack,

sizeof(Pack));

Well . , Well
, TCard. Well, ,
5*5*_1_.
sizeof(TCard)*5*5*PACK_TOTAL
.
( (0, 0, 0)) &Well[0][0][0],

223

11.
. ++ ,
Well. :
FileWrite(iFile,

Well,

sizeof(TCard)*5*5*PACK__TOTAL);

( )
Well.
, .


, , , - , ,
. FileWrite()
(-1) . :
int

err;

:
err = FileRead(iFile, Well,
Sizeof(TCard)*5*5*PACK_TOTAL);
if( err == -1 )
ShowMessage("Well" + BAD_OUTPUT_STR);
FileClose(iFile);
return;
}
Text.h :
const A n s i S t r i n g BAD_OUTPUT_STR = " ";


.

void F i l e C l o s e ( i n t i F i l e ) ;
:

224


void
fastcall
*Sender)

TForml::SaveltemClick(TObject

if f FileExists(FILE_NAME_STR)

{
AnsiString

text;

text = FILE_EXTST_STR + FILE_NAME_STR +


if(

"

?";

Application->MessageBox(text.c_str(),
HEADER_STR.C_str(),
M B _ Y E S N O I MB_ICONQUESTION)

!= IDYES )

return;
}
int

iFile,

iFile
iff

err;

FileCreate(FlLE_NAME_STR);

iFile == -1
{

ShowMessage(CANT_CREATE_STR + FILE_NAME_STR)

return;
}
err = FileWrite(iFile,
iff

err == -1
{

&Cycle,

sizeof(Cycle));

ShowMessage("Cycle"+BAD_OUTPUT_STR);
FileClose(iFile};

err = FileWrite (iFile,

return;
&Line,

}
sizeof(Line));

if( err == -1 )
{

ShowMessage("Line"+BAD_OUTPUT_STR);
FileClose(iFile);

return;
}
err = F i l e W r i t e ( i F i l e ,
iff
{

&Pos,

sizeof(Pos));

err == -1 )
ShowMessage("Pos"+BAD_OUTPUT_STR);
FileClose(iFile);

return;

225

1.

err = FileWrite(iFile, &, sizeof(Pack));


if( err == -1 )
{ ShowMessage f"Pack"+BAD_OUTPUT_STR);
FileClosefiFile);
return;
}
err = FileWrite(iFile, Well,
sizeof(TCard)*5*5*PACK_TOTAL);
if( err == -1 )
{ ShowMessage("Well"+BAD_OUTPUT_STR);
FileClosefiFile);
return;
}
FileClose(iFile);
}
, .


, .
, FileReadQ.
.
.
i n t F i l e O p e n ( A n s i S t r i n g FileName,

i n t Mode);


(, ,
-1), . fmOpenRead, ,
.
(, , Text.h):

226


const A n s i S t r i n g BAD_INPUT_STR = " " ;
. :
void
fastcall
^Sender)

TForml::LoadItemClick(TObject

int iFile, err;


iFule = FileOpen(FILE_NAME_STR, fmOpenRead);
if; iFile == -1 )
{ ShowMessage(CANT_CREATE_STR + FILE_NAME_STR);
return;
}
err - FileRead(iFile,

&Cycle,

sizeof(Cycle));

i f ( e r r == -1 )
{ ShowMessage("Cycle"+BAD_INPUT_STR);
FileClose(iFile);
return;
}
err = FileRead ( i F i l e , &Line, sizeof(Line));
i f ( e r r == -1 )
{ ShowMessage("Line"+BAD_INPUT_STR);
FileClose(iFile);
return;
}

err = FileRead(iFile, &Pos, sizeof(Pos));


if( e r r == -1 )
{ ShowMessage("Pos"+BAD_INPUT_STR);
FileClose(iFile);
return;
}
e r r - FileRead(iFile, &Pack, sizeof(Pack)};
i f ( e r r == -1 )
{ ShowMessage("Pack"+BAD_INPUT_STR);
227

1.
FileClose(iFile);
return;
}
err - FileReadfiFile, Well,
sizeof(TCard)*5*5*PACK_TOTAL);
if( err == -1 )
{ ShowMessage("Well"+BAD_INPUT_STR);
FileClose(iFile);
return;
}
FileClose(iFile);
ShowAl1();
}
ShowAII(), , .
,
, . ,
.
.
.
/ .
,
,
, /
.
-. . ,
TSolData:
class

T6olData

{
int Cycle,
TPack

228

Pack;

Line,

Pos;


TCard

Well[5][5][PACK_TOTAL];

TForm 1 :
TSolData

SolData;


, Pack, a SolData.Pack . .
( )
:
FileWrite(iFile,

&SolData,

sizeof(TSolData) ) ;

TSolData,

/
TSolData.
, ,
TSolData ( ), TSolData -
.

.
, .
Windows,
.
, C++Builder File Open ( ).
C++Builder OpenDialog
DecisionCuba I DfieotHt ^Wmat I Samdes I AaBwKj St*X*.

SaveDialog,
DWoasfwiBSI I ! | S t i L *

SaveDielogf
229

11.

Dialogs.
,
.
(. . 47).
""

. 47.

, MainMenu ImageList, .
,
.

OpenDialogi SaveDialogi (,
, Name).
, Title. , .
.
.SOL ( solitaire
). , .
Filter (). , ,
,
*.soi, j.
, ,
. DefaultExt, ( ) SOL.

230


,
.
, ,
, . ofFileMustExist ( ),
Options.
ofFileMustExist
true.

Ot)|i;nt Inspector
| jDirCiaoiji TDpriCa
' bg
Properte
i s JEwert*|
p Opo
tins
d
O
verw Prompt false
t
, otHdePeaaOJ.j t(UB
< _0fNuCh<re
jCtr
'fab*
i

dbeeF-J
ofSharaAwuie

Thidds"-"

1
(1
"4


ExecuteO . true, . false.
? ExecuteO true,
FileName.
, FILE_NAME_STR (
),
FILE_NAME_STR ( , ).
AnsiString FILE_NAME_STR;

LoadltemClickO :
// , :
if (

!OpenDialogl->Execute()

return,-

//
AnsiString

FILE_NAME_STR;

FILE_NAME_STR = OpenDialogl->FileName;
FILE_NAME_STR
, , .
SaveltemClick()
:

231

// , :
if ( !SaveDialogl->Execute() ) return,// :
AnsiString FILE_NAME_STR;
FILE_NAME_STR = SaveDialogl->FileName;
.

C++BuiLder
, C++Builder.
, .
.
1. FileName
. ,
, , ,
Windows.
FileName .

iFile.
2. - 1 ,
. .
3. ()
TDateTime,
, ,
( DateStringO) ( TimeStringO), :
TDateTime d t ;
// :
dt.CurrentDateTime();
// Text
//

Text = d t . D a t e S t r i n g O ;
Text , , : 22/11/2000.

232


int FileAge{AnsiString FileName);

FileName.

TDateTime
FileDateToDateTime():
i n t age;
TDateTime d t ;
age - FileAge ( "c : Wcomrrand.com") ;
dt - FileDareToDateTirr.e (age) ;

int FileGetDate(int iFile);


int FileSetDate{int iFile, int Age);

iFile.
Age
iFile. Age
TDateTime

DateTimeToFileDate():
inc age;
TDateTime dc;
dt = FileDateToDateTime(age);
age = DateTimeToFileDate(dt);

AnsiString FileSearch(AnsiString Name,


AnsiString D i r U s t ) ;

Name
DirList (
). ,
,
"" .
if ( FileSearcht"referat.doc",
" : \\terrp; : \ \doc ; : \ \inet")

int FileSeek(int iFile, int Offset, int Origin); iFile,



.
Offset
, Origin ,

. Origin = 0,
;
Origin =1 ;
Origin = 2 .
bool DeleteFile(AnsiString FileName);

FileName.
false.

bool RenameFile{AnsiString OldName,


AnsiString NewName);

OldName
NewName, :
RenameFiie{"start.doc",
"start2.doc"};

false.

233

11.
bool CreateDir(AnsiString Dir);

Dir.
false.
, ,

CreateDir(":\temp\web\koi");


c:\temp\web.
void ForceDirectories(AnsiString Dir);

Dir.

, ,
, :
temp,
ForceDirectories(":\temp\l\2"
\temp,

\1\2.

boot DirectoryExists(AnsiString Name);

, Name.

AnsiString GetCurrentDir();

bool SetCurrentDir(AnsiString Dir);

Dir
:
SetCurrentDirf":\\tmp");

false.
bool RemoveDir(AnsiString Dir);

Dir.
.
false.

jnt64 DiskSize(Byte Drive);


.
Drive :
0
1
2
3
4 D . .

int64 DiskFree(Byte Drive);


Drive .

234

12. ,

,
C++Builder,
, ,
.
, C++Builder.

Standard

, , , ,
.

C++Builder 5. ,
,
C++Builder. , , .
.

235

12. ,

Windows ,
. C++Builder
PopupMenu TPopupMenu ( , ).
, , ,
(), X Y , :
PopupMenul->Popup{250,250);

, - , . Memo.

Lines. : Count
Strings AnsiString,
, Count. , Memol, :
s

- Memol->Lines->Strings[

Memol->Lines->Count-l

];

, .

(CheckBox) Windows.
Checked, bool
true, .
Caption (
Alignment taRightJustify), (taLeftJustify).
, OnCiick
( ).

(RadioButton) , , i
, , , - L_

236

Standard

.
, , Checked.
Alignment.


, RadioButton.
()? RadioGroup.
Items ( TStrings, ) ,
. (. . 48),
Items.
String List <;di)or
1
2
3

. 48.


, Columns.
, ,
Itemlndex, ( ).
, Items.
Itemlndex - 1 , , . Itemlndex ,
, Itemlndex
.

237

2. ,


( ScrollBar)
, , , .

Kind , : (sbHorizontal) (sbVertical).


: Min , ,
() ().
Position, ,
, Min .
PAGE UP PAGE DOWN , Position , PageSize. , , Position
, LargeChange.
Position , SmallChange.
Position .
OnScroll , , ,
, .


(GroupBox) ( Caption).
.

, ,
( Panel).
,
. : (
Bevellnner) (BevelOuter),

238

Additional
(bvRaised), (bvLowered) (bvNone).
BevelWidth,
BorderWidth.

Additional

(BitBtn) (SpeedButton).


MaskEdit , , - |
(). ,
,
Input Mask Editor.


StringGrid .
, .
(
) ,
ColCount ( ) RowCount ( ). ,
(/
).

Cells . ,
"123 , 45" (2,3) StringGrid 1,
:
S t r i n g G r i d l - > C e l l s [ 2 ] [3 3

= "123,45";

239

12. ,

123,45.
, (
), Col Row (
).

DefaultColWidth DefaultColHeight.



, , , , [
- .
DrawGrid StringGrid,
Cells.
,
. , DrawCellO, , (
C++Builder). DrawCell()
.

, ,
, Image ().
Picture, , .



. C++Builder
Shape.
(stRectangle),
(stSquare), (stRoundRect),
(st Round Square), (stEllipse) (stCircle).
Shape.
( ),
, Color () Width (

240

Additional
).
( Brush), Color ( ).
Width Height.

Bevel () Panel. ( Style,


bsRaised , bsLowered ). ( Shape), , .


C++Builder ,
( )
.
ScrollBox .
.


, , /.

8
. C++Builder StaticText.
Caption,
, StaticText BorderStyle, .


C++Builder
. , , .
ControlBar.
9 1064

241

12. ,
,
. .

Chart . ,

. .
, ++.
'lt.-oCti.irt Gallery

. 49.

Win32

, ImageList ( ),
, ToolBar
, .

PageControl () ,
.

242

Win32
, C++Builder ,
. ,
, , .
PageControl . .
1. PageControl.
2. .
3. New page
.
4. (
!), .
5. Caption ,
.

,
.

( !)
DEL.
Win32 TabControL.

, TabControl,
, .


Memo . , , ,
. . RichEdit.
. RichEdit , ,

243

2. ,
.RTF, .

TrackBar

Min, Max Position.
Frequency ( ). , , Min = 0, = 10, a Frequency = 2, 6
( ). Orientation , (trHorizontal)
(trVertical). ThumbLength,
LineSize, PAGEUP/PAGEDOWN
PageSize.
,
SelStart SelEnd. , SelStart
3, SelEnd 8. 3 8
, ,
, .


ProgressBar , ,
, .
Min, Max
Position, Step, ,
Steplt()
, .
Position StepByO.
.


, , ,
1 25.
, ,
.
TUpDown, .

244

Win32
, Position
.
, ,
-, ,
Associate ( ) .
,
.
, Min, Max, Orientation Position,
Increment (
Position ), Thousands
, ( )
, , : 1,000 9,876,543.
, ,
,
( ArrowKeys true).


. , Windows, ,
ALT+TAB ,
CTRL+ S
. . THotKey.
, : SHIFT+CTRL+A,
SHIFT+CTRL+A. , , HotKey,
,
C++Builder.

Image (), Animate ()


( , Windows , . .),
.AVI.

245

12. ,
FileName. :
(aviFindFolder);
(aviFindFile);
(aviFindComputer);
(aviCopyFiles);
(aviCopyFile);
(avi Recycle File);
(aviEmptyRecycle);
(aviDeleteFile).
CommonAVI.
, AVI-,
, Open true, ,
true Active. Repetitions
, Transparent , .
StartFrame ( ) StopFrame ( ).
.
, Seek(),
.
Stop(), Active true.


/ ,
, . TDateTimePicker.
/.
Kindio
dtkDate,
dtkTime. ,
.

246

J111
.OO
.G

! "

1
3
i
1 2
1 9 10
! 1G 17 18
? 23 24 25
30 ?1
l i b .

(1

1 | =* g

6
12
19

13
20
?7

21
7

11.10.00

1
22

Win32
,
Date Time ( TDateTime).
( DateFormat) dfShort
( ,
2000 XXI ) df Long,
. ,
MinDate ( ) MaxDate (
).


MonthCalendar
.
( Date)
( MultiSelect true;
EndDate).
,
FirstDayOfWeek.
, WeekNumbers true.


HeaderControl
, , , .
, HeaderControl, Sections Editor.


(
StatusBar).
( false SimplePanel,
SimpleText), , ,
Panels Editor.


CoolBar ToolBar.

247

12. ,

,
. ,
Bands Editor .


C++Builder 640x480 ,
,
.
PageScroller.
Control ( ) ,
. , PageScroller
-.
.

System

.
, -, . Windows
. ,
. , ,
.
Microsoft , . Windows,
.
Microsoft C++Builder Timer.

.

248

System
, Enabled true,
false. ,
OnTimer, , Interval. , , ,
, .
, Windows


Windows-,
,
OnTimer .



. ,
( ).
, PaintBox.
.
OnPaint.


AVI- ,
C++Builder MediaPlayer,
( !) , , ,
.
C++Builder , DeviceType ( ) .
MediaPlayer ,
( , , , ).
Panel. ,
, MediaPlayer Display.

249

12. ,
, , FileName.
, 1(), Stop(). TMediaPlayer
, (Play,
Stop, Next . .).
1 ! 41
, , VisibleButtons, , .
false, . ,
Play.
, , , MediaPlayer .
, , ,
,
. MediaPlayer ,
, , Visible ().
false, , .

OLE-
, OleContainer
.
OLE Microsoft
Windows , 16- .
OLE Windows, ( C++BuiLder),
, . . , ,
OLE-.
Windows 9x OLE.
Word, Excel, Paint, . ,
, OleContainer,
.

250

Dialogs
OleContainer
,
OLE-.
Insert Object ,
.

Microsoft Wofd
WoidPad


Microsoft Excel
MIDI

Microsoft PnwetPoint

( , Excel, Microsoft Excel),


OLE-, .
Excel.
, ,
:
. ,

Excel,
,
, Excel
.

WAVBVBVQ^IZI
v
; Aria Cyr

ac

JE >

'

"

_ij

.- .. * - ^ -

!
1 leant 11
2

.
~

5"

OLE : . .

Dialogs
,
Windows, . (OpenDialog SaveDialog). OpenPictureDialog SavePictureDialog,
,
.
FontDialog ( Font)
, .
ColorDialog (
Color).

251

12. ,

PrinterSetupDialog.
( ,
, . .), PrintDialog.
FindDialog.
FindText,
Options.
ReplaceOialog, . FindText, , ,
ReplaceText.
,
. , , , ,
. . , , .
Executed) true, .

!
C++Builder 200 ,
, . ,
-, . Web- www.torry.ru (,
).
,
O+Builder?
www.torry.ru Components Page ( ). ,
,
. ,
, .

252

!
Buttons & Check Boxes # 2 ( -2) Torry's Button,
. 81 . .
Zip- : torrybtn.inf ( ), torrybtn.pas ( ) torrybtn.d32
( ).
,
++?
-
Delphi , C++Builder,
.
C++Builder 4- , 1999 .
, , . ,
C++Builder ++, ,
.
Torry's Button Component Install Component.
. Into
New Package ( ), Unit file name ( )
Browse () torrybtn.pas (
: .PAS, .!),
Package file name: t o r r y .
jlnstall Component
Into rxBtng package Into new package j
UrtsVJOF-irR-SPAE
Search petht js 3U3J4 c.$;l
Eeskaae Fe
li name pv
deicrittwn

Canoe!
Puc. 50.

, .
C++Builder , torry.bpl ( torry.pas ).

253

12. ,
Yes. C++Builder
, ( ,
) TTorryButton ( TorryButton). C++Builder , , TForm, TButton .
.
? ,
.
.
QHeoortJ DteJooslWr3l! Samotes] ActiveX] Servei Ton* \ JJ

, ,
. TorryButton ( Caption).
, ,
. !

. , , TorryButton, .
1. Component Install Packages. ( ).
2. , (
torry), .
, .
C++Buitder!
3. Remove () Yes.
4. .
TTorryButton .
.

254

C++Builder

C++Builder
, C++Builder. .


1.

,

, .

2.

, Parent (), ,
. ,
, ? .
, . .
.


ActiveControl

,
( )

Align

.
:
aINone ;
alTop no ;
alBottom ;
alLeft no ;
alRight no ;
alClient

Alignment

:
(taLeftJustify);
(taRightJustify);
(taCenter)

Anchors

,
. ,
akLeft akRight,
.

to Hotkeys

255

12. ,
AutoScroll

true,
,

AutoSize

true,

BiDiKeyboard

BiDiMode



(bdLeftToRight, )
(bdRightToLeft)

Borderlcons

BorderStyle

. :
bsNone ( );
bsSingle ( );
bsSizeable (,
);
bsDialog ( );
bsToolWindow ( bsSingte, );
bsSizeToolWin ( bsSizeable, )

BorderWidth

Cancel

,
OnClick, ESC
( Cancel true).

Caption

. ,
,
(, )

Checked

, {true )

Color

Columns

Constraints

Ctl3D

( Windows 95 )

Cursor

( )

256

C++Builder
Default

,
OnClick, ENTER
( Default true)

DockSite

,
. . (true),

.
(. Drag Kind)

Down

(true )

DragCursor

DragKind

,
(dkDrag)
(dkDock),

DragMode

, (
dmAutomatic) (dmManual, no )
, DragKind

Enabled

. Enabled false,
(,
, )

FileName

.
,
,
. .

Flat

(true )

Font

,
.

FormStyle

. :
fsNormal ( );
fsMDIChild ( ):
fsMDIForm ( );
fsStayOnTop ( )

Glyph

, (,
, , )

Height

257

12. ,
HelpContext

,
F1
( Windows)

HelpFile

HorzScrollBar

Highlighted

Hint

,
. ,
ShowHint true

HintFont

Icon

Images

,
, . .

ItemEnabted

Itemlndex

Items.
. ,
Itemlndex 1

Items

, .
, ,

Kind

() .

Left

Lines

.
. Items

,
, . .

Max Length

MenuAnimation

,
Windows 2000

258

C++Bui!der
MenuFont

Min

,
, . .

ModalResult

,
. mrNone (
), mrOk, mrCancel, mrAbort, mrRetry, mrlgnore, mrYes,
mrNo mrAII.
, mrNone,

Name

( ,
)

Options

Orientation

.
(udHorizontal) {udVertical)

OwnerDraw

,
(true)

Picture

PixelsPerlnch

() .

. , Scaled
true

PopupMenu

,
.

Position

. :
poDesigned

;
poDefault Windows;
DefaultPosOnly ,
;
poDefaultSizeOnly ,
;
poScreenCenter
;
poDesktopCenter .
, . .

259

12. ,
ReadOnly

true,
. ,
ReadOnly
,

Scaled

true, PixelsPerlnch

ShowHint

, ,
Hint

Sorted

. (true),

Style

. (,
, . .)

TabOrder


TAB.

TabStop

,

TAB

Tag

, .

int. Tag

Text


( . .)

Title

() , ,

Transparent

. ,
Transparent true ,
-,
,

VertScrollBar

260

C++Builder
Visible

,
( true)

Width

WindowState

. :
wsNormal ,
;
wsMinimized ;
wsMaximized

261


Borland C++Builder
Borland C++Builder Inprise.
{desktop)
, , , ,
, , , , , .
C++Builder,
Inprise C++Builder Delphi.
.


,
( Data Access, Data Contrlos, InterBase ADO),

, ,
.
, , ,
(
- ),
, , ,
, . , , {)
. , , .

262

, Microsoft SQL Server, Oracle, IBM DB2, Inprise


InterBase .


,
,
(,
),
- ,

( Decision Cube).
.


C++Builder ( QReport) .
. (, , ), , ,
. .

Internet FastNet
, ,
, . .

, , ,
.


,

.
( Midas Internet Express),

263


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

Microsoft ( Word, Excel, PowerPoint,


Access, Outlook) .
,
C++Builder
. , : ,
,

, !
, - , -.
, - ( Microsoft), Servers.


Inprise JBuilder 4. Java, , ++
, . ,
Windows ,
, Unix . Inprise Kylix.
C++Builder Delphi.

264



: Windows Linux. He , , . ,
.
, C++Builder Web-
www.borland.com www.borland.ru ( Borland
Inprise).

265


Associate, 247
Active, 248
ActiveControl, 257
ActiveX, 28
Add(), 145
Additional, 27, 241
Align, 257
Alignment, 239
Anchors, 258
Animate, 248
AnsiString, 98
Arrow Keys, 247
atoi(), 98
atof(), 102
AutoHotKeys, 258
AutoScroll, 258
AutoSize, 258

I Background, 55
Bevel, 243
BiDiKeyboard, 258
BiDiMode, 258
BkColor, 177
bool, 104
Borderlcons, 258
BorderStyle, 258
BorderWidth, 258
Borland C++, 14
Borland C++Builder 18
24
20
Build, 164
Button, 40
c_str(), 101
C++Builder Direct, 26
Cancel, 258
Caption, 39
catch- 96
Cells, 241
Chart, 244
Checked, 258
Col, 258
ColCount, 241

266

Color, 176, 242


ColorDialog, 254
Columns, 259
CommonAVI, 248
Compiling, 55
Contains(), 203
Constraints, 259
Control, 250
ControlBar, 244
Count, 238
Ctrl3D, 259
Cursor, 259
)
Data Access, 27
Data Controls, 27
Date, 249
DateString(), 234
Debug, 163
Decision Cube, 28
Default, 59
DefaultColHeight, 242
DefauItColWidth, 242
Dialogs, 28, 254
Display, 252
DockSite, 259
double, 66
Down, 259
DragCursor, 259
DragKind, 259
DragMode, 259
DragGrid, 242
DrawingStyle, 177
EConvertError, 92
Edit, 37
Enabled, 259
EndDate, 249
EOverflow, 96
Execute(), 233
FileCreate(), 221
FileName, 248, 259
FUeReadO, 228
FileWnte(), 224
Filter, 232


FindDialog, 254
FindText, 249
FirstDayOfWeek, 258
FormMouseUpO, 204
Flat, 259
FloatToStrO, 70
FloatToStrF(), 71, 93
float, 66
Font, 32, 259
FontDialog, 254
FormStyle, 260
Frequency, 246
Glyph, 118, 260
GroupBox, 240

HeaderControl, 249
Height, 177, 260
HelpContext, 260
HelpFile, 260
Highlighted, 260
Hint, 260
HintFont, 260
HorzScrollBar, 260
HotKey, 247

I
Icon, 260
IDE, 25
Images, 242, 260
Imagelndex, 260
ImageList, 177, 244
ImageType, 177
Increment, 247
Interval, 251
IntToStr(), 68
ItemEnabled, 260
Itemlndex, 260
Items, 260
(
Kind, 260
Kylex, 266
Label, 39
Left, 260
Lines, 2610
Linker, 58
Linux, 17
long double, 66

MainMenu, 115
Masked, 177

MaskedEdit, 241
, 247, 261
MaxLength, 261
MediaPlayer, 251
Memo, 246
MenuAnimation, 261
MenuFont, 261
MessageBox(), 223
Microsoft Outlook Express, 29
Microsoft Visual Basic, 18
Microsoft Visual C++, 18
Midas, 28
Min, 247, 261
ModalResult, 261
MonthCalendar, 258
MultiSelect, 249

N
Name, 39, 261

3
ObjectPascal, 18
Object Inspector 30
OleContainer, 252
OnChange, 31
OnClick, 31
OnMouseDown, 204
OnMouseUp, 203
OnPaint, 251
OnTimer, 251
Open, 248
OpenDialog, 231
Options, 261
Orientation, 261
OwnerDraw, 261
>
PageControl, 245
PageScroller, 250
PaintBox, 251
Panel, 252
Picture, 261
PixelsPerlnch, 261
Play(), 252
PopupMenu, 261
Position, 247, 261
PrintDialog, 254
PrinterSetupDialog, 254
ProgressBar, 246
QReport, 28, 265
RAD- 17
RadioButton, 238

267


RadioGroup, 239
random(), 124
randomize(), 150
Readonly, 262
Repetition, 248
ReplaceDialog, 254
ReplaceText, 254
RichEdit, 246
Row, 242
RowCount, 241
RTL- 163

SaveDiaiog, 231
Scaled, 262
ScrollBar, 240
ScrollBox, 243
Seek(), 248
SelEnd, 246
SelStart, 246
Shape, 242
ShowHint, 147, 262
ShowMessage(), 145
ShowModal(), 158
SimplePanel, 250
SimpleText, 250
sizeof(), 225
Sorted, 262
SpeedButton, 241
Standard, 239
StartFrame, 248
StaticText. 243
StatusBar, 249
Step, 246
StepBy(), 246
Steplt(), 246
Stop(), 248, 252
StopFrame, 248
StringGrid, 241
StrToFloat(), 70
StrToInt(), 50
Style, 32, 262

TabControl, 245
TabOrder, 262
TabStop, 262
Tag, 262
TApplication, 136
TButton, 199
TCanvas, 197
TDateTimePicker, 248
TEdit, 99
Terminate(), 136

268

Text, 38, 262


THotKey, 247
Time, 249
Timer, 251
TimeString(), 234
Title, 262
TMouseButton, 203
ToDouble(), 100
Tool Bar, 244
, 262
Tony's Button, 255
TPopupMenu, 238
TrackBar, 246
Transparent, 248, 263
TShiftState, 203
TString, 143
TUpDown, 247

V
VertScrollBar, 263
Visible, 263
VisibleButtons, 252

W
WeekNumbers, 249
Width, 178, 263
Win 3.1, 28
Win32, 27, 244
WindowState, 176, 263
Windows 95, 19
Windows 98, 19
Windows NT, 19
Workshop, 175

13
248
13
>
22
16
76
44
57, 73
43
61
43

17

29
161
54


76
77
77
77
78
78

I
44
161

42
20
30
18
14
16
16
16
189
83
95

197
47, 98
139
121, 131
123
124
124
122
121
121, 168, 256
13
18
20
117
37

20
14
14
14, 57
17
13
14, 53
54
137
55
17, 29
36
36
18

{)
27
44
24
46
72
182
132, 182
137
138
127
133

105
156

37
165
167
170
205
169
170
167
170
167
168
168
20

115
238
115
116
98
125
123
192
146
159
18
)
29
OLE 253
36
59
30
30
59

29
157
269


()
161
72
142
17
202
52
51
56
104
151
52
83
106
15,148
148

15
94

29
25, 240
239

25
25
27
25
26
26
25
, 18
238
239
42
142
119
141
139
61
43
86
61
45
61
45
168
43
143
42
97
38

270

108
56
56
36
39
49
30, 240

166
169
113
33
149
56
251
14
58
- 129
56, 91
89
33
57
119

16
104
215
- 17
33
38

143
135

175
33
29
29
49
29
29
264, 266
17
30
30
73
17

143
27
75


()
27
116
94
184

79
20
157
76
29
29
155
32
237
237

73
70
56
50
50

36

45
43
45
50
63
85
14
/
129
103
Borland C++Builder 5 20
21
21
21
21
21

12
75
234
57
57
234
231
220
138
57
109
103
109

153
183
189
153, 188
153

111
70
66

32
32
32

17
17, 29

13
++ 15

271


,



,

BHV -




. (. ), . , 32.
. 955-90-13. E-mail: dess@aha.ru
World Wide Web: http://www.dess.ru/

272

Вам также может понравиться