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

..

C++Builder 6


2003

004.43
32.973.26-018.1
87

..
C++Builder 6. .:
2003 . - 1152 : .


- C++Builder 6 C++Builder 5 4.
C++Builder, - ,
ADO, InterBase Express, dbExpress, , COM, CORBA, M1DAS, . ,
, , ,
, , ,
. C++,
C++Builder API Windows ( 570 ), C++Builder,
, .
, -
, ,

.., 2003

ISBN 5-7989-0239-0 (. )

, 2003



C++Builder 6, 5, 4?
?

19
19
20
21
21
22

1. C++Builder 6
23
1. C++Builder . . 25
1.1 -
25
1.2
27
.
29
1.4
31
1.5
32
1.6
33
1.7 C++Builder 6 Borland. . 35
1.8 : C++Builder 6?
37
1.9 - C++
42
1.9.1
42
1.9.2 C++
: . . . . 42
1.9.3
43
1.9.4
47
1.9.5 ,

49
1.9.5.1 ,
49
1.9.5.2
51
1.9.5.3 ,

52
1.9.5.4
53
1.9.5.5
56
1.9.6
57
1.9.6.1
58
1.9.6.2
59

2.
C++Builder 6

63

2.1 () C++Builder
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5
2.1.6
2.1.7
2.1.8 C++Builder
2.1.9
2.2
2.2.1
2.2.2
2.3 C++Builder

63
63
64
65
67
69
70
72
75
76
77
77
79
81

C++Builder 6
2.3.1 C++Builder,
81
2.3.2
85
2.3.2.1
85
2.3.2.2
85
2.3.2.3
88
2.3.3
89
2.3.4 To-Do List
92
2.3.5 ,
95
2.4
97
2.4.1
97
2.4.2
97
2.4.3
98
2.4.4
98
2.4.5
99
2.5
100
2.5.1
100
2.5.2 Parent Owner
101
2.5.3
102
2.5.4
103
2.5.5 Object TreeView
103
2.5.6 ,

105
2.5.7
109
2.6
109
2.7
113
2.7.1 Code Insight
113
2.7.2 ClassExplorer
115
2.7.3 , . . . . . . . 116
2.7.4 C++Builder
OpenHelp .
118
2.8
120
2.8.1
, . . . . 120
2.8.2
122
2.8.3 ,
125
2.8.4 Watch List
126
2.8.5 Evaluate/Modify
129
2.8.6
130
2.8.7
132
2.8.8 Debug Inspector
137
2.8.9 , OutputDebugString
139
2.8.10
140
2.8.11 ,

140
3. C++Builder
145
3.1
145
3.2
146
3.2.1

146
3.2.2 Label, StaticText, Panel . 148
3.2.3 Edit, LabeledEdit MaskEdlt
150
3.2.4 Memo RichEdit
155
3.2.5 ListBox, CheckListBox,
ValueListEditor, ComboBox, ComboBoxEx
160
3.2.6 StringGrid
168
3.3 ,
170
3.3.1 , . . . 170


3.3.2
UpDown CSpinEdit
3.3.3
DateTimePicker, MonthCalendar, CCalendar
3.3.4 Excel FIBook
3.4

3.5
3.5.1
3.5.2 Tree View Outline . .
3.5.3 Windows
List View
3.6
3.6.1 . .
3.6.2 DrawGrid StringGrid
3.6.3 Shape
3.6.4 Chart
3.6.5 Chartfx
3.6.6
ProgressBar CGauge
3.7 , ,
3.7.1
3.7.2 Button BitBtn
3.7.3 SpeedButton
3.7.4 RadioGroup,
RadioButton GroupBox
3.7.5 CheckBox CheckListBox
3.7.6 TrackBar ScrollBar.
3.7.7 HeaderControl Header
3.7.8 Timer
3.8
3.8.1 MainMenu
3.8.2 PopupMenu
3.8.3 HotKey
3.9
3.9.1
3.9.2 Panel,
GroupBox, Bevel, ScrollBox, Splitter
3.9.3 TabControl,
PageControl, TabSet, TabbedNotebook, Notebook
3.9.4 ToolBar PageScroller .
3.9.5 CoolBar ControlBar
3.9.6 StatusBar
3.9.7
3.10
3.10.1
3.10.2
OpenDialog, SaveDialog, OpenPictureDialog, SavePictureDialog . .
3.10.3
DriveComboBox, DirectoryListBox, FilterComboBox,
FileListBox CDirectoryOutline
3.10.4 FontDialog
3.10.5 ColorDialog ColorBox
3.10.6
PrintDialog PrinterSetupDialog
3.10.7
FindDialog ReplaceDialog

171
172
173

. .

. .

175
176
176
176
182
186
186
187
189
189
194
196
198
198
199
202

203
205
. . 206
207
208
209
209
214
215
217
217
219
221
. . 224
227
229
230
237
237
. .

239
244
246
248
250
252

C++Builder 6

2.
4.

257
259

4.1
4.2
4.3
4.4
4.5


259
ImageList
262
ActionList
265

268
ActionManager,
ActionMainMenuBar, ActionToolBar, CustomizeDlg
271
4.5.1 ActionManager
271
4.5.2
275
4.6 ApplicationEvents Application . . . 279
4.7 Screen , . . 285
5. . . .
5.1 Windows . . .
5.1.1
5.1.2
5.1.3
5.1.4
5.1.5
5.1.6
5.1.7
5.1.8
5.1.9 -
5.2
5.2.1 Align
5.2.2
5.2.3
5.2.4 . . . .
5.2.5
5.3
5.3.1
5.3.1.1
5.3.1.2 , ,

5.3.2
5.3.2.1
5.3.2.2
5.4
5.4.1 Drag&Drop . . .
5.4.2 Drag&Doc.

5.4.3
5.5
5.5.1
5.5.2 :
5.5.3

5.5.4
( MDI)
5.5.5

5.6
5.6.1 Print
5.6.2 , . . .

289
289
289
291
291
296
298
299
301
302
305
308
308
311
312
314
314
315
315
315
318
321
321
322
325
325
328
335
340
340
344
346
349
351
354
354
354


5.6.3 Windows
ShellExecute
355
5.6.4 Printer
355
5.7
357
5.7.1
357
5.7.2 : . . . 364
5.7.3 .ini
369
6.
373
6.1
373
6.1.1
373
6.1.1.1 Image
373
6.1.1.2
375
6.1.1.3
375
6.1.4 TPicture,
TBitmap, TIcon TMetafile
376
6.1.2 Image Editor
378
6.1.2.1
378
6.1.2.2
380
6.1.2.3
381
6.1.2.4
382
6.1.3
384
6.1.3.1
384
6.1.3.2
385
6.1.3.3
386
6.1.3.4 Brush
390
6.1.4 . . . 391
6.1.5
395
6.1.5.1
395
6.1.5.2
396
6.1.6
398
6.1.7 OnPaint
405
6.2
407
6.2.1
407
6.2.1.1
407
6.2.1.2 , MessageBeep PlaySound . . . 408
6.2.2
411
6.2.3 Animate
418
6.2.4 MediaPlayer
421
7. , ,
7.1
7.2
7.2.1 execlp
7.2.2 spawnlp
7.2.3 WinExec
7.2.4 CreateProcess
7.2.5
ShellExecute
7.3
7.3.1
7.3.2 API Windows
7.4 Windows
7.4.1 C++Builder
7.4.2
7.4.2.1 SendMessage, PostMessage Perform
7.4.2.3
7.4.3
7.4.4

427
427
. 427
428
429
432
434
436
,439
439
441
441
441
443
443
443
445
448

10

C++Builder 6

7.5 DDE
7.5.1
7.5.2
7.5.3
7.5.3.1 -
7.5.3.2 -
7.5.3.3
7.5.3.4
7.5.3.5
7.6
7.6.1 TThread
7.6.2
7.6.3
7.7 OLE
7.8
7.8.1
7.8.2
7.8.3
7.8.4 ActiveX
7.9 -
7.9.1 - C++Builder 6 5
7.9.2 Word
7.9.3 Word
7.10 CORBA
7.10.1
7.10.2 CORBA C++Builder

8. C++Builder

450
450
450
453
453
454
455
457
457
459
459
463
468
472
478
478
480
486
491
495
495
499
505
510
510
510

. . 513

8.1 - CLX
8.2
8.3
8.3.1
8.3.2
8.3.3
8.3.4
8.3.5
8.3.6
4 DLL
8.4.1 DLL
8.4.2 DLL
8.4.3 DLL
8.4.4 DLL
8.5
8.5.1
8.5.2

513
517
519
519
522
524
527
530
534
539
539
540
541
545
547
547
548

3.
9. .
9.1
9.1.1
9.1.2
1
9.1.2.1
9.1.2.2 -
9.1.2.3 /
9.1.2.4
9.1.3 C++Builder
9.2 Database Desktop

553
.

555
555
555
558
559
559
*>0
60
J60
562

11

9.2.1
562
9.2.2
564
9.2.3
566
9.2.3.1 Validity Checks
566
9.2.3.2 Table Lookup
566
9.2.3.3 Secondary Indexes
567
9.2.3.4 Referential Integrity
569
9.2.3.5 Password Security
570
9.2.3.6 Table Language
571
9.2.3.7 Dependent Tables
571
9.2.4
571
9.2.5
Database Desktop
572
9.3
, ,
573
9.3.1

573
9.3.2 Database Desktop . . . 574
9.3.3
BDE Administrator
576
9.3.4 SQL Explorer
577
9.4 , . . . . 579
9.5 Table

580
9.5.1 ,

580
9.5.2
583
9.5.3
580
9.5.4
586
9.5.5
588
9.6
591
9.7 . . . . 594
9.8 Session
598
9.9 BatchMove
600
9.10
602
9.10.1
602
9.10.2 (lookup fields)
603
9.11
605
9.11.1
605
9.11.2
606
9.11.3
607
9.11.4
609
9.11.5
611
9.11.6
611
9.11.7
614
9.11.8
615
9.12
617
9.13
'
622
9.14
623
9.14.1
628
9.14.2 ,
628
9.14.3
630
9.14.4
631
9.14.5
633
9.14.6 BDEClientDataSet
638

12

C++Builder 6

10.

641
10.1 SQL
641
10.1.1
641
10.1.2 Select
642
10.1.2.1
642
10.1.2.2
644
10.1.2.3
646
10.1.2.4
646
10.1.3
648
10.1.4
649
10.1.5
650
10.1.6 Query
651
10.1.6.1
651
10.1.6.2 Query
653
10.1.6.3 Query,
655
10.1.6.4 Query
656
10.1.6.5 , Query UpdateSQL . . 657
10.1.7 SQL
661
10.2
664
10.2.1 . . . 664
10.2.2 , Database
665
10.2.3 SQL Monitor
667
10.2.4
669
10.3 InterBase /
670
10.3.1
670
10.3.2 IBConsole
670
10.3.3 Interactive SQL
674
10.3.4 Views
677
10.3.5
677
10.3.5.1
677
10.3.5.2
679
10.3.5.3
681
10.4 Microsoft ActiveX Data Objects (ADO). . . 682
10.4.1 BDE ADO
682
10.4.2 ADO
683
10.4.3 ADOConnection,

686
10.4.4
689
10.5 InterBase InterBase Express (IBX)
693
10.5.1 InterBase Express (IBX)
693
10.5.2 IBDatabase IBTransaction
695
10.5.3 IBTable, IBQuery, IBStoredProc
697
10.6 dbExpress
698
10.6.1
698
10.6.2 SQLConnection
699
10.6.3 SQLTable, SQLQuery,
SQLDataSet, SQLStoredProc, SQLClientDataSet
701
10.7 MIDAS
703
11.
11.1 Decision Cube
11.1.1
11.1.2
11.1.3 DecisionPivot
11.1.4 DecisionGraph

705
705
705
709
711
713


11.2
11.3

12.
12.1 WWW
12.2 , WWW
12.3 HTML
12.4
12.5 Web CGI
12.6 Web C++Builder
12.6.1 Web
12.6.2
12.7 CGI DLL ISAPI
12.8 HTML
12.8.1
12.8.2
12.9 HTML
12.10
12.10.1
12.10.2
12.10.3
12.11
12.11.1
12.11.2
12.12

4.
13. C++
13.1
13.2

13.2.1 #include
13.2.2 #define #undef
13.2.2.1
13.2.2.2
13.2.2.3 #undef
13.2.3 : #if, #endif, #ifdef, #ifndef,
#else, #elif
13.3
13.3.1
13.3^2
13.4
;
13.4.1
13.4.2
13.5
13.5.1
13.5.2
13.5.3 const
13.5.4
13.5.5
13.5.6 inline
13.5.7
13.5.8
13.6
13.6.1 ,
13.6.2
namespace using

13

....

713
720

729
729
730
. . 730
733
739
741
741
743
745
746
746
748
750
754
754
757
761
765
765
768
771

773
775
775
776

776
777
777
778
780

781
782
782
784
785
785
785
788
788
792
793
794
795
797
797
799
800
800
801

14
,

C++Builder 6

13.7
803
13.7.1
803
13.7.2
803
13.7.3 , Assign . . . 805
13.7.4
807
13.7.5
808
13.7.6
808
13.7.7 ()
809
13.7.8 (?:)
810
13.7.9 sizeof
810
13.7.10 typeid
811
13.7.11 (&) (*)
811
13.7.12 (::)
811
13.7.13 : (.) (->)
811
13.7.14 (<<) ( )
812
13.7.15
815
13.7.16
816

13.8
819
13.8.1
819
13.8.1.1 if
819
13.8.1.2 switch
820
13.8.1.3 goto
821
13.8.2
822
13.8.2.1 for
822
13.8.2.2 do...while.
824
13.8.2.3 while
825
13.8.2.4 : break, Continue,
return, Abort
826
13.9
827
13.10
831
13.10.1
831
13.10.2 VCL Exception
832
13.10.3 try ... catch
833
13.10.4 EAbort Abort
836

14. C++
14.1 ,
14.2
14.3
14.4

14.4.1
14.4.2 AnsiString
14.5
14.6
14.7
14.8
14.9
14.9.1 /
14.9.2 /
14.9.2.1
14.9.2.2
14.9.2.3
14.9.2.4 /,
14.9.3 / C++
14.9.3.1
14.9.3.2
14.9.3.3
14.10

839
839
842
843
845
845
848
850
852
854
857
858
858
859
859
860
863
866
869
869
872
875
877


14.10.1
14.10.2
14.10.3 ,
14.11
14.11.1
14.11.2
14.11.3 C++
14.12
14.12.1
14.12.2 -, ,

14.12.3 -, ,
14.12.4
14.12.5 , ,

14.12.6 ,
C++Builder
14.12.6.1
14.12.6.2
14.12.7

15.
C++Builder
15.1
15.2
15.3 Tools
15.4
15.5 Code Insight
15.6
15.7
15.8
15.9
15.9.1 ,

15.9.2
15.9.3
15.9.4
15.9.5 Directories/Conditionals
15.10

877
879
880
882
882
883
885
886
886
. . . .

888
891
892
895
898
898
901
902

905
905
906
907
909
912
913
915
917
920
920
922
923
924
926
928

16. , C++, C++Builder, API Windows . . 931


16.1
931
16.1.1
931
16.1.2 ,
. . . . 933
16.1.2.1
933
16.1.2.2
937
16.1.2.3 Format
938
16.1.2.4 TFloatFormat TFloatValue

941
16.1.2.5 FormatFloat
942
16.1.3 ,
944
16.1.3.1 doserrno, errno _sys_nerr ,

944
16.1.3.2
944
16.1.3.3 EDOM, ERANGE
946
16.1.3.4 _matherr matherrl
946
16.1.3.5 assert
948
16.2
948

16

C++Builder 6

16.2.1 ,
948
16.2.2
949
16.2.3
952
16.2.4
954
16.2.5
956
16.3
958
16.3.1
958
16.3.1.1 char * . . . . 958
16.3.1.2 ,
SysUtils.hpp
960
16.3.2
964
16.3.3
970
16.4
971
16.4.1
971
16.4.2
973
16.4.2.1
973
16.4.2.2
974
16.4.2.3 AnsiString
980
16.5
984
16.5.1 ,
984
16.5.2 , FILE . . 986
16.5.3 , . . . 989
16.5.4 /
993
16.5.5
999
16.5.6
1001
16.6
1012
16.6.1
1012
16.6.2 exec... spawn
1013
16.6.3 API Windows

1019
16.6.3.1
1019
16.6.3.2 ShellExecute
1020
16.6.3.3 FindExecutable
1022
16.6.3.4 WinExec
1023
16.7
1023
16.7.1
1023
16.7.2
1028
16.7.2.1 ShowMessage ShowMessageFmt
1028
16.7.2.2 MessageDlg, MeasageDlgPos CreateMessageDialog
1028
16.7.2.3 TApplication->MessageBox
1032
16.7.2.4 InputBox InputQuery
1035
16.7.2.5 SelectDirectory, LogihDialog, LoginDialogEx
1036
16.7.3
1037
16.7.4 C++ C++Builder
1040
16.7J5 API Windows
1045
16.8 Windows
1048
16.8.1 PostMessage
1048
16.8.2 SendMessage
1049
16.8.3 RegisterWindowMessage
1050
16.8.4 Perform
1050
16.8.5 WMJJSER
1051
16.8.6 TMessage
1051

17., , , ,
17.1

Align
Bitmap
BoundsRect
Brush

1053
1053

1053
1056
1057
1058

JJ

Canvas
Charset
ClientHeight
ClientOrigin
ClientRect
'
ClientWidth
ClipRect
Color
CommaText, DelimitedText, Delimiter. QuoteChar
ComponentCount
Componentlndex
Components
ControlCount
Controls
CopyMode
Cursor
Delimiter
DelimitedText
DragCuraor
DragKind
DragMode
Font
Handle
Height
Height
HelpContext
HelpKeyword
HelpType
Imagelndex
Left
Mode TPen
Name
Parent
ParentColor
Pen
PenPos
Pitch
Pixels
QuoteChar
Shortcut
Size
Style TPen
Style TBrush
Style TFont
Tag
Top
TransparentColor
TransparentMode
Visible
Width

17.2

Add
Assign
Assign
BeginDrag
BringToFront
BrushCopy
Chord
ClassName
Clear
ClientToParent ParentToClient
ClientToScreen
CopyRect
Delete
Draw
DrawFocusRect
Ellipse
Exchange
FillRect
FindNextControl
FloodFill
FrameRect
Free
Hide
IndexOf
Insert

1059
1059
1060
1060
1061
1061
1062
1062
1064
1064
1064
1064
1065
1065
1066
1068
1069
1069
1069
1069
1069
1070
1071
1071
1071
1072
1072
1073
1073
1073
1073
1074
1075
1075
1075
1076
1076
1076
1077
1077
1077
1078
1078
1079
1079
1080
1080
1080
1080
1082

1082

1082
1083
1083
1084
1085
1086
1087
1087
1088
1088
1089
1090
1090
1091
1091
1092
1092
1093
1093
1094
1095
1095
1096
1096
1096

18

C++Builder 6
LineTo
LoadFromClipboardFormat
LDadFromFile
Move
MoveTo
ParentToCHent
Pie
PolyBezier PolyBezierTo
Polygon
Polyline
Rectangle
Refresh
Repaint
RoundRect
SaveToClipboardFormat
SaveToFile
ScreenToClient
SelectFirat
SelectNext
SendToBack
SetBounds
SetFocus
Show
StretchDraw
TextExtent
TextHeight
TextOut
TextRect
TextWidth
Update

1097
1097
1098
1098
1099
1099
1099
1100
1101
1101
1102
1102
1103
1103
1104
1105
1105
1106
1106
1106
1107
1107
1108
1108
1108
1109
1109
1110
1111
1111

17.3

1112

17.4

1124

17.5 ,
VCL
C++Builder 6

1145
1150

On Change TCanvas
OnChanging
OnClick
OnCreate
OnDblClick
OnDragDrop . i
OnDrlgOver
OnEndDrag
OnEnter
OnExit
OnKeyDown
OnKeyPress
OnKeyUp
OnMouseDowr OnMouseUp
OnMouseEnter
OnMouseLeave
OnMouseMove
OnMouseUp
OnPaint
OnProgress
OnStartDrag
VCL
AnsiString
Set
TBitmap
TBrush
TCanvas
TColor
TCursor
TDragMode
TFont

TPicture
TPoint
TRect
TStringFloatFormat
TStringList . . . . '
TStrings

1112
1112
1112
1113
1113
1113
1115
1116
1117
1117
1117
1118
1119
1120
1121
1122
1122
1123
1123
1123
1124

1124
1126
1129

1132
1133
1136
1136

1136
1137
1138
1139
1140
1140
1141
1'142


C++Builder , 5, 4?
C++Builder 6.
: C++Builder 6,
5, 4?. , , , C++Builder
. C++Builder - , , .
, , , Windows. ,
Windows C++Builder 6 -
, Windows, Linux.
C++Builder , ,
. .
, C++Builder
Delphi, Borland. , . C++, C++Builder, ,
Object Pascal, Delphi. C++
Object Pascal. , C++Builder
, Delphi . , .
C++Builder, Delphi.
C++Builder Delphi ,
, ( )
C++. , .
C++ Pascal. C++Builder , Delphi.
C++.
, C++Builder ,
Delphi.
C++Builder ,
. , C++Builder 6, 5, 47,
, , , ,
. C++Builder. , ,
. C++Builder , . , , C++Builder , ++ilder .
, .
C++Builder, C++Builder 6,
5 4,
( C++Builder 4 5).
, C++Builder 6 :
- ,

20

C++Builder 6

, , ,
. , C++Builder 6.
: ,
, .
.
COM, CORBA, MEDAS. , , , C++Builder. , , , , .

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

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

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

21

, , , C++Builder 6
, ,
.
, , [3].
, . , C++Builder, (
, ) . C++Builder , .


, ,
C++Builder ... C++Builder 4 5 :
.
. .
, C++Builder 6: - , ( , dbExpress), , ,
. C++Builder
, . : 4 , 7 , , 12
( , ). , COM, CORBA MIDAS, ,
DLL,
, , . , C++Builder 5. ,
C++Builder 4, . , , ADO InterBaseExpress,
, - .
?
, .
, ,
[1] [3].
, , .


, .
,
.
.
, C-H-Builder, , . 1, - .
C++Builder -

22

C++Builder 6

2 ( ,
, , ).
C++Builder ,
. , C++, ( 1),
2 . C++Builder , .
- , .
, C++Builder - ,
C++.
1 2 5 5.15.3 5.5 ().
3,
. , 4 (
), .
, 9. ,
.
,
, , .

C++Builder. , , 1,
, , ++ilder 6. . 2, C++Builder . , , C++Builder.
3 4,
C++Builder . , C++Builder 6, , , ,
, . .
, , , .
.

, ,
Borland , C++Builder 6.
, , . ,
. , . , , ,
.
, .
, .

C++Bd
ulier
1

C++Builder


C++Builder 6

C++Builder

1
C++Builder

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

1.1 -
- ( )
( )
. Windows,
, , , ..
. . -
, .. , -
: , ,
. Windows - (
).
, - , . - . ( )
. , , , .
.

. . . , ,
, -
.
. , , , .
.
-, . ,

26

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

, , . . 1.1. . . .
, .

27

C-^Builder

. 1.1


. - . . ,
, .
,
, . , , , . , , , , . ,
, .
,
. - , . .
.
.
, ( ), .
, , . (, )
.
: ( )
, .

1.2

, ,
, , .
. , , , ,
.
80-90% . , .

28

.
API. , , , .
,
. (,
Windows 3.x Windows 95, Windows 98 Windows XP) -
.
. , , . ,
.
, .
, , , Visual
Basic C+4-Builder Delphi
Borland. CASE- (Computer Aided Software Engineering
).
, , . C++Builder .
( Integrated development environment IDE) C++Builder. ( ), . , . , C++Builder. .
. , . , , - .
.
,
C+4-Builder , , .

- , ,
- . , , , , , .
, , , . ,
.
, , ,
, .. , ,
.

C++Builder

29

C++Builder
, .
, , .
, ,
, .
, , C++Builder . , .
, , . C++
. . , C++Builder
. . , .
, .
C++Builder . , , , , - , : , , , , , , , , , , , . , , .
, ,
. , , , .. , . ,
- - .
-
, , - RAD Rapid Application Development.
, C++Builder.
, C++Builder , . C++Builder
, .
C++Builder , . C++Builder , , .

1.3

. , , ,
, .
().

30

, , ,
, .
. , , .
,
. , ,
SQL, . 10.1 . 10.
. - ,
- , . , , - . .
, ..
, , . , , . 7.
, . . , . , , ,
. , (Windows, Unix, Solaris .), .
, Windows, (, ), Clipboard,
Windows, DDE . , . DDE ( . 7.5 . 7), ,
.
(Object Linking and Embedding) OLE 1. , , , , Word Excel.
OLE 2, . , , , ..
. OLE C++Builder . 7.7 . 7.
COM (Component Object Model) . ()
, . ,
: , , . DCOM. . ,
. ,
.
. 7.8 7.9 . 7.
DCOM , C++Builder . ,

C++Builder

31

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

1.4
DCOM
.
/. ,
,
. , . , - ,
. , /
-
. , , . 10.3.5 . 10. .
/
. /
. -
. , ,
.
. .
.
. (middlware) . -. .
, , - .
. . . - .
. , .
-, .
.
, . . .
, . : - . ,
, . .

32


: DCOM, CORBA, MIDAS, MTS,
OLEnterprise, J2EE, TCP/IP, HTTP, XML.
.
.
DCOM . 1.3
. 7.8. CORBA
. CORBA
, , VisiBroker, CORBA.
.
,
. CORBA
. 7.10.
MIDAS , : DCOM, CORBA, OLEnterprise, HTTP,
TCP/IP, MTS . MIDAS . . 9.14 10.7.
Microsoft Transaction Server (MTS)
. ,
Windows. .
TCP/IP HTTP, , , , 12.
HTML, Web.
Java - , , , . , , . Java
.
, , -. -
, Java.
, , . Java . - , .
, Java, J2EE (Java 2 Enterprise Edition). , , .
, , ,
, .
, . , , , , ,
, Web. .

1.5
, ,
. ,., . Unix

C+-Builder

33

. , ,

.
.
.. , Windows, Sun Solaris, IBM AIX ..
Java , . - .
, , ,
.

DOS , .

HTML. Web.
. , , , . ,
HTML, XML (Extensible Markup Language)
. , Windows, , ,
. , WWW, Web. XML, HTML,
.
.
. XML

. , , HTML, .
XML , . XML , SOAP, UDDI, WSDL, ebXML .
Java XML.
Java XML .

1.6
, Web Services . Web Services
Web. Web Services
. , ,
XML. WSFL
Web Services Flow Language.
Web. ,
UDDI Universal Description, Discovery & Integration.
.
WSDL (Web Services Description Language).
. ,
, .
2 C-H-Builder 6

34

, WSDL,
,
SOAP Simple Object Access Protocol ( ). SOAP, ,
SOAP.
SOAP, ,
, .
XML.
SOAP , , UDDI Disco (Discovery protocol ), .
,
Web Services, -. business-to-business 2. , , , , -.
, ,
-.
. Web Services.
Microsoft .NET. .NET # (-).
Java, , - , , Delphi, C++Builder, Visual J++ Microsoft.
.NET Web.
,
business-to-business. , . ASP.NET , ADO.NET ADO ,
Windows Forms . SOAP WSDL.
, , Visual Studio.Net. Visual C++, Visual Basic, C# .
.NET , : COM, CORBA
Object Management Group J2EE Sun. .NET
, .
CORBA,
IDL. .NET
.
. ,
.
, Web , Windows Web. Web , Windows Web. , Web ,
API, .. .
, . , ,
, . -

C++Builder

35

, C++Builder 6.
, , Java, XML, MTS , , . ,
, , .

1.7 C++Builder
Borland
, ( ), C++Builder 6.
- , , :
Windows , , .
( ) ,
. , C++Builder DOS, Windows . :
Windows , , ,
, Windows.
. .
, .
, , , Microsoft Office, Word, Excel .
- ,
Windows, Linux.
> .
Windows, Windows.
, , , , DLL, ActiveX ..
C++Builder , .
. , , , .
+-(-Builder . Borland, , C-H-Builder. ,
C++Builder Delphi. -
, C++Builder.
Delphi C++Builder, ,
, . Delphi
C++, Object Pascal. C++Builder Delphi, . -

36

'

Delphi , C++Builder ,
Delphi, , Delphi. , C++Builder 5
Delphi 5, , Delphi 6. C++Builder 6 , Delphi 6.
++ilder C++Builder . ,
Object Pascal (, ) C++. C++ Object Pascal, , , C++Builder Delphi .
- C++ , Object Pascal.
C++ . , C++Builder.
Borland JBuilder
Java.
. 1.4. A JBuilder , C++Builder, Java, C++.
Borland, C++Builder 6 Delphi 6,
Kylix.
, Linux.
Windows .
Kylix , C++Builder
Delphi. , C++Builder.
CLX C++Builder 6, .
Kylix , Linux.
C++Builder Kylix, ,
C++Builder 6 - ,
Windows, Linux.
C++Builder 6, VCL,
CLX (cross-platform component library).
, Kylix. Linux C++Builder.

Borland . , ,
Borland AppServer 4.5.
J2EE (Java 2 Enterprise Edition . . 1.4
Java) CORBA. , J2EE CORBA,
.
AppServer Java, JBuilder.
C++Builder,
AppServer.
, C++Builder 6 Borland, ,
. Windows C++Builder - .

C++Builder

37

1.8 :
C++Builder ?
, C++Builder 6 ? , .
. , (, ,
) , C++Builder.
, .
C++Builder ,
, C++Builder , .

-
, C++Builder 6 , Windows, Linux. C-H-Builder 6 - CLX.
C++Builder VCL, Windows, Linux. , CLX ,
VCL. , Windows Linux. , CLX ,
VCL. , , CLX VCL.
- .
. 8.1.

C++Builder 6 ,
ActionManager, ActionMainMenuBar, ActionToolBar, CustomizeDlg. ,
, C++Builder 4 5. , ,
. ,
( 26, 60), ,
. . . 4.5.

VCL
11 : dbExpress, DataSnap, BDE,
DotaSnap, WebServices, WebSnap, COM+, Servers ( , Office2k), IndyClients, IndyServers, IndyMisk
.
Tabs .

38

: LabeledEdit
, VaiueListEditor " = ", CoiorBox , ComboBoxEx ,
AetionManager, ActionMainMenuBar, ActionToolBar, CustomizeDlg .
,
, .
.
, C++Builder,
( ) ,
:
TControi HelpKeyword HelpType, .
HelpContext ( TWinControi).
. 5.1.9 . 17.
,
Windows, Linux.
TControi ClientToParent, . (. . 17.2) .
TStrings (, , TStringList) DeliraitedText, Delimiter QuoteChar,
(. . 17.1).
TLabel ( TCustomLabel) OnMouseEnter
OnMouseLeave (. . 17.3 . 17),
. , , .
TColor :
clGradientActiveCaption (Windows 98/2000
),
clGradientlnactiveCaption (Windows 98/2000
),
clDefault . , , .
TCheckListBox Header, HeaderBackgroundColor, derColor, -
(. . 3.2.5).
TCustomListBox (TListBox, TCheckListBox)
Style , , (. . 3.2.5). AutoComplete,
.
TCustomAction TMenuItem
AutoCheck,
Checked
(. . 3.8.1).
OptionsEx
, Windows C++Builder (. . 3.10.2).

C++Builder

39

Align alCustom (. .
Align . 17, . 17.1).
OnMouseWheel, OnMouseWheelUp OnMouseWheelDown TWinControl TControl.
VCL . , , , .
, , .


C++Builder 6 dbExpress. , SQL . dbExpress
DLL , , , .
.. dbExpress . 10.6.

BDEClientDataSet, SQLClicntDataSet, IBClientDataSet ClicntDataSet.
. . 9.14 10.6.3. SharedConnection LocalConnection .
,
. ,
.
.


C++Builder 6 : .
, COM, CORBA, XML DataSnap.
Web-
, . , - (business-to-business), BizSnap
SOAP/XML.
DataSnap ( MIDAS) . , , .Net BizTalk Microsoft ONE Sun Microsystems. DataSnap
C++Builder , , SOAP, XML, COM, CORBA TCP/IP
.
- Web- . DataSnap , DB2, Informix, InterBase, MS SQL Server, Oracle Sybase.
WebSnap Web-
C++Builder -

40

. , WebSnap, Web-, .
WebSnap Web- ,
, DreamWeaver
FrontPage, JavaScript, VBScript Web.

XML
C++Builder 6 XML.
, XML - .
XML Document Object Model (DOM). XML Data Binding New New Items. XML, DOM.
XMLDocument, XML .
XML . XML ClientDataSet.
C++Builder 6 XML Mapper ( Tools). XML
, .
TXMLTransform, TXMLTransforraProvider, TXMLTransformClient.


, WebServices, WebServices, SOAP
(Simple Object Access Protocol). XML HTTP . WebServices
, , .
Web.
ISAPI, NSAPI, CGI, Win CGI,
Apache. WebBroker WebSnap.
Web WebSnap.
Internet, , View | Toolbars | Internet.
WebSnap New
Items, File | New | Other.
C++Builder Web, Tools | Web App Debugger.
, WebBroker WebSnap. , Web.
HTML .



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

C++Builder

41

. .
, , .
. . 2.5.5.
, ,
Preview, HTML. HTML , Web . . . 12.3.
Code Insight (. . 2.7.1).
.
: , , . HTML .
.
(. . 2.1.7). , DataSource,
, . DataSet,
. ,
, , .
. .
,
(. . 15.6).
Internet, .
WebSnup Web, Web . ,
- , , C++Builder.
C++Builder 6.
C++Builder. , , , ,
, , . C++Builder
.
(, , ).

, . , ,
C++Builder.
C++Builder 6,
5 4. , , C++Builder 6 . , C++Builder 6, 4 5, , ,
.
C++Builder.
C++Builder 6 : Standard , Professional

42

'rasa

, Client/Server /, Enterprise
. C++Builder 6 3 :
Standard, Professional, Enterprise.
.
Enterprise . .
,
( ) .

1.9 -
C++
1.9.1
C++
. , , , .
13 . 13.1, , , , . . 13 14, -
. , ,
, , - . C++ . , [1] [3].
C++ , .

1.9.2 C++
C++ (, , ,
, ) .
main ( WIN32) WinMain Windows. . C++Builder
, .
-
.
, . .
- ,
.
.
, , C++Builder . . , . , , .
.

.

C++Builder

43


, , ,
.., , .
.. .h.
, , (). .
, . , .
,
.
. () . . , .obj.
, ,
.. .

1.9.3
C++Builder ,
. WinMain (
Windows, , main). , .
. , , . -
, C++Builder. ,
, - , .
, C++Builder Project | View Source. ( ):
//
//
linclude <vcl.h>
#pragma hdrstop
// ,
USERES("Projectl.res") ;
USEFORMC'Unitl .", Forml);
USEFORM("Unit2.cpp", Form2);
//
// main
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
try
Application->Initialize();
Application->CreateForm ( classic! (TForml) , sForml) ;
Application->CreateForm( classid(TForm2), &Form2);
Application->Run();

44

1
catch (Exception ^exception)
{
Application->ShowException(Sexception);
}
return 0;
(

, " # ' .
(. . 13.2).
#include,
.
. , . , #include <vcl.h>
vcl.h, , C++Builder.
USERES
USEFORM. , ,
. . USEFORM, .
C++Builder
USEFORM , . , (, Unitl.cpp),
.

WinMain.
. , Windows
. API Windows (API Windows Windows, ). WinMain
( ). , , .

WinExec. . ShowWindow.
WinMain ,
.
WinMain ,
. Application->Initialixe
. Application>CreateForm .
, .
.
Application>Run
. , .
WinMain try,
catch. , , .
, , catch. Application>ShowException.
. 13, . 13.10.

C++Builder

45

WinMain return(O),
0.

. , USEFORM Application>CreateForm,
. .
- , , , , , . , - (, ). - . , .
, . ,
, , C++, - .
, , , Form2
,
Y.
WinMain :
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR S, int)

S, .
Application->CreateForm( classid(TForm2), &Form2);

if <S[0] =- '')
Application->CreateForra( classid(TForm2), 5Form2);

, Projectl
Projectl Y, Form2 .
.
, , . ( MessageBox . . 16, . 16.7.2.3):
if

(Application->MessageBox(
" ?",
" ",
MB_YESNOCANCEL + MB_ICONQUESTION) == IDYES)
Application->CreateForm(
c l a s s i d ( T F o r m 2 ) , SForm2);

, . 1.2. ,
.
. 1.2

'J

|^']|

46

, , ,
.. , , .
.
, . , - , , C++Builder File | New | Other Unit.
, . , , , - , , .
_.._______*.
.
, ,
. .

, , extern (. . 13 . 13.4.2). , , , (. . 13,


. 13.5 1).

, , , begin, ,
. Unitl.cpp,
Unitl.h (
. . 1.9.4).
include "Unitl.h"

Unitl.h, WinMain
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR S, int)

.. S, ,
WinMain :
begin(S);

begin .
begin :
void begin(String s)
(
//
)

, ,
, .
: Projectl,
Project2 .. .
. .

C++Builder

47

*-~~------~-~-"--...-. - , , C++Builder .
Project!, .

1.9.4
, . : , ,
. , ( TLabel) (
TButton). ,
.
:
//
#ifndef UnitlH
#define UnitlH
//
linclude <Classes.hpp>
^include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//
// ( , include),
//
//
// TForml
class TForml : public TForm
{
published:
// IDE-managed Components
//

' ,

TButton *Buttonl;
TLabel Labell;

void _ fastcall ButtonlClick(TObject *Sender);


private:
// User declarations
//
// , , ,
// ,
public:
// User declarations
//
// , , ,
//
fastcall TForml(TComponent* Owner);
);
//
extern PACKAGE TForml *Forml;
//
// , , ,
// ;
//
//
#endif

:
/

^include <vcl.h>

48

1
#pragma hdrstop
include "Unitl.h"
pragma package(smart_init)
pragma resource "*.dfm"
//
// ( , include),
//
// Forml
TForml *Forml;
//
__
__
// Forml
fastcall TForml::TForml(TCOmponent* Owner)
: TForm(Owner)
(
// ,
// '
)
//
// ,
//
// ;
// ,
// ,
// ,
void
fastcall TForml::ButtonlClick(TObject *Sender)
(
Closed ;

. . , C++Bullder
include, , , , , ,
. . include .
.
TForml. :
published
, , private , public
.
published : Buttonl TButton
Labell TLabel. ButtonlClick Buttonl. ,

published, C++Builder . , , . private public , , . , C++Builder public, . , private, . ,
, C++Builder public, () TForml.
PACKAGE, .
, , ,

C++Builder

(. . 1.9.5)
, .
.

Forml, . ,
- . , .
, , , ,
, .
C++Builder :
Unitl, Unit2 ..

, , - , , C++Builder .
, Unitl, Unit2, Unit3, .

1.9.5 ,

1.9.5.1 ,
, , . ,
: But ton 1 TButton Label 1
TLabel. , ,
, , , .
:
,-

#ifndef UnitlH
define UnitlH
//
#include <Classes.hpp>
include <Controls.hpp>
linclude <StdCtrls.hpp>
lindude <Forras.hpp>
class TForml : public TForm
{
published:
// IDE-managed Components
TLabel *Labell;
TButton *Buttonl;
void
fastcall ButtOnlClick(TObject *Sender);
private:
// User declarations
// Fl Ch6
void
fastcall Fl(char C h ) ;
char Ch6;
public:
// User declarations
fastcall TForml(TComponent* Owner);
// Chi F2
// ,
//

50

1
char Chi;
void
fastcall F2(char Ch) ;
};
it.

______________

__

extern PACKAGE TForml *Forml;


// Ch2 F3
II ; Ch2 ,
II extern;
II F3 ,
II
char Ch2;
void. F3 (char Ch) ;
fendif

:
//
include <vcl.h>
pragma hdrstop
include "Unitl.h"
Ipragma package(smart_init)
#pragma resource "*.dfm"
TForml *Forml;
//
fastcall TForml::TForml(TCcmponent* Owner)
: TForm(Owner)
(
]

II

// Ch3 F4
// ; Ch3 ,
// extern;
// F4 ,
//
char Ch3;
void F4(char Ch)
(
Forml->Labell->Caption = Forml->Labell->Caption + Ch + Forml->Chl;
(
//
void
f a s t c a l l T F o r m l : : F l ( c h a r Ch)

(
Labell->Caption = Labell->Caption + Ch + Chi;
)
ii

void
fastcall TForml::F2(char Ch)
(
Labell->Capticn - Labell->Caption + Ch + Chi;
]
//
void F3(char-Ch)

Forml->Labell->Caption = Forml->Labell->Caption + Ch +
Forml->Chl;
)
//
void
fastcall TForml::ButtonlClick(TObject *Serfder)
{
// Ch4
char Ch4;
Chi = '-';

C++Builder

51

Ch2 = 'A';
Ch3 = '';
Ch4 = ' ;
Labell->Caption = "";
Fl(Chi);
F2(Ch2);
F3(Ch3);
F4(Ch4);
Labell->Font->Color = clRed;
(
Button 1 Click Button 1 : F1-F4, : ChiCh4.
. ,
. ,
, .
TLabel Caption
. F1-F4 ,
, Ch, ,
Chi, .
TForml::ButtonlClick, ChiCh4 " - " , "", "" "", Caption Label!, , FlF4, . .
Font Labell. , Color - .
TForml::ButtonlClick.
1.9.5.2
,
. - . , TForml
TLabel * L a b e l l ;

Labell - TLabel.
, , . 14, . 14.7,
, , . , C++Builder , .
(- -) .
( '-' ">', , .. >) (.).
, .
, , F1 F2. Labell>Caption.
: Caption Labell. To Caption
(*Labell).Caption. (*Labell) ,
.
,
C++Builder . . , ,

52

. 14, . 14.7, , - , " - > " .


. . , Font , . , , Color
. Labell,
Labell->Font>Color (. TForml::ButtonlClick).
: Color Font, Labell.
. , , ', Hide,
. - Labell ,
Labell->Hide();

1.9.5.3 ,

, ,
. ,
, - -. -
C++Builder . .
1.9.5.1 F1 F2 ,
Ch2, Ch3 F3 F4 . ?
( TForml),
. , ,
(::). Fl, F2
ButtonlClick TForml::Fl, TForml::F2
TForml::ButtonlClick. ,
TForml. F3 F4, , .
, ,
.
(, F1), . ,
, F1,
F1,
Forml::Fl. ,
, ( , ).
.
,
. , .
C++Builder . , ,
, , ,
.
, ,
, , . , , ,

C++Builder

53

, , . F3 F4 Forml>Chl.
Caption Labell
Forml>Lahell>Caption. Forml , .
, .
TForml::Fl, TForml::F2 TForml::ButtonlClick
Labell .
, ,
TForml ( ,
MDI),
, . ( Ch2 Ch3)
. , ( ), , . .. TForml
. , , , ,
- ,
. , ,
.
, , , . -
fastcall. He , , . - .
, . ,
, (
- ).
.
- (::).
-
fastcall.
- - - .
, ,
- () - () (>) ( )
(.).
1.9.5.4

, ..
.
, .
.
, "{}". ,
- , -

54

. - , . .. ,

"}". ,
. -
, ,
,
.
:
i n t i = 1, k = 4 //
I
i n t i = 5, j = 2; //
....
{

'

// j,
// i

int i = 7;

// i

...

// j, k
// L

)
...

// j,
// i

, . . ,
. , - .
i
, , 7 .
(auto) ,
static. :
static int i = 7;

. , - . , .
,
, , , , .
C++ , -
. " : : " .
,
.
, ,
i = : :i + 1;
i i.
, , ,
.

C++Builder

5]>

,
. Unitl Unit2 Unit2 ,
Unitl. Unit2 , Unitl, .. - . ,
, ( ) Unit2
extern. , Unitl
int al - 10;

Unit2 ,
extern int a l ;

, , #include Unitl.h Unit2, .


, . Unitl a l , Unit2 #include
Unitl.h,
extern ( al), Unit2 a l , U n i t l . , al Unitl.
Unitl Unit2 a l .
.
. , , .
,
. Unitl
F, Unit2 :
#include Unit2 Unitl .h
Unit2 ( )
F
F
Unit2.
F Unitl , , Unit2 .

, static. :
static void F(void);

.
, , . .
( )
extern.
Ch2 Ch3.
, , . .
,

56

#include ,
. F3.
, , .
.
. F4.
( ), private,
. ,
,
, .
F1. , , private.
, public,
, #include .
, , . F2.
, , protected . , protected, ,
- .
, ,
.
, (
Ch4 TForml::ButtonlClick), , .. . ,
., . Ch4
TForml::ButtonlClick .

static.
, , . ,
, ( ) extern.
,
, , , .

"::".

. 13, . 13.6.
1.9.5.5
:
. ,
. . :
void Fl(char Ch);

C++Builder

57

Ch ,
. , :
Fl(Ch2);

Ch, Ch2. Ch Ch2 . Ch, Ch2, .


.
,
. , , -
. . -, ,
. -, . -
, , , . , , ,
. -, , , .
, , - .
, '&'.
:
void Fl(char SCh);
,
. ,
. Ch, ,
, , .
,
.

. 13.5.2, . 13.

1.9.6
-
.
, C++Builder.
. , ,
. 2. .
- ,
, , ,
. -
,

. , , , .

58

1.9.6.1
,
, .. , . () () :
<> *<>;

, TLabel
():
TLabel

*Lab;

, .
. . ,
, , , , :
i f ( L a b = = 0 )

... ;

, .
C++ NTJLL, . :
if (Lab == NULL)

...;

. :
Lab = Label1;

Lab Labell. : Lab, Labell . , Labell>Capti Lab->Caption .


, , void.
:
void *Lab;
void
. . , ,
. , , Labell (
) Lab>Caption. Caption
((TLabel *)Lab)>Caption, Lab " TLabel".

, , .
,
, -.
.
, ,
, , .. C++
.
, TControl :
TConrrol *Contr;
. ,

C++Builder

59

Contr = Labell;

.
Contr . , TControl.
, , , Name . - .
, Contr>Caption
: 'Controls::TControl::Caption' is not accessible., , Caption TControl .
, TControl, , :
((TLabel *)Contr)->Caption

: Contr
TLabel. .
, ,
.
.
. . new. new . ,
(Owner). , (Parent) , .
, .
:
TLabel *Labl - new TLabel (Forml);
Labl->Parent - Forml;
Labl->Caption = " ";
Labi -
TLabel new - Forml. Labi : Forml :
,
TLabel .
new.
1.9.6.2

, , -. C++Builder . , Sender , .
? , - , , Buttonl
OnClick, , Sender
. ,
Buttonl.
. . -

60

.
, , .
. . . 5, . 5.1.8 5.3.2.2 ,
Enter . , , , , .
. 5.2.5
, . TWinConrol
, ,
, . ,
. . 5.4.1
Drag&Drop .

. . 3, . 3.10.7
. , .
.
.
- , ,
, .
. ,
.
, . Sender,
, C++Builder TObject *Sender, ..
TObject. TObject,
. 18.4, C++Builder.
, . - Sender , . , , ,
( Caption) Labell
: " ...". ,
, Name.
TComponent. Sender. :
Labell->Caption = " " +
((TComponent *)Sender)->Name;

((TComponent *)Sender)
Sender TComponent.
Name, . : , , .., TComponent.
,
Sender , . , , :
TComponent *Obj = (TComponent *)Sender;
Labell->Caption="npoH3oiimo " + Obi->Name;

C++Builder

61

Obj TComponent
, Sender. Obj .
, Sender ,
-,
, . ,
, Sender, TWinControl ( ), TWinControl ScaleBy.
:
((TWinControl

* ) S e n d e r ) - > S c a l e B y ( 1 1 , ID) ;

,
Sender. ClassName,
TObject
ShortString

fastcall

ClassName 0;

ClassName ShortString, . ,
Labell->Caption = Sender->ClassK'3me () ;
"TButton', Sender TButton.
ClassName -
. ,
if

(String(Sender->ClassName[))

==

"TLabel")

( )
TLabel.
ClassNamels,
TObject :
bool

fastcall ClassNamels(const AnsiString string);

true, string. :
if (Sender->ClassNameIs("TLabel") )

, -,
. ScaleBy, TWinControl. , Sender, TWinControl (, TLabel, TWinControl),
ScaleBy .
, , .
, ,
, ,
, . , ScaleBy, ,
TWinControl.
InheritsFroin,
TObject , , .
:
bool

fastcall InheritsFrom(TClass aClass);

62

true,
aClass, . TClass,
classid:
classid(classType)

, , TWinControl.
, , ,
Sender, TWinControl, :
if (Sender->InheritsFrom(

classid(TWinControl)))

ScaleBy
:
if (Sender->InheritsFrom(
classid(TWinControl)))
((TWinControl *)Sender)->ScaleBy(11,ID) ;

ClassParent, TObject,
, .
:
TClass

fastcall ClassParent()

(.. TObject), NULL.


ClassParent, , . ,
, TObject , Sender.
TClass ClassRef= Sender->ClassType();
ListBoxl->Clear();
while(ClassRef != NULL)
(
ListBoxl->Items->Add(ClassRef->ClassName());
ClassRef = ClassRef>ClassParent() ;
}
, Sender TButton, ListBoxl :
TButton
TButtonControl
TWinControl
TControl
TComponent
TPersistent
TObject

C++.
, . 13 14 .
C++Builder
. .


C++Builder 6
2.1 ()
C++Builder
2.1.1
(Integrated Development Environment
IDE, ) ,
, . , , ,
, , .
, . , ,
, , .
.
C++Builder, C++Builder 6
Windows | . C++Builder,
. . 2.1.
. C++Builder, . . 2.1
Enterprise.
.

2.1.

| ,

C++Builder 6

' *

* '
,

... I

-Ii

!
*

^ (*
-|.

Y"

kL
'"*" "

"."*""

" - _' :' " "' " ** * " " ""


' *'""'' "- "

'

64

.
( )
, . . , .
C++Builder, , Windows, - .
Visual Component Library VCL, cross-platform component
-library CLX. , C++Builder 6, VCL.
, .
, .
: (Object TreeView), (Object Inspector).
. , .
, .
. ,

. . 2.1 - .
.

2.1.2

.
.
File () , , , .
Edit (, )
Windows Clipboard,
.
Search ()
, .
View () ,
.
Project () , ,
.
Run ()
, ,
, ..
Component () , , .
Database ( ) .

C++Builder 6

65

Tools () , , , (Image Editor), , .. ,


, , C++Builder,
( . . 15.3).
Window () C++Builder 6. ,
.
Help () ,
C++Builder .
, . C++Builder , ,
.
. , . ,
, .
.
.

2.1.3
C++Builder 6
. 2.2. CORBA . , View | Toolbors . C++Builder 5 , . 2.2, ,
(. 2.2 ) CORBA (. 2.2 ) . C++Builder 4 (. 2.2 ).
, ,
.
. 2.1 ,
, .
. 2.2 . 2.1 . C++Builder 6 , - , ,
, .
. 15,
. 15.1.
. 2.2.

C++Builder 6:
(),

(),
(),
CORBA ()

3 +4 Builder 6

&

* II

.
)

u a'

)
-af

66

2.1.

File

New | Other

File Open
File Reopen

, ,
.
Reopen,

File Save As
File Save
(Ctrl

File Save All

( )

File Open Project


(Ctrl F l l )

Project | Add to Project


(Shift-Fll)

Project | Remove from Project

Help

s)

C++Builder Help

View Units
(Ctrl-F 12)

View Forms
(Shift- F12)

View Toggle Form/Unit


(F12)

File

New Form

Run
(F9)

Run

.
,

Run Program Pause

Run Trace Into


(F7)

>


CPU.

C++Builder 6

67

Run | Step Over


(F8)

View | Desktops |
Save Desktop

View | Desktops |
Set Debug Desktop

File | New | Other | WebSnup


WebSnup Application

WebSnup
Web ( Delphi 6)

File | New | Other | WebSnup


WebSnup Page Module

WebSnup Web ( Delphi 6)

File | New | Other | WebSnup


WebSnup Data Module

WebSnup Web ( Delphi 6)

Tools ] Externol Editor

Web, Edit Internet ,


Tools | Environment Options
( Delphi 6)

File -| New | Other | Mulfitier


CORBA Object Implementation

CORBA

Edit I CORBA Refresh

,

IDL

Edit | Use CORBA Object

IDL ,

CORBA

2.1.4
(. 2.3) (Visual Component Library VCL). .
. , , , ..
. Vtl>| Su lecii | Dab Access! Dola Conlrol

I Ir

I A I * E| JJ IS tf i@

. 2..

L i y a J i o c ! B u t 1 ADO | InterBase | WetSavices 1

68
C++Builder 6 :
Standard

Additional

Win32

32- Windows 95/98 NT

System

, , ,

Data Access

, C++Builder 6 ,
, BDE

Data Controls

dbExpress

dbExpress ( C++Builder 6)

DataSnap


, (
C++Builder 6 C++Builder)

BDE

Borland Database Engine BDE ( C++Builder 6,


Dato Access)

ADO

Active Data Objects (ADO) ActiveX, Microsoft OLE DB ( C++Builder 5)

InterBase

InterBase, Borland Database Engine (BDE)


Active Data Objects (ADO) ( C++Builder 5)

WebServices

Web, Web SOAP ( C++Builder 6)

InternetExpress

InternetExpress Web
( C++Builder 5)

Internet

Web

WebSnap

Web,
, ( C++Builder 6
C+4-Builder)

Fast Net

( C++Builder 5)

Decision Cube

( C++Builder)

QReport

Dialogs

, .

Win 3.1

Windows 3.x, Windows 3.x

Samples

, ,

ActiveX

ActiveX

COM+

, +,
+

C++Builder 6

--

69

Servers

( C++Builder 6,
C++Builder 5 , Office2k)

indyClienfs

Internet Direct (Indy), -


Delphi, C++Builder, Kylix ( C+^Builder 6)

IndyServers

Internet Direct (Indy) ( C++Builder 6)

IndyMisk

Internet
Direct (Indy) ( C++Builder 6)

nterBase Admin InterBase


Office2k
Office97

VCL
Microsoft ( C++Builder 5,
Servers)

C++Builder 6 ,
, . . , C++Builder 6
,
, Tabs. .
, .
- 0, , . , , . ,
, .

.
-.
, .
, , . ,
,
- .
, ,
, ,
. F1,
.
. , , : MainMenu, Button
.. C++Builder
"", , TMainMenu, TButton.
C++Builder .

2.1.5
C++Builder . Windows. , .

70

, Windows, , Windows . , , , , . , - , .. , , . 5.1.3 . 5.


.
, . , , .
- . C++Builder
.
- ,
. F1. F1,
.

2.1.6
C++Builder
, . 2.4 . ,
C++Builder 5, ( 2.4 )
(ClassExplorer),
. 2.7.2. ,
,
, ,
ClassExplorer ( Tools | Environment Options,
ClassExplorer, Automatically Show Explorer).
)

)
Fi

mmE H ,

" i

<

S3 rnKIi
TFu

ii

m2(TC mpc.

-A)* * CllO

class TForRii ; BuJtlic TI


lstiefl:
/; -/,
piivat e :
// Use*
public
fi tJsez
fasto

...1

11

Modfied

. 2.4. ClassExplorer () ()

C++Builder 6
, . 2.4 .
(Unitl.cpp)
(Unitl.h).
C++Builder 6. C++Builder 5 , ,
() Open Source/Header File.

C++Builder 6

71

, . Diogram (), C++Builder 6, , . 2.5.5. .


. , .
.
C++ ( . 2.4 , class, public .). ( . 2.4 #include).
( . 2.4 // IDE-managed Components // User
declarations).

, . , . . 2.4 : Unitl.cpp Unit2.cpp.
- ,
, Close Page.
( View | New
Edit Window
) .
.
. ,
Modified , , ,
, . .
, C++Builder,
. - ( , ..) F1. ,
C++Builder [3], , , .
.
File | Open HTML, (.
. 12). HTML Code. C++Builder 6 Preview. Web,
HTML.
HTML. ,
HTML,
html Editor.
HTML, . . Delphi ,
. ,
.
, ,
Internet HTML (. . 15.7 . 15).

72
2.1.7

(Object Inspector) C++Builder , .


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

) b)

2]

JFom
i TFarni
Fr ] Everts |
1

PIILUHS'

E a d d o t le
burder ' i d h

' [biSystomMenu-j
t

1 f-dbl
U

roptroi

F tnt

CfciftuJlh

1EE

Cilnr

dBlrftce

Er

1|||||||||||||||

0F
Zhddwi

QnCon Irainfdt
OnConl&clPopi

BCc BcWindrj^Text
C i cCaplronTe^t
lu;tiveBorder
De
UlriactrveBorder
D
clippWoikSpace
Dr
IHighlighl
Dr

Foimi TFormi
_^J
Properties Everts j
T
i ClnActivata
j*
DtConFr 1 iFrrnrr^aP 1
OnUct
W u
"

OnCieale
FotrrCie-
OnDblClick
OriJeactivate
0 nDestrov
OrOockDrop ;
Or^lockOver
OrCiagDfOp
On[iiagOvet
All shown

jj
:

(Properties) (. . 2.5 ),
, .

( . 2.5 ). . , Caption () ,
, , .
, , Color (),
.
, (. . 2,5 ). , Color
clBtnFace ( ) clWindow ( ).
, .
(., ,
Font . 2.5 ). , ,
.
Font. ,
, Color (), Height (), Name ( ) .
Style (), .

, , , trne
fsBold (). , true false
.
, . ,
,
, .
(Events) (.
. 2.5 ). , -

C++Builder 6

7^

. , - ( ), OnCreate. . -
OnCreate , . , .
, :
void

fastcall TForral::FormCreate(TObject 'Sender]


. , C++Builder.
"{" "}" .
, ,
, , OnActivate . OnCreate (
. 2.5 ). OnActivate, .
.
,
. F1.

. ,
. View.
(. . 2.6) .
. . Toggle : , , . , None
(, , ).
, : ... hidden. , . 2.5
: All shown.
. 2.6.

/ Action
v Drag, Drop and Docking
/ Help and Hints
w input
>/ Layout
Legacy
*/ Linkage
w Locale
w< Locaiizabie
v> Misceianeous
*/ Visual

Toggle
None

74

, , Arrange
: by Name , by Category .
. " + " ,
, .
.
:
.
, C++Builder 5, ,
.
C++Builder 6
, .
, C++Builder, , ,
. . ,
, - . ,
3.8.1, MainMenu, . , ,
ImageList.
, , . C++Builder 6, -, , ,
. , " + " . , . , . . 2.7 MainMenul, , , ImageListl,
. ,
, .
.
. 2.7


() ()

6)
PmpeiWj ]E,enls|
Left
192

E3SIK!" "
Pmp-il- E,pnl
S"i-{ i
Ed( pO

I ^i limdtic
1

^1 1

MLdIT Right

JHMHU
1

In i g r L 11

H7tihHnii"3
P

Irraq^Li ti

:,.:-

1
r t p r itet

I l l n si"
11'1 SJT

O r A c l i afi
OnCanRestse
OnClick

1: e

OnCloseQuery
OnCuiis-trainedl

Ih
2hdJn

II\r- i|
"

OnConleytPcpt,

-1
'"'},

OnCieate
All shown

C++Builder 6

75


(. . 2.7 ). , , .
, , , C++Builder 5. . . 15.6.

2.1.8 C++Builder
, C++Builder, Drag&Doc
. :
ClassExplorer. (. 2.4 ).
, : (Project Manager), (Watch List)
.
:
,
.
, , Dockable . , . , .
,
.
.
,
( . 2.4 ). - . .
ClassExplorer ,
, , , .
, , .
.
, .
, ,
. , , .
, .
Drag&Doc . (. 2.1), , 6 , . -
(, ) , ,
, , ,
, .
, . 2.3
. , . . C++Builder
. - .
,
. - , ,

76

. ,
- . , , . 15.1 . 15.

2.1.9
:
, , ClassExplorer.
, . ,
, . , , - .
. , C++Builder. .
, C++Builder , . , , .
, .

, . Tools | Environment Options. Preferences (. . 15.19 . 15.10, ) Autosave options Project desktop. C++Builder . .
- , , , .
C++Builder.
C+4-Builder 5 . ,
View | Desktops | Save Desktop (.
. 2.1 . 2.1.3). ,
. . ,
.
(. . 2.1 )
. , - ,
, .
View | Desktops . ,
, . , .
, :

(
Z-,
, )

C++Builder 6

77

(, , )
(, , Dockable)
, View | Desktops | Delete.
,
, .
View | Desktops | Set Debug Desktop
(. . 2.1 . 2.1.3). , . , .
, , : - , Watches, (. .
2.8.4), Watches. Watches. , , Watches
, , , Watches. .

2.2

2.2.1
( )
() C++Builder. .
: , - .
.
1. C++Builder, , Windows
| . C++Builder , - , . File | New
Application. No C++Builder,
2. , , TButton
Standard ,
( )
. , C++Builder
Button 1.
3. Standard Label ( ).
. C++Builder Lafaell.

78
4.

, . 2.8 .
, .

. 2.8
()
()

>

. * Buttonl .
Caption (),
Buttonl (,
C++Builder) .
6. Lahell, .
,
Font (),
Style () true fsBold ().
7. Caption Labell, ,
.
,
Caption Labell . . OnClick. , .
8. Buttonl , , (Events), OnClick (
) . . OnClick ( ) : Buttonl . :
void
fastcall TForml: : Buttonldick (TObject *Sender)

(TForml),
(Buttonl) On (Click).
9. , ,
(. 2.4), . , .
10. Lahell. :
L a b e l l - > C a p t i o n = " !";

, :
void.

fastcall TForral: :ButtonlGlick (TObject "Sender)

Labell->Caption

" !";

C++Builder 6

79

, , . " = "
, , , , . : Lahell>Caption. , Caption Label!. (. . 1.9.5.2): ,
">": " - " ">",
. .
Caption !.
Label 1,
, , . , , , .
, Enter (, ) . : . . , , , Enter, .

, . ,
,
Sort by Name .
,
- ,
- ( , ). ,
C++Builder, , , . , ,
. , ,
(. . 15.5 . 15).
, . .
Run | Run,
(. . 2.1.3 . 2.1), F9.
, ,
,
. ,
(. 2.8 ). : , , . ,
.

2.2.2
C++Builder
Windows. -
, - . ,
, , . , :
, , ..

80

Edit. , ,
Label, Panel, , . , .
. Additional LabeledEdit,
Standard Panel, Button Lahel . , . 2.9 .
, C++Builder 6.
, LaheledEdit . ,
LabeledEdit Edit Standard .
. 2.9 .
. 2.9

HBuiider 6
()
()

Labeli
Panel I

LabeledEdit - .
, 1, 2, , ,
,
. " + " .EditLahel Caption .
, . C++Builder 4 5, .
Caption , , .
Caption . Text ()
" 1 " .
, Bevellnner
BevelOuter, ( bvLowered
bvRaised) . , BevelInner = bvLowered BevelOuter = bvRaised.
' , . 2.10 .
.
:
Panell->Caption = LabeledEditl->Text + " * " +
LabeledEdit2->Text + " = " +
FloatToStr(StrToFloat(LabeledEditl->Text) *
StrToFloat(LabeledEdit2->Text));

C++Builder 6 :
LaheledEditl LabeledEdit2 Editl Edit2.

81

C++Builder 6
)

. 2.10
)

()
()

jl-25
2

|248.8

1.25-248.8-311

. :
Caption Panell , . .
,
Editl Text.
" * ". " + " .
" = ". .
, , . FloatToStr(...), . . . , ,
. StrToFloat(),
. '*', StrToFIoat,
.
. - . (
Windows) File | Save All. (. . 2.1 . 2.1.3).
. , (. 2.10 ) .
, C++Builder . , . C++Builder 6 .

2.3 C++Builder
2.3.1 C++Builder,

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

82

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

(.)

C++Builder . WinMain,
.


(.)


,
. XML.


(.res)

, : , .. .
(Image Editor).


(.)


, .
,
.


(.h) ,
. .

(.dfm)

, C++Builder . .
(.).


C++Builder,
(.hpp)
lnclude\VCL.

(.bpg)

, C++Builder
.


(.bpl .bpk)

C++Builder
: .bpl , .bpk , .
C++Builder : , .
, .
Autosave options/Project desktop (. . 15.10).



(.dsk)

(.-,
, , .
.~df, .~cp, .-h)
- , .

C++Builder 6

83

(.)

. , -(
, ,
, DLL, OCX ..

(.), .
(.obj)

(.)

,
DLL.


(.tds)

, .


(.?)

, il (.ilc, .ild, .ilf, .ils),


,
.

, , Windows, C++Builder:

(.)

Windows,
C++Builder.

Windows
.
(.wmf, , )
( ) ., .h, .dfm, .bpr, .res. , , , ,
. C++Builder .
.
WinMain, . ++ilder . ,
, , . . 1.9.3.
,
.. C++Builder . , Project | View Source.
.

,...,

C++Builder : .dfm, . ,h.


.dfm
, , ..
C++Builder, C++Builder 5, .dfm .
,
View os Text. -

84

. . View As Form.
. , ++ilder 5, ,
: .
, Text
DFM. .
, .
, ., , .
.h .
C++Builder
.
- , , . C++Builder 6
.
C++Builder ,
. Open Source/Header File.
, , . ,
.
, . , (
), , , , .
.
. , - , File | New | Other New Items New Unit.

..

. . .

, , , , , , . , ,
,
. .

,
. ,
. , .obj, .res, .tds, .il?, .-*. .tds, ( ).
. . C++Builder . (packages)
.
( ) ,
, . . 8,
. 8.5
. , , ,
, , . .

C++Builder 6

85

. .

Project | Options,
Packages
Packages Built with runtime packages.
Defou.lt,
.

, .

2.3.2
2.3.2.1
.
-*-~~

( Windows). .

, , , , , C++Builder , .
.
,
, .
.
Windows
.
2.3.2.2
. : File | New | Application C++Builder 6 File | New
Application C++Builder 5 4. File | New | Other ++ilder 6 File | New
(. . 2.1 . 2.1.3). New Items
( ), . 2.11.
(Object Repository) , . - , , . . . 2.6.
, . , Application (), New (). Application
. .
, Projects (. 2.12).

86
. 2.11
New
New Items

DaifiModule j -" j w/eoCoLumml j pt nap j \ 'ebLervices j


New | ActiveX | M MM | Fn |2 j F a n , Dialogs | Project! |

Batc.l Fa
li Ffe
i CLX
Ap
p
c
lao
tin
ComponentCW
onszo
e
on
lilao
P
anelM
C
ad
n
rio
a
ilrdCA
prto
p
c
tin
o
e
u
lllPanel

. 2.12
Projects
New Items

Data Modules j 6u$iness j Web Documents ] WebSnap j WebServices


New j ActiveX j Multitier j Pfoject2 J Forms j Dialogs Projects
Application
MDl
Wizaid Application

SDl
Applicalion

Uelp

,
View Details (). (. 2.13) Description . , Win2000 Logo Application , , Windows 2000.
, , . , . 2.12 2.13 Win2000
Logo Application, .
, , , , , ..
MDl Application. , MDI ( Word, Excel
.. . . 5.5.4 . 5).
Application Wizard. , (Wizard) C++Builder,
, , , ..
, -

87

C++Builder 6
. 2.13
;-= Projects
New Items
; View
Details

DataModdes | Bushess
New | ActiveX ] MuBl
Name
j Desc|ipt|Qr>

Web Documents | WebSnap | WebSeivices I


Plqedi
I PrencB I Forms | Dialogs

M
^Appc
ilato
i n Wziard Appc
ilao
tin Wziard rfom demonstrao
tin V/ziard D
LLodI.iBod
MDIAppcilao
tin Standard MDIappc
ilao
tin frame.
30 0. Boli
ESDI Appcilao
tin GenereSOk^e appc
ilato
in.
300.. Boli
!W
j m200
rj LogoAp Appcilao
tin that meest m
m
nium Wd
yiows2UUO Logo requre
iments. 30 0.. Borj
Swni95/9BLogoA. Appcilao
tin that meest m
m
nium V/mdows95/9B Logo reque
ime. 30 0.. Borl

copy

J A
Help

.
- , .
,
, . , .
, -
, . ,
.
.
, , .
, , .
. , , - , ,
. ,
. C++Builder,
, . , , C++Builder, , , , - , .
C++Builder , Win32 Windows
DOS. New (. 2.11) Console Wizard.
,
.
C++Builder 5 New Control Panel
Application Control Panel Module, ,
Windows. Control Panel Application , . . , Control Panel Module. DLL ,
Windows. $, .cpl.

88

TAppletApplication. , TAppletModule, , , Appletlcon , . , ,


OnActivate, .
,
Install Control Panel Applet. ,
Launch Control Panel. Uninstall Control Panel .
2.3.2.3
,
.
-

, .

, , ,
C++Builder,

. . ,
, ,
.
,
, .
..-.

.,

- , , C++Builder no .
Project!, . , . ,
, Project!.

File | Save All.


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

-~.~

.-..-.


. C++Builder .

C++Builder 6

89

,
C++Builder Unitl, Unit2 ..? , .
Unitl, , . , , Unitl,
Unit5. , ,
, .
, - . ,
Projectl Unitl ?
- .

-.

___

, U . ,
PEditor], UEditor]. , ,
.

, .
.
File | New Application. .
File Save All.
File | Open Project. ,
File | Reopen. (. . 2.1.3).
, , , , .

C++Builder , . , Tools | Environment
Options. Preferences Project desktop Autosave options ( . . 15.10).
C++Builder
, C++Builder. ,
.
. , - .
. 2.6.

2.3.3
(Project Manager) .
, . ,
, - , ,
DLL, , .
View | Project Manager. ,
<No Project Group>. - , . 2.14 .

90

ProjectGroupl, . . , ,
" + " . , . ,
, ,
. ,
.
. 2.14
. ()
()

IJ^^j

Ren o^ t

Palh

Fibs

- ["| tSrcupi
D^rogiamFilBS^oilan^CB jilderb1 Proie
- ~1 PMESS1
F\Tettt'\MESSAGES
J FMessi.cpp FATest\MESSAGES
PMessi.res
FATestAMESSAGES
- f] U1Me si cpp F.\Teels\MESSAGES
J UIMets" FMeslsVMESSAGES
FATeslsWESSAGES
Z J Frrmi
-

i j E B e e [ FATeslsVMESSAGES
t J LLMessi . FATeslsVMESSASES
FATe3ls\MESSA6ES
ZJ Foim2

|11
|sr.Tsr - Fie

il
1

Nw

Rum" -

-id 'a'e

Fath

J . | -__

Me l 'vMES^r.Ej
F UedAMESSABES

_J PMe -1 cpp F Mests\MESSAGES


J PM -1 r- FVTestsVMESSAGES
J U1HE rr1 CPPh \Ttss
l\MESSAGES
4 Jy ME1 CPPFUesslVMESSAGES
- ^ PMes$2 exe FUeslsWESSASES
J FMe 2rpp F\Tesls\MESSAGES
F\Tesls\MESSAGES
J PMe 2
t Lj UIMe ilcpp F UeslsVMESSAGES

New () .
Remove () ,
. ,
. .,
. , , .
, . ,
Open (), Remove From Project ( ), Save
(), Save As ( ) . , ., , ,
, Add ( ), Remove File (
, ), Save ( ) .
.
, ^
New ,

C++Builder 6

91

Add New Project ( ).


, , Application
.
, , ,
, Add Existing Project ( ). .

(. 2.14 ).
, File Save
As ,
Save Project Group
Save Project Group As. -bpg. File | Open Project File | Reopen, .
, ,
, , .
, .
, , . ,
.
. . .
. , . 2.14
Pmess2. Run | Run F9,
.
. ,
Activate.
. , ,
Activate.
, .
, Windows NT 2000/XP, .
Project | Make All
Projects. . , , C++Builder,
. ,
( ).
Windows 95/98 . C++Builder, C++Builder Windows, , .

92

,
C++Builder 5 -
. . ,
, .. .
. 15.9. .
,
.
, . . ,
, Edit Local Options. (. . 15.9), , . -
, ,
. (. , . 15.15) ,
Right Click to Revert. , ,
, . . Revert All .
, .
Change Override Color _ .
- ,
. , .

2.3.4 To-Do List


To-Do List, C++Builder 5,
, . . , , .
.todo. To-Do List, , View | To-Do List. ,
, . 2.15.
. 2.15
To-Do List

;JP

X!

Action Item
1

Owtiei

Cattery

4 [ l ]

2 ..AUnili.cpp

S items (0 hidden)

items pending

C++Builder 6

93

:
Action Item

, . :

, .
, . ,
. 2.15 ( )
.
Show Completed Items (
), .

:
,
, ( . 2.15
) , . , ,
.

. ,
, , , .
.

Priority

. . 1, 5. 0
.

Module

, .
.

Owner

Category

, :
Add

. (Text), (Category), (Priority)


(Owner).

Delete

.
, Delete.

Edit

.
, ,
. ,
Done. , .

94

Sort

: Action Item
, Status , , ,
, , Priority ,
Module , Owner
, Caiegory
.
, .

Filler

, .
(Categories), (Owners)
(Item types), .
Current project source files , , Open source files ,
, Project To-Do file , .

Show Completed , .
Items
Show ToolTips
When Clipped

, ,
.

Copy As

(Text)
HTML (HTML ).

Table Properties

( ,
) Copy As HTML Table.

Add . .

Add To-Do Item. , Add . , , ,
. , , . :
/* TODO!DONE [nj [-<>] [-<>] : <> */

(/* */).
"//" . TODO .
, DONE. .
.
. . .
,
/* TODO 2 - - : */

, 2,
.

(, TODO DONE).

O+Builder 6

95

ClassExplorer (. . 2.7.2), ,
C++Builder 5, , To-Do List , . ,
.

2.3.5 ,
,
, :
.
, . . 15,
. 15.9.2.
, , . . , , . 8, . 8.5.
(.
).
.
, . , , . 5,
. 5.7.
(
), . , Delphi 5, . 5, . 5.7.1.
, , . , ..
, . , ,
.
Project
Options Version Info
(. 2.16).
,
.

(. . 2.17).
Version Info Include version information in project.
, . ,
, , , .
Include version information in project,
.
Module Version Number , , . , 2.3.1.0.
(. 2.17). Auto-increment build
number .
, -

96
. 2.16
Version Info Project Options

I- ^ ^ -

'

Pascal ] Lhkei [ Advanced Link ei j DiiftUones/Condewtials


Fn | Apphcation j Cofnpiiei j Advanced Compiler } >*
VetBonlnlo | Packages \ Tasrn \ CORBA } CodEQuard
P Include isonn!o(mahofiiipro|ect
Module & Jmbei
Map veiston
!5

M o vastcn
1

Release

Build

|i

V ftu'ei-ncjemeil number
Module aid bulei
CtebuQbuld
^j) nlbuH
F

Hey

Language"
LocalelO; thQ419
""
"'

jValue

OnginaFiwiame
ProduvtName

ProducWersran

1 D00

Commerrt^

, Project | Build All.


.
Module Attributes . , :
Debug Build , Pre-Releose ,
DLL DLL, Special Build , Private Build .
Language ,
, .. .
. 2.17
( 0x0419 ). Language .
Key/Value : CompanyName (), FileDescription ( . 2.17
), FileVersion ( ), InternalName (
), LegolCopyright ( . 2.17
), LegalTrademarks ( ), OriginalFilename ( ),
. 2.17
,
, Windows

J j

2.3.1.0

;




?-*.

.
-

__

C++Builder 6

97

ProductName ( ), ProductVersion ( ), Comments (). ,


. 2.17. ,
, Key/Value. ,
, LegalCopyright, LegalTrademarks Comments, , .

2.4
2.4.1
, .
, , ,
, - . , - , , , .
- ,
.
- --

. _ _

, , ( Nome), C++Bui!der .
, ^ .

2.4.2
.
, File | New Form .
, , - .
, .
Project | Add to Project
.
, (, Forml,
, C++Builder ), : The project already contains a form or
module named Forml
Forml. . ,

. Unltl
, Unitl,
.
.
, ( Name). , File j Save As, .
.

4 C++ Builder 6

98

>-'

, ,
, . - , , .

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

2.4.3
,
, ,
File |
Save As, , , ( ).
.
, , . -,
Windows MS DOS, . , ., ,h .dfm. .
, C++Builder .

C++Builder. File |
Open, , File | Save As. , . ,
. C++Builder ., .h .dfm.

2.4.4
C++Builder
. File | New |
Other ( , C++Builder 6 File | New), New Items ( ), .
Forms (. 2.18) Dialogs ,
.

C++Builder 6
. 2.18
Forms
Nem Items

99

*i
Data Modue
l s | Busn
i ess | Web Documents* I WebSnap ] WebServees
New I ActiveX ] Multitiei | PiojecH Forms I Diabgs j Proiects
i
Dual box

QiickRepoit
Labels

QuiekReport
List

QuickReport Tabbed pages


Master/Detail
Copy

Inherit

Help

,
: , Inherit , ^se . ,
.
. , .
, ,
C++Builder. Inherit _se . 2.6.
, , , , , . . , -
.
. . , C++Builder,
, - , . ,
,
, .

2.4.5

. ,
C++Builder. ,
- , , ,
.
, , . File | Open,
. , Clipboard - .
1'-, Close Page.
.
-
HTML (. 2.1.6).

100

2.5
2.5.1
, .
, ,
. ,
, . . , .
, Shift , , . , Shift, .
. ,
, , .
, , ,
.
, , . View |
Component List. (. 2.19), .
.
Search by name. . , Add to form , . ,
, F1, .
. 2.19

Search bv name:
F~
I TBulton [SldCWs]

UJTCColorGrid [CGRID]

cGaugo [CGAUEES .
I Add to form I

:
Delete.
-
'

Name,
, , ,
, , .

C++Builder 6

101

.
. ,
, . ,
,
, Button7,
, -
Label3.
N18 . , .
, , . . . . , , .

2.5.2 Parent Owner


, ,
.
,
.
, .., , . .
. Parent.
, .
?
. , ParentFont ParentShowHint,
ParentCtl3D.
( true), , ,
. , Left ,

, . , , . Anchors . . 5.2.2 ,
.
,
. Visible , Enabled .
Visible
false, ,
. , Enabled false, . ..
.
,
.

102

,
Parent. Owner . Owner . , ( ) . , ,
,
.
,
, . , , , , .
Z-. ( ) Z- , . , .
, .
Z- .

2.5.3
,
.
. , , .
, ,
. .
,
Clipboard. Clipboard
Edit | Cut Ctrl-X.
, , Edit |
Pasie, Ctrl-V.
Clipboard .

+-I-Builder 6 , 2.5.5.
,
- , .
, Z-.
, Z-
, .
, , . Edit | Bring To Froni Edit | Send To Back.
Z-
. Z-
, Z-
, . : .

C++Builder 6

103

, .
: , . , . , , Bring To Front Send To Back
.

2.5.4
, , ,
, . . ,
TLabel, AutoSize ( ) true
Caption, , Caption . , ,
Z-.
, , , .
, , .
, . ,
, ,
- .
.
,
- , .
- ,
, - , Send To Back, Z-. , , ,
.

, 2.5.5.
, , ,
, , ,
. , . .
Esc. , . Esc
.. , . ,
, Esc.

2.5.5 Object TreeView



+-HBuilder 6 Object TreeView (
), , .
: ,
, ..
, .

104

- ,
.
(. . 2.1).
, View | Object TreeView .
. 2.20 , Panell 13. Panell
Editl, Labell, 12, Buttonl Button2. 13 Edit2 Label2. ,
.
. 2.20

] Fandl
3 Ed*l
3 Label
l
Pane|
H
2
3 Buttonl
3 Button2
1 Panel3
LabeG

- ,
,
.
(. 2.5.4).
, , , . . , , .. . 10.
. , , .
Diagram , .
(. . 2.21). Name - ( Forml . 2.21).
Description . , , .
.
, .
, , .
,
. , .
, .
, ,
. ,
. , -, - .

C++Builder 6
. 2.21
Diagram


, (
Forml . 2.21). Allude connector , .
, Buttonl Edit2, Button2 Editl,
, . 2.21. Allude connector,
, ,
, , .
.
, : Starts with
Ends with . Color Fill color ( ).
, . 9.
- ,
,
( Color). Bring to Front Bring to Back. , . , .

2.5.6 ,

,
. . , ,
(. 2.22). , , , , .
,
. .
, Shift. , , .

106

. 2.22

:
, . ,
, .
.
. , , ,
Name Caption, . , , .., .
- .

, .
Clipboard Edit | Ctrl-C. , , - Clipboard Edit |
Paste Ctrl-V. . .
.
, .
, , ,
, . C++Builder .
Edit | Align , Edit | Size
Edit | Scale .
Edit, Position , ,
( , , ). .
Size ,
, . 2.23. Width
. : No chonge , Shrink 1o smallest , Grow to largest , Width
.
Height .
, . 2.22 . , ,

, , , Shrink to smallest.

C++Builder 6
. 2.23

Width
change
t* Shrink to smallest

Height
f No change
f* [Shrink to smallest!

' ^ Siow to largest

C" G row io largest


Heigh!.

OK

Cancel

Help

Align , , . 2.24. Horizontal


. : No
change , Left sides
(.. ), Center
, Right sides
, Space equally , Center in window .
. 2.24

; Horizontal
j " No change
> ff Left sides
Centers
<~ HigN sides
Space equally
! **" Center h window
|

OK

' ' '


*J
!; Vertical
f* No change
i Tops
<* [inters
f botoms
;
:: " Hess*
C~" Center n
i wnidow \
] Cancel | Hep
l

Verticol . . : No change
, Tops , Center , Bottoms
, Space equally
, Center in window .
.
(Left sides, Right sides, Tops, Bottoms, Center) ( ) ( ) , .
Space equally ( ) .
. , , , ,
. (
) ( ) . , , . .
.
Center in window , . -

108

,
. , ,
, . , , , .
, , . 2.22. ,
, .
.
Center in window, Spoce equally,
,
. ,
, . . Left sides, Cenler, Right sides ,
. Space equally.
. Center in window, No change.
: Center in
window No change . , . 2.25.
. 2.25
, . 2.22,

, . . C++Builder . View | Alignment Palette . , . 2.26. .



. . - , . , ,
.
. 2.26

108

,
. , ,
, . , , , .
, , . 2.22. ,
, .
.
Center in window, Spoce equally,
,
. ,
, . . Left sides, Cenler, Right sides ,
. Space equally.
. Center in window, No change.
: Center in
window No change . , . 2.25.
. 2.25
, . 2.22,

, . . C++Builder . View | Alignment Palette . , . 2.26. .



. . - , . , ,
.
. 2.26

C++Builder 6

109

Edi11 Scale . .
Scaling factor
%. , , 200, 2 .

2.5.7
, , .
,
, .
, Edit | Lock Controls. .
- , Edit | Lock Controls
.

2.6
( Repository) , File | New | Other. New Items (.
. 2.11-2.13, 2.18), C++Builder Borland .
.
.
. ,
- , , . , , , ,
. -
C++Builder,
. .
, (.
. 2.4.4), .. . , , ,
, , , .. .

, , , . 2.2.2 . . Add To Repository.
, . 2,27.
Title
. Description
. , ,

View Details. Page ,
. ,
. .

110
. 2.27

Title

Etwms

]
Ascription
jTupMa *
age

Author,

j j j [

= Select an icon to represent this object:

OK

Cancel

Help

Author . ,
, ,
Brawse.
.
.
File | New | Other New Items (. 2.28).
. 2.28
New Items

*]
New | ActiveX | Multfa |12 | Fotms J Dialogs \ Ptoiecu Dala Modules
j Business | Web Documents j WebSnap j WebSeivces
C D
""]
[!

&

f Inherit

Use

, ,
: ,
Inherit , Use . ,
. . , . - , , , .
Inherit , . , - , , , .
, .
Use . , . , , -

C++Builder 6

111

, ,
( ).
, Inherit , Use .
.
. , (
Project | Remove from Project )
( File | New | Other)
. 2.28 . ( Name), , FCopy ( File | Save As) UFCopy.
, , .
Inherit, FInherit
UFInherit.
Use. .
Visible () true
. , , .
- FCopy, . , FCopy.
.
- , Use. , ,
FInherit. , , Use
, . FInherit . , .
FInherit , , .
, - FInherit. , - , . FInherit.
, ,
, . .
.
(, ) , (, - ),
. ,
.
. FInherit - . ,
C++Builder .
.
( Visible false) (
Enabled false). .
.
. UFCopy , TForm,
, ,
ButtonlClick. UFInherit :

112

2
class TFInherit

: public TForral

published:
// IDE-managed Components
private:
// User declarations
public:
// User declarations
fastcall TFInherit(TComponent* Owner);

77
TFInherit TForml,
3++Builder TForm. TForml ButtonlClick. , UFInherit
.
.
, C++Builder 5,
(. . 3, . 3.9.7). ^
,
.
, . ,
Projed | Add To Repository. , . ,
, .. .
, , File | New | Application, File | New | Other.
, .
, .
, ,
, . , , . ,
, , ,

.
,
. , , Tools | Repository. ,
. 2.29. , New Items
Properties.
. 2.29 . (Add Page),
(Delete Page), (Rename Page) , ,
(Delete Object), (Edit Object)
.
Moin Form ( ). ,
. New Form ( ),
, , File | New | Form.
, (
Projeds), Main Form
New Form New Project. , : -

113

C++Builder 6

File | New | Application


Application New Items.
. 2.29 .

. [Objed: Repository],
, . ,
.
. 2.29

Pages:
Forms
Dialogs
Proiects
Data Modue
ls
1

Web Documents
WebSnap
WebServices
[Object Repository]

QbiectsfiddPage..
Celete Page

Database Form Wizard


LjlQuickReport Wizard
JDTeeChartWiiaid
Qg DB Web Application We...

Page

EditObrect.

Ddete Detect

P Jew Form P Main Foirn


OK ~~]

Cancel

Help

2.7

2.7.1 Code Insight
.
, , , , . Code Insight : . . 15.5 , Code Insight
.
, .
Code
Insight , Ctrl-Shift- Ctrl- , Code Insight .
Code Insight .

,
(>) , , , ,
.
, Enier, . Code Insight.
, , , , Ctrl-.

114

C++Builder 6
, , , .
.
, .
Sort by Name.
" = " Ctrl-,
, , . . , , - .
C++Builder 6, Ctrl-
, , . , Code Insight , Enter.
, ,
Code Insight , ,
, . , ,
, . ,
, Code Insight,
- C++Builder.
, , Shift-Ctrl-.

Code Insight C++.
(. . 14.2.6). Ctrl-J. . ,
for, :
for (; ;)

, , .

Code Insight . 2.8.3 . Code
Insight
.
Code browser
Code Insight, , , . , ,
Code Insight . .

C++Builder 6

115

Code browser , Ctrl. ,


. ,
, , , , . .
, Code browser.
Code browser ,
C++Builder Project |
Options ( Directories/Conditionals) Tools | Environment Options (
Library).
Code browser , , .

2.7.2 ClassExplorer
ClassExplorer , ,
, , ,
, .
(. . 2.30) (. . 2.4 ). ,
Automatically show Explorer
ClassExplorer Tools I Environment Options.
View |
ClassExplorer. . 2.2.8, .
. 2.30
ClassExplorer

""! TFoimi
:f int A
Q) TButton " Buttoni
fij int FA
Q TLabel-Labell
;
if double P
. %, void SetA[int value)
*$j TForm1(TComponent" Owner)
E- TForm2
TMemo-Memol
1
^ TForm2(TComponent" Owner]
S 10 Functions
' , void FFtint A; double P)

,
. . 2.30 , : (Projectl), (TForml,
TForm2), (public) () (),
( published) (Buttonl, Labell), (private) (FA) (SetA). , (FF). , , ,
.
, , .

116


, , . ,

Go to Declaration.
, Go to
Implementation ( ).
Class
Hierarchy. , , ClassExplorer (
), , , .
, . , , . .
. 8, . 8.3.6.

2.7.3 ,

, , , , , . - , ,
( , ) F1,
. ++ilder 6 VCL CLX (. 8.1),
, ,
(. . 2.31).
Windows, VCL, CLX.
[3],
( . 2.31). ,
.

(. . 2.31), .
, ( . 2.31). , , CLX, , .
.
,
. , (. 2.32).
. 2.31


TComboBox (Visual Component Reference Help]
-

117

C++Builder 6
. 2.32

Find Declaration
Open Source/Header File Qrh-F6
Co
l se Page
CM+F4
Open File Bt Cursor Ctrl+Enter
New Edit Wn
idow
Tope Search
Fl
AddTo-Oo Item.,, SNft+GtrH-T

BBookmarkD
i Bookmarki
9 Bookmark 2

Goto Bookmarks
Debug
Read Onyl
Message Ve
iw
Ve
i w Explorer
Properties

Sl+rl+

P Bookmarkt
i Bookmark^
p Bookmark 6
Bookmark?
Bookmark 8
! Bookmark 9

, , , , , ..,
Find Declaration . ,
. (, ..)
, ,
. - , , ,
, . ,
, Close Page.
,
#include, Open File at Cursor, , , ..
.
-
. , , Toggle Bookmarks. ,
. 2.32. ,
, .
. - , .
, Goto Bookmarks .
.
Grl-K- ( Ctrl-K )
, , . Ctrl-K .
,
, , -
, .
New Edit Window.

118

, . ,
.

2.7.4 C++Builder
OpenHelp
C++Builder Help. , , :
C++Builder Help

C++Builder C++

C++Builder Tools

C++Builder 6

Windows SDK

Windows

STLport Help

(Standard Template Library), HTML

.
Help. -
C++Builder. - , Fl , . , , - , - Fl,
. , .
,
. 2.31 . 2.7.3. ,
.
, .
, ,
. .
C++ C++Builder,
. , , , ,
Visual Component Library
Reference ( ), Alphabetical Object and Component Listing ( ) . , .
, , , Visual Component Library Reference ( ), Alphabetical Routines Listing
( ) Categorical Routines Listing (
), .
C++,
Runtime Library rieierence ( ) Standard C++ Library. .

O+Builder 6

119

API Windows, Windows ..


Windows SDK Help. Windows C++Builder .
, . Borland OpenHelp,
Help | Customize. . 2.33. OpenHelp
..
, . , . , C-H-Builder ( . 2.33
C++Builder), *" . - ,
. [3] , .
. 2.33
OpenHelp Contents

Fie * U*
t

Contents n
i dex I bnk

$t C++B jidei Po
i gtammers' Gud
ie
^Developing Database Application
$t Developing Internet Applications
^Component Writer's Gud
ie
Developing COM based applications
_ Runhme Library Reference
^ S t a n d a d C++ Library Help
^CMBuldet Command-line Tools
^Visual Comoonent Libf ay Releience
^ C L X Reference
^tlrteiBaseEi<piessRefehce

D \Prope

^odeGuad User's Guide


^Translation Tods

D \Pro9an
D

...'. ':-.

D:\fte

:\

OpenHelp .
.ohp /Help.
: (Contents),
,
C++Builder F1.
OpenHelp
. , WINHELP.INI
. , OpenHelp File | Cleor, Registry.
.
.toe,
Windows .cnt, Include. , :
1. OpenHelp Contents (. . 2.33).
2. Edit | Add Files.
3. .toe .cnt.

120

4.
5.

.
.
,
Contents.
6. File | Save Project File | Save Project As.
:
1. OpenHelp Contents.
2. .
3. Edit | Remove.
4. File | Save Project File | Save Project As.
..

, ,
Index ..
- ., ALink. C++Builder
F1 , , . - ,
, , Link.

2.8
2.8.1

(
). ,
.
, .
C++Builder , .
.
(. . 2.3.3), , , , .
Run | Run, ,
F9. , ,
. . , . ,
.
, . 2.34. .
:
( . 2.34 UnitS.cpp) (Linking). (Current
line), , (Total lines).

(Hints), (Warnings) (Errors). Cancel .

C++Builder 6
. 2.34

121

Pwe
i ct F

Urnt3

CuitnlkieHints-

18J523
0

Wairsngs

felines
0

46
Ejfors:

, . , ,
, . .
, , , . .
Run ,
- .
Run [ Parameters
.
.
, - .
: Project | Compile Unit,
Project | Make Project Project [ Build Project.
Compile , .
,
. ,
.obj .
Make ,
.
, .obj
. ,
.. , Moke Run , .
Build Make , , . , .
. , ,
, , . , Build, . .
: Project | Make Ail
Projects Project | Build All Projects. Make
Build, (. . 2.3.3) ,
.
C++Builder 6 5 . Tools | Environment Options
Preferences Background Compilation ( . .
15.10). . , , , . ,

122

. ,
: , .
, - ,
, ( C+4-Builder 6
).
, ( Run) . 2.34 : Done: Make : , Done: There are errors : , Done: There are
warnings : .

2.8.2
.
,
, . . , Label Button.
:
void

fastcall TForml::ButtonlClick(TObject *Sender)

int i , j ;
double A;
f o r ( i = 0 ; i < 50;
A *- 10000;
Labell->Caption
"A

// 10000

for, 50 , 10000 .
Run | Run, , F9. ,
. 2.35. , ,
, Project | Options Compiler
vVarnings . ,
. . , . 2.35, , . ,
. 15.9.3.
. 2.35


Unit!
fagtcalj. TForml::ButconlClick[TObject
int a, j;
double A;
, for(i = 0: i < 50; 1++)
| A - lOOaa;

// 10000

I
24: 30

jModified

Insert

;\l_lnit1 cpp/linin ii

1* Wainng] Unili .cpp(23): WB013 Possible use of W before deiiilion


|C*Enor]Unitl.cpp(24): E2451 Undefined symbol'B'
|C Wainmgl Unil1.cpp[25]. W8080 V is declared bul nevoc used
|C Wainmgl Unil1.opp|25]. W8057 Parameter 'Sender' never used

"Sender)

C++Builder 6

123

. , , , .
,
, , . ,
.
.
. , ( , ), , Message View.
. :
[C++ Warning] U n i t l . ( 2 3 ) : W8013 P o s s i b l e use of 'A' b e f o r e d e f i n i t i o n
([C++ ] U n i t l . , 2 3 : W8013
' ' , , , )
,
23 . , ,
.
. ,
*= 10000;
// 10000
, . , a Warning . , ,
. , , 1,
:
double = 1;
:
= 1;

,
, . , .
, .

. ,
, .
, ,
.


, . , .
,
. , , . . ,
.

124

2
. 2.35. :
[C++ Error] Unitl.cpp(24): 2451 Undefined symbol ''
([.C++ ] Unitl., 24: 2451 '' )
.
Labell->Caption = " = " + ;

, .
.
, , , , .
,
.
:
[C++ W a r n i n g ] U n i t l . ( 2 5 ) : W8080 ' j ' i s d e c l a r e d b u t n e v e r u s e d
([C++ ] U n i t l . , 2 5 : W8080 ' j '
, )
, j, .
- ,
. j ,
, , , , .
:
[C++ Warning] Unitl.(25): W8057 Parameter 'Sender' is never used
([C++ ] Unitl., 25: W8057
'Sender' )
Sender, . , . , .
, - .
, , , :
[C++ E r r o r ] U n i t l . ( 2 4 ) : 2060 I l l e g a l use o f f l o a t i n g p o i n t
([C++ ] U n i t l . , 24: E2060 )
,
Labell->Caption = " = " + ;
" = " .
, , .
:
Labell->Caption = " = " + FloatToStr(A);
, :
double A = 1;
void
fastcall TForml::ButtonlClick(TObject *Sender)
{
int i;
for(i = 0 ; i < 50; i++)
A *- 10000;
// 10000
Labell->Caption = "A = " + FloatToStr(A);
]
.

125

C++Builder 6

2.8.3 ,
, , ,
, .
. ,
.
, - :
, , ..
, , , . , , - . :^ .
:~. .
;; .
. : .
. ~;.-
, . 2.36.
. 2.36

Debugger Nutilrtolkm

Project Projectl .exe raised exception class I


stopped. Use Step or Run to continue.

-.,;;; ^--ting pant overflow'. Process

: Projectl.ej.T ; = : ; ; ; - EOverflow ' -;;: : '. . Step .< .


, . (exceptions) . . 13,
. 13.10. : ?
, (. 2.37) , . , .
. 2.37

,
.
double A - 1;
ivoid

faetcalX TForml:iBucronlClick ,-~

i n t 1;
f n r | l - 0;

i < 50;

Labell->Caption = rrA = " +


I
Insert

;\Unil1 cpp/_-i

.
Ctrl-F2
.

126

, , , , , . , , .. ! ,
, , . , , , .. .
, .
Run | Run (
, F9), , , .
(. 2.38) ,
. , .
. 2.38

-Si
_____

Floating point overflow.

,
.
, , - .
.
, , :
, .
. C++Builder 6 Tooltip Expression Evaluation.
, , , : =1+308.
. , .
, .

2.8.4 Watch List


, , , ,
, . Watch List.
View | Debug Windows | Watches. .
OH-F5. ( C+4-Builder).
, QH-F5 . , - , OH-F5
(. 2.39).

C++Builder 6

127

. 2.39

<
-10000: +INF
Formi ->Labeli >Caption: { " = 1200" (

. 2.39 , . , 380
10 , * 10000 +INF. . ,
10000 , double
. .
, . , ,
,
, . . , , ,
Labell>Caption,
: Undefined symbol 'Labell'
'Labell'.
Forml, 2.39, .
, . ,
, .
volatile. :
volatile int x;

volatile ,
.
( ) Project |
Options Advanced Compiler
Register Variables.
,
, .
, . .
, i,
(.
. 2.8.7) .

.
. ,
, : Edit Watch ( ) Add Watch ( ). Watch
Properties, . 2.40. , Ctrl-F5 .

128
. 2.40

Watch Properties

[Expresso
in
Grgup name
Repeal count'.
S7 Enabe
ld
= Character

filing

! f*1 tJecimal

\fi '100U0

jWatches

zJ

(0

Dots

P Allow StdeElfecls
^

Hexadecimal

*SHuclu.e

*" Floating point

^ Memory Dump

o,nt B
*

Default

Cancel

Help

Watch Properties. Expression , , , . Repeat


count . , X,
Expression X.
X. Expression
[0], Repeat count , , 10.
10 .
Digits
. Enobled
.
. , - , . Watch
Properties Enabled .
Allow Side Effects , . , Expression ++. Allaw Side Effects
( ), +-I-A : Side effects are not allowed. ( ).
, , , . Allow Side Effects, ,
1 , . ,
.
Watch Properties . Default.
.
. ,
,
, .
Expression , , . , .
, Forml>Labell>Caption, Forml>
Label2>Caption Forml>Label3>Caption,
,
.
C+4-Builder 6 VVarch Properties
. ' Watches. -

C++Builder 6

129

. 2.39. (). Watch List Add Group .


, Wotch
Properties (. 2.40) Group name .
- ,
Move Watch ta Group .
, .
,
. - ,
Delete.
, , Watch
Properties .
. (.
308
. 2.39), 10 , 312
10 .
double . , ,
. OH-F2, . .
Evaluate/Modify.

2.8.5 Evaluate/Modify
Evaluate/Modify , . Run J Evaluate/Modify. Debug |
Evaluate/Modify ,
.
, . 2.41 . Expression . , Evoluate, Result .
, . Expression , , Modify, . .. .
, , ,
, , .
Expression , New
value - (
. 2.41 / 2300) Modify.
, Result.
, .
,
F9, . ,
, , .
.

5 ++

130
. 2.41

: () ()

) 11
Evaluate Modify
Expression.
A
fiesuK:
1E.308
i9M value:
1E.308

vvatch

Q,
Inspect

Help
d
3
d
il

6)
Evaluale rjiodity
^xpiessjon:
Qesu:
[50000000
Hew value;
jA / 2e300

Watch

Inspect

t dp
d

, ,
. . , , , . , ,
, , .

2.8.6
, . . ,
, - ,
.
:

Step Over
(

F8

,
,
.. .

Trace Into
(
...)

F7

Trace to Next Source Line


( )

Shift+F7

...)

F4
Run to Cursor
( )


, .

131

C++Builder 6

Run Until Return


(
)

Shift+F8

, ,
.
,
.

Show Execution Point

( )

. Watches. , , , , .
, , , .

(. 2.42 ), .
, Watches (. 2.42 ). , View |
Desktops | Save Desktop View | Desktops | Set Debug Desktop ( . . 2.2.9).

(. . 2.1 . 2.1.3).
. 2.42
,
:
()
()

Otiect Inspector | Watch List]


Properties

Ee

t t (; |
Align
AlphaBlerd

Hjll

BlDlMi.de
Hbotdetlcon
BotdefSt^le
BordeiW*
1 Caption
LfientHfjgitt
Oerfcidlh

tisJ
-N
fa
sleone
[ta
kLefUkToi
u
ise
fa
le^
bib
EsyS
se
tE
m
M
ea
b
eier

Foiml
246
334

Watch List 1
A: 1E*30B
A-10000 *INF
Form1->Label1->CaplJ
i 27

jj

2 hidden


,
*= 10000;

F4, , , . . . , , (. . 2.37):
, . , F7 F8 ( ),
. -

132

F7 F8 , - , . F7 ,
F8 .
,
, Labell>Caption. F4. ,
, .
.
F7 F8, . F8 . F7
dstring.h. AnsiString,
. F7 .

2.8.7
Run 1o Cursor F4.
(breakpoint).
() , .
(. 2.43). , , ,
.
. 2.43

Umll.cpp ]
.

__

double A = 1;
void fastcalJ. TForml::ButconlClick(TOto3ect ^Sender)
<
', int i ;
, f a r ( i - 0; 1 < SO; i++)
Ll->Captlon

Action: Break
Group:
; Pass Count; 0

+ rioatToStr(A);
I
\umtl ,cpp /,UniH ,h /{Diagram /

, , , F4.
, . ,
. , , .
,
.
.
, , , , ,

C++Builder 6

133

, . C++Builder , , . , - . - ,
(. . 15.9.3).
C++Builder .
, .
(. 2.43)
. .
.
. , ,
, , 26- ,
(
). , , i
26, , .
, (. 2.43). Breakpoint properties. , . 2.44. C++Builder 6 5
, C++Builder 4.
. 2.44
( )

s f Actions'
I I 17 freak
: : P ignore subsecjjent exceptions
: " Handle subsequent exceptions
(=26 pas

:i;dl expression.

Log result

Enable gfoup
Disable group

d
""'

"

Cancel j

Help

Filename ( ) Line Number ( ) .


, .
Condition () . , true. i==26.
Pass Count , . . Pass Count 2.
Group () ,
. ^Builder - .

134

. . 2.44 Enable Group ( ) Disable Group ( ).


, .
Advanced . (Action),
. Break, , . Ignore
subsequent exception ( ) Handle subsequent
exception ( ),
, (. . 2.8.3, . 2.36) . Ignore
subsequent exception, .
Handle subsequent exception, .
, C++Builder Language Exceptions (. . 15.8).
Log Message , Event Log (. . 2.8.9).
Eval Expression , . Log Result
Event Log.
,
Event Log, , ,
Break. Ignore subsequent
exception,
. , Event Log, , , , .
, . 2.44,
.
, . ,
i = 26. , , ( F7)
. . 2.39
Break, , View | Debug Windows Event Lag,
, , :
Breakpoint Message: i=26
Process Projectl.exe (0x700)
Breakpoint Expression A: 1E+304 Process Projectl.exe (0x700)

( i=26 ) () .
,
( , ),
View | Debug Windows | Breakpoints. Breakpoint
List (. 2.45 ). (
. 2.45 , ). (. . 2.45 )
.
, .

135

C++Builder 6
. 2.45

()
(6)

) iRrpaldininMict
.11 I
Fiename/Addiess LiWLength
SWniti.cpp
23
t == 2S

>1299
8

- "

Si
Action Pass CounI | Group
Break Oof 2
0
Break... 0
1

I >\
6)
"10000.1+304
Formi -> Labeli -> Caption- { "A -1E 200" )
JL?5

fL:....; .L.i'.i.Cp'1*qnj A... j Pass.,.j Gtou


U.. 23 i == 26
iA 8
>123

Bi.. 1 o!2
.
0

0
1

, . ,
, . ,
,
. Pass Count, , 50. , , , .
Breakpoint
List, , , .
.
Add . : Source Breakpoint
, Address Breakpoint , Data Breakpoint . , Breakpoint List
, . , ,
.
. ,
.
. , , , .
;, ^ , . ,
.
, ,
.
,
, > 10 2 9 9 . -

136

, , , , . ,
, C++Builder.
Breakpoint List Add. Data Breakpoint .
(. 2.46), (. . 2.44).
Address , . (Length) . Condition Pass Count ,
. 2.44.
, . 2.46, .
,
(. 2.45 ).
. 2.46
( )

;
| Addiegs,
; Length:
; Condition:
Pan count'
. .Group:

j/>
J8
JA>1e299
jo
1

d
d

I f~ eep existing Breakpoint


r Aclions:

Advanced << I '

--

\~ Ignore subsequent exceptions


P Handle subsequent exceptions
'

: i

Log message; |^> 12

3 ; :

E val expression: ]A

d i !
:;

P Log result

; ;. Enable group:

)i

ti.

| ! Disable group: |o

OK

Cancel

Help

, .
, Properties.
(. 2.44) (, )
Disable Group. . :
Enabled. , Enabled .
. , ,
. .
*= 10000;

, = 10 3 0 0 (. . 2.45 ). .. ,
, ,
.

137

C++Builder 6

, . , Enabled.
, , C++Builder 6 5
, . , , Run | Add Breakpoint ( ) Source
Breakpoint, Address Breakpoint, Data Breakpoint Module Load Breakpoint.
,
, . ( .dll .bpl). ( Break When
Changed, ). , ,
, .
,
. , Enabled.

2.8.8
Debug Inspector
+-I-Builder 6 5
Debug Inspector. ,
Evaluate/Modify, .
Run | Inspect,
.

Run | Inspect. (Debug |
Inspect). , AH+F5.
.
, , , , . , . 2.47 .
. 2.47
: ()
()

)
(A- double: 004031
Dala
|

"

idoubie' "

' fi+308''

138

.
,
Change, . 2.47 .
, ,

.
: , , , , . . 2.48 ,
, Forml>
Label 1. , ,
Properties, . ' , .
- (, , ),
. Change, . 2.47 , .
.
, , "?". . 2.48 Caption.
, . "?", ,
, .
. 2.48
Label!

HHPff*'

|Forni1->Ubel1 Stdctrls: TLabel" .0UU34C14 . .Uljrj


Data | Methods

Properte
isI

0 ," Controsl- VN
l one ".'_*]
I Align'
Alignment
0
/"
C
a
l
s
s
e
s
l
a
LefUustj
:
Anchors
{
' \xO?'0/1'Controls
'< AutoSize
t
r
ue (read-AutoSzie wri
! BIDiMode
[l f Ca
l es:bdLfT
l oF
I Caption
(read-Getf ext wita_2j
. Color
2H74B3633 |readCo
: Consliaints
00836344 |read=Consl
DragCursor
-12 [read=DragCursor w
DragKind
l:dkDrag".
10*"Contros
: DragMode
0/" Controsl dmManui
Enabled
[
r
e
a
d
=
G
e
t
E
nabe
ld wrtie
:
FocusControl
N
ULL(read=FocusCon
.0099631 [read-Font J-J
Font
System: iftnsiStrmg property
>
,
:
Range

Chonge

Change .

Show Inherited

, , ,
. ,
, .

Show Fully
Qualified Names

139

C++Builder 6

Inspect

.
, , .. .

Descend

Inspect, , . ,
, .

New Expression

Type Cast

, , .

2.8.9 , OutputDebugString
C++Builder
, .
, View | Debug Windows | Event Log
Ctrl-Alt-E. Event Log (
. 2.49) . . 2.49 , , , . 2.8.7:
i = 26, 3 8 > 10 2 9 9 . ,
, , .
. 2.49
Event Log

ource Breakpoint at 0x00401 B7: FMestsSDebugV2VUnit1.cpp line 23. Pass 1 of 2 Process Pic
ODS. : = 1E200 Piocess Projecti (0x45C)
Data Breakpoint at (M0401B33. Object at address: 0x0O40318C. Length: B. Process .
Breakpoint Message: A > 1 e299 Piocess Pioiectl ,exe (0x45CJ
Breakpoint Expression A. IE+300 Process Project1.exe (Ox45C)
Data Breakpoint at 004' Object at address: OxOO4O31BC. Length: 8. Process Proiecll.ex
Breakpoint Message: A > 1 e293 Process Pro[ect1 .exe (0x45C)
Breakpoint Expression : 1E+300 Process Project1.ene (0x45C)
Source Breakpoint at 0x00401 87: FATes!sSDebugV2VUnit1.cpp line 23. Pass 2 of 2 Process Prc
Breakpoint Message: i=26 Piocess Piojectl.exe (45)
1 *3U4 Process Prorecti .exe (045
I


, . 15.8. , , , OutputDebugString. . API Windows, :
VOID

OutputDebugString(LPCISTR

lpOutputString);

lpOutputString
.
OutputDebugString ,
Event Log.
-

140

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


,
,
.
,
, , , TForml::ButtonlClick
OutputDebugString((" : = " + FloatToStr()).c_str());


. 2.49 (. ). , , . 15.8, . .

2.8.10
C++Builder ,
. , , CPU ( View
Debug Windows | CPU),
, FPU ( View | Debug Windows | FPU), .
( View j Debug Windows | Call Stock)
, , , . (
View | Debug Windows | Modules) , . , ,
.,
.
, ,
.
,
.
, , . ,
.

2.8.11 ,


C++ C++Builder. , ,
.
C++Builder assert.
:
#include <assert.h>
void assert(int test);

test, , - . test ( 0), abort


.

C++Builder 6

141

.
#include <assert.h>

, , :
f o r ( i = 0 ; i < 50; i++)
{
*- 10000;
a s s e r t ( < 1300);
}
300

< 10 ,
. ,
, . 2.50. , , , , .
. 2.50
assert

ill
Assertton failed: A < 1, ffc F:\TtsV>ebug\21Unitl .cpp, (no 25

: assert,
if?. assert , , , NDEBUG.
ttinclude <assert.h>

define NDEBUG

, , assert, . , , .
,
, .
, assert ,
. , . My Warning,
assert,
msg. , ,
,
, . - ,
.
# i f d e f NDEEV3
#define MyWarnir.g (p,rasg)
((void)0)
#else
//
#define MyWarning(p.msg) (() ?(void)0 : (ShowMessage((msg)+
", ("+AnsiString(*p)+")\ " + AnsiString( FILE ) +
", " + IntToStr( LINE ))))
tendif

142

,

MyWarning(A < 1300, " = " +FloatToStr() + ", i = " + IntToStr(i));

, , 10
, . 2.51.
. 2.51
MyWarning

300

= 1304, i = 25, ( < 1)


F:\Te5ts\Debug\2\llnitl.cppj 32

, ,
, . , , , .
#ifdef NDEBUG
define MyAssert(p,msg)

((void)O)

#else

//
define MyAssert(p,msg) (() ?(void)0 :
(FMyAssert((msg), FILE , LINE
#endif
void FMyAssert(String msg, String sFile, int Line)
(
ShowMessage((msg)+"\ " + sFile + "f " +
IntToStr(Line));
abort () ;
)

)))

MyAssert :
MyAssert( < 1300, " = " +FloatToStr() + ", i = " + IntToStr(i));

, , , . , ,

define NDEBUG

, , ,
, . :
lifndef NDEBUG

#endif

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

C++Builder 6

143

//
TForm FDebug;
//
* Memol;
'/'/'void
fastcall TForml::FormCreate(TObject *Sender)
(
lifndef NDEBUG
//
FDebug = new TForm(Application) ;
FDebug->Caption = "";
Memol - new TMemo(FDebug);
Memol->Parent = FDebug;
Memol->ScrollBars = ssVertical;
Memol->Align = alClient;
FDebug->Show();
#endif
}
//
void
fastcall TForml::FormDestroy(TObject *Sender)
(
lifndef NDEBUG
//
FDebug->Release();
#endif
>
/

void
fastcall TForml::ButtonlClick(TObject *Sender}
(
for(int i = 0; i < 50; i++)
(
A *= 10000;
lifndef NDEBUG
//
Memol->Lmes->Add("A = " + FloatToStr (A)+" , i=" + IntToStr (i) ) ;
#endif
}
Labell->Caption = "A = " + FloatToStr(A);
)

, . OnCreate FDebug Memol. .


OnDestroy . , , NDEBUG.

. , . 2.52,
.
- , .
, ,
#define NDEBUG

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

144


. .
. 2.52

A-1E60J-14
A-1E64J-15
A.1E68J-16
-172>17

A = 1E7S>18
80, i-19
- 184, i=20
- 18,.-21
A-1E32>22
-196.23
A-1E1OO.i-24
-1104,1-25
- 1108, i-2G
A = 1E1l2,i.27
A = 1EHG, i=28

, , . , , Debug.txt.
debug, :
bool debug = FileExistsCDebug.txt");

(, ),
,
if(debug)
, Debug.txt ,
.
, . ,
, Debug.txt, , , . ,
, , .

3

C++Builder
3.1
VCL C++Builder, , , C++Builder.
(. . 15.2), , (. . 8). ,
C++Builder 6 . 2.2 . 2.1.4.
Samples ActiveX C++Builder
. Samples ...\EXAMPLES\CONTROLS\
SOURCE. ,
.
ActiveX .
, Property , , .
Samples ActiveX
. , .
Win 3.1 32-
Windows. , Windows, Windows 3.x. 32-
Win 3.1, . 3.1.
3.1. Win 3.1
32-
Win 3.1
DBLookupListBox
DBLookupList

DBLookupCombo

DBLooknpComboBox

Data Controls

TabSet

TabControl

Win32

Outline

Tree View

Win32

Header

HeaderControl

Win32

NoteBook
TabbedNoteBook

PageControl

Win32

PageControl

Win32

Data Controls

146


C++Builder.
, C++Builder.
Data Access, Data Controls, ADO, Interbase, dbExpress . 9, 10, 11 .
Decision Cube, QReport . 11. . 6 (. 6.2). Servers . 7, . 7.9 . 11, . 11.3. Internet FastNet
. 12.
,
, .
, . .

3.2

3.2.1

C++Builder
, , . . 3.2 C++Builder 6 ,
.
, , . 9 10.
3.2.

Label ()

Standard

,
. , . Caption.

JA

StaticText
(
)

Additional

Label,

. Caption.

Panel ()

Standard


,
.
Caption.

Jrtf.

Edit
( )

Standard

, .

. Text.

C++Builder

MaskEdit
( )

Additional

147



. Text H.EditText.

LabeledEdit
Additional
(
)

Edit Label. Text EditLabel.Caption. C++Builder 6.

Memo
Standard
(
)

, . . Lines.

RichEdit
Win32
(
RTF)


Windows RTF,

,
. Lines.

ListBox
( )

Standard

CheckListBox
Additional
( )^
ValueListEditor Additional
( )
ComboBox
( )

Standard

CoraboBoxEx
Win32
(
)
StringGrid
Additional
( )


Windows, . Items.

ListBox
CheckBox.

= .
: Keys ,
Values .
C++Builder 6.
ListBox
Edit. , . Items.
.
Items. C++Builder 6.
| |
!
1

. Cells.

148


Canvas () ,
, , (. . 6.1.3). ,
Canvas->TextOut(60,16,"Canvas")

, (60, 16), Canvas.


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

3.2.2 Label,
StaticText, Panel

Label, StaticText Panel. ,
. Panel : .
.
. 3.1. Panel
. 3.38 . 3.7.2.

. 3.1
>
Label (a)
1|=1. Alignment-taCentei
StaticText ( 6 )
Align=airop. Aligriment.taCentei. Coloi-cFWhile

Align=alNone. Color=rlWhitc

WordWrapMalse, Aut

p
AutoSize=false

)
BorderStj/lessbxNune

Boidei5tyle=sbsNone

[BoiderStjFle=sbsSing]e| |BorderStyle=sbsSingie]
iBorderStyie^sbsSunken BorderStyle-sbsSunken
;
'

Aligrunent=taCeriter,
AutoSize=false,

ord ei S t I e^sbsS unken

C++Builder

149

, , Caption.
. :
Labell->Caption = " ";
Caption AnsiString (.
. 16). . . ,
Labell->Caption = 5.1;

5,1.
, , FloatToStr IntToStr,
. , , " + " ,
(). , I, , Labell :
L a b e l l - > C a p t i o n = " :

"+IntToStr(I);

Color, Color Font. , (


) . 3.1 . 3.1 clWhite
. ,
, , .
Label . StaticText Panel BorderStyle, . . 3.1
StaticText. sbsNone StaticText
Label. , ,
sbsSunken.
Panel BorderStyle Bevellnner,
BevelOuter, BevelWidth, BorderWidth, , . 3.41 . 3.9.2. , Panel Label.
, , Top, Left, Height, Width, Aline,
. , ,
,
. 5.2. .
Label StaticText AutoSize.
true,
. AutoSize false, Alignment,
, . Panel AutoSize,
Caption. Alignment
.
Label Wordwrap
, , . , Wordwrap true,
AutoSize false ( ) , (. . 3.1 ). Wordwrap -

150

true AutoSize false, ,


, (. . 3.1 ).
StaticText ,
AutoSize false
. . StaticText ,
Repaint
OnResize.
.
Label StaticText,
. FocusControl . Caption
"&", , ,
( ). FocusControl, , ,
: Alt +
.
: . FocusControl , ,
(. . 3.2.3), .
, , ShowAccelChar true.
, , Edit MaskEdit (. . 3.2.3) Readonly.

3.2.3 Edit, LabeledEdit MaskEdit


. 3.2 .
BorderStyle,
.
. 3.2

Edit
BoiderStyle-bsSingle

BofdeiStyle=bsNone

Mask Edit

(095)12345 67

01.03.02


Text AnsiString.
. ,
, . . ,
, . AutoSize
, :
, .

C++Builder

51

, . , : Ctrl-C Clipboard
( Copy), Ctrl-X Clipboard (
Cut), Ctrl-V Clipboard ( Paste),
Ctrl-Z . ,
. .
AutoSelect ,
. true , , .
SelLength, SelStart, SelText, ,
. ,
, SelLength = 6,
SelStart = 10 SelText "". ,
SelStart .
. true Readonly AutoSelect false. ,
. 3.2.2. . -,
( . 3.1 3.2).
, .
, .
.
Text AnsiString (. . 17).
. . ,
Editll->Text = 5 .

/ 2;


2,5.
StrToFloat , StrToInt . (, ), EConvertError (. . 13.10, . 13).
. :
int A;
try

= StrToInt(Editl->Text);
)
catch (EConvertErrori)
(
ShowMessage(" ; ");
}

. ,
,
, . . 3.3 , . , Edit ,

152

. . 5,
. 5.3.2 , ,
, ,
. . 8, . 8.3 ,
Edit , .
MaxLength .
MaxLength = 0, .
MaxLength , .
Modified, , , . , Modified
false. (true false) , .
PasswordChar
. PasswordChar #0 . .
(, " * " ) ,
, , (. . 3.2). .
. Edit . LabeledEdit, , Edit, . EditLabel TBoundLabel. ,
Label (. 3.2.2): Caption, Color, Font, Layout, ShowAccelChar, WordWrap, Canvas. Caption
.
LabelPosition LabeledEdit ,
: lpAbove , (.
. 3.2), lpBelow , , lpLeft
, lpRight .
, LabeledEdit, C++Builder 6,
, , Edit ,
.
.
,
.
, . , .
Edit LabeledEdit. ShowHint true (. . 5.1.9). ApplicationEvents (. . 4.6) OnShowHint:
void

fastcall

TForml::ApplicationEventslShowHint(
AnsiString SHintStr, bool iCanShow,
THintlnfo SHintlnfo)

{
if ((HintInfo.HintControl->ClassNameIs("TEdit") ) ||
(HintInfo.HintControl->ClassNameIs("TLabeledEdit")))
if (Canvas->TextWidth(((TEdit *)Hintlnf.HintControl)->Text) >
((TEdit *)HintInfo.HintControl)->ClientWidth)

C++Builder

153

. HintStr = ((TEdit *)HintInfo.HintControl)->Text;


ADpIicationEventsl->CanceIDispatch{);

, -
, ,
.
, ApplicationEvents OnShowHint, . 4.6.
. ,
, Hintlnfo>HintControl. . , TextWidth
Canvas. HintInfo >HintControl TEdit (. 1.9.6.2).
TextWidth ClientWidth . , TextWidth
, Canvas (. . 6),
Edit LabeledEdit .
. , . -
Label, LabeledEdit .
, HintStr, , , .
Edit LabeledEdit. (. . 3.9.7, . 5, .
5.1.8 5.3.2.2, . 8, . 8.3 ).
MaskEdit Edit LabeledEdit , EditMask.
, , , , , .. , ";". (. . 3.3), , , ; 1
, , , , Text ; , , .
Text,
,
EditText, .
3.3.
"!" , EditText
, "!" ,
.
" > " , , " < " .

154

" < " , , " > " .

" " , .

"\" , ,
, . , " > "
"\" > (), , .
"L" , .
"1" ,
.
"" , .
"" , , , .
"" , .
"" ,
.
"" , .
"9" , .
" # " , , " + " ,
"" .
":" , .
"/" , .
"_" .

EditMask. ,
EditMask .
, . 3.3 ( ,' ).
Sample Masks . Input Mask .
, OI<HO Input Mask , , .
. 3.3


Input Makor
Input Mask:

Sample Masks

Character (or Blanks:


Save Literal Characters

ilesl Input.

555-12-12

123456
V-ll 12345B
01 03 02
03 02
210515
13:45

Cancel

Help

C++Builder

1!55

Character for Blanks ,


, ( ).
Save Literal Characters : , 1, , 0.
Masks - . , ,
C++Builder, , .
.
.dem. C++Builder , C++Builder BIN. , .
, Sample Mosks .
, Sample Masks
. . , , , ru.dem.
I 5551212 I !000-00-00;0;_
| 0955551212 I !\(999\) 000-00-00;0;_
| 123456 | !0000000;1;_
| VII123456 | !L-LL 999999;0;_
I 010302 I ! 99/99/00;1;_
| 0302 | !99/00;1;_
| 210515 | !90:00:00;1;_
| 1345 | ! 90:00;1;

. 3.3 , . 3.2
.
. :
!\(999\)

000-00-00;0;__

"9" , . "" , . . , (. . 3.2):


(
)
- -_
0, EditText Text . EditText
. 3.2 "(095) 123-45-67", Text
"0951234567". 1,
"(095) 123-45-67".
. EditMask , ,
, , ,
"99;0;". ,
"00;0;".

3.2.4 Memo RichEdit


Memo RichEdit (. . 3.4) . , Edit, , .
: Ctrl-C Clipboard ( Copy), Ctrl-X Clipboard ( Cul), Ctrl-V Clipboard
( Paste), Ctrl-Z .

156

. 3.4
Memo RichEdit

Memo
.

iLJ

RichEdit

-!

Memo (, , )
Font. ,
,
, , .
Memo Font Memo, ,
.
RichEdit . RTF.
SelAttributes. TTextAttributes,
: Color (), Name ( ), Size (), Style ()
. , RichEdit,
FontDialog Dialogs (. . 3.10.4)
Button, .
:
if(FontDialogl->Execute())
RichEditl->SglAttributes->Assign(FontDialogl->Font);
RichEditl->SetFocus();

, , , , , . ,
, ,
( SelStart).
Def Attributes,
. ,
SelAttributes. DefAttributes
Assign
SelAttributes, .
DefAttributes .
, ,
OnCreate.
, .. Paragraph Attributes. :
Alignment

.
taLeftJustify (), taCenter ( ) taRightJustify
().

Firstlndent

Numbering

, .
nsNone , nsBullet
.

Leftlndent

157

C++Builder
Rightlndent

TabCount

Tab

Paragraph
, ,
- . Paragraph
, . ,
:
RichEditl->Paragraph->Alignment = taLeftJustify; //
RichEditl->Paragraph->Alignment - taCenter;
//
RichBditl->Paragraph->Alignment = taRightJustify,- //

,
, .. :
RichEditl->Paragraph->Numbering = nsBullet:;

RichEditl->Paragraph->Numbering = nsNone;

, ActionList (. . 4.3) , ABullet,


:
if (ABullet->Checked)
RichEditl->Paragraph->Numbering - nsBullet;
f
else RichEditl->Paragraph->Numbering - nsNone;
ABullet->Checked = ! ABullet->Checked;

() .
. 3.5 ,
RichEdit. , .
TabCount Tab
WantTabs = true. . WantTabs = false,

.
Memo RichEdit.
.
. 3.5

RichEdit

J T O - E?E
RichEditj
i :

-1

RichEdit SelAtttibutes->Slyle = [fsBofd]


6 4 5 P&fJSKtph~>NwBbermg= nsBullet

2: 9

|,

158

Alignment Wordwrap , , , , .
Readonly true .
MaxLength . MaxLength = ,
. , . . [2] [3].
WantReturns WantTab
.
ScrollBars .
ScrollBars = ssNone, .
.
ScrollBars ssHorizontal, ssVertical ssBoth, , . Memo RichEdit - . Memo , (. . 3.4). RichEdit
, .
Memo RichEdit Lines,
TStrings.
, Lines .
, . 3.6.
, CodeEditor
. , , , , Close Page ,
.
. 3.6

\ 4 IM-I

Memo

Cancel

Lines TStrings.
. 17.4, . 17.
, Lines.
, String, , Text.

C++Bullder

159


AnsiString Strings[int Index]. , C++Builder, 0.
Memol>Lines>Strings[O] . ,

Wordwrap = true, ,
.
Count .
Clear. , Lines.
Add Append Lines.
LoadFromFile. SaveToFile.
, , Editl,
, , Memol ,
.
:
Memol->1() ;
Memol->Lines->Add("X
Memol-^Lines->Add(" " + E d i t l - > T e x t ) ;
Memol->SetFocus();

");

RichEdit . , , ...
, . , , :
RichEditl->Clear ();
/* */
RichEditl->Paragraph->Alignment = taCenter;
/* */
RichEditl->SelAttributes->Style =
RichEditl->SelAttributes->Style << fsBold;
RichEditl->Lines->Add("X " ) ;
RichEditl->Lines->Add("CoTpyflHHK "+Editl->Text);
/* */
RichEditl->3elAttributes -> Assign(RichEditl->DefAttributes);
/* */
RchEditl->Paragraph->Alignment = taLeftJustify;
RichEditl->SetFocus[);

RichEditl (,
)
RichEditl->Lines->LoadFromFile("text.rtf");

RichEditl->Lines->SaveToFile("text.rtf");

SelStart Memo RichEdit


. CaretPos , X , , Y , .
, , 0, RichEditl>
CaretPos. + 1 RichEditl->CaretPos.x + 1
, .
. 3.5 ,
(. . 3.9.6) .

160

RichEdit Windows,
,
(, ), ..
. C++Builder [2], [3].

3.2.5 ListBox, CheckListBox,


ValueListEditor, ComboBox, ComboBoxEx
, , . 3.7. ListBox,
CheckListBox, ValueListEditor.
,
, , .
. 3.7

-=jSJ.*J

4
5

123-45-67

19

1 SieckLisffiox*"
! 1
I
1_1
* 1_2
;
1_3
1_4
1_5
1_6
1_7
2
2_1
2 _ 2

2.3

2 _ 5
2 _ 6
2 _ 7

ListBox CheckListBox ( . 3.7)


.
, , Items, TStrings. ,
.
,
TStrings (. . 3.2.4 . 17) Clear, Add . .
.
ListBox MultiSelect, ( . 3.7 true
). MultiSelect = false ( ),
. Itemlndex,
. , Itemlndex = 1.
, . , .
, ...: ..., , :

C++Builder

161

if (ListBoxl->ItemIndex < 0)
ShowMessage(" ");
else ShowMessage(" " +
IntToStr(ListBoxl->ItemIndex + 1) + ": " +
ListBoxl->Items->Strings[ListBoxl->Itemlndex]);
Itemlndex .
Itemlndex = 1. , 1
. - , .. , , , , OnCreate ,

ListBoxl->ItemIndex = 0;

(MultiSelect = true),
Itemlndex , .
, ,
Selectedpnt Index] bool. ,
" ...: ..." ( ) :
for (int i=0; i < ListBoxl->Items->Count; i++)
if
(ListBoxl->Selected[i])
ShowMessage(" " + IntToStr(i+1) + ": " +
ListBoxl->Items->Strings 4] >:

MultiSelect = true
ExtendcdSelect. ExtendedSelect = true, , , Shift . , Ctrl.
ExtendedSelect = false, Shift Clrl .
Columns ,
, ListBox (
. 3.7 Columns 2).
Sorted . Sorted =
true , .
AutoComplete, true,
, ,
.
Style, lbStandard ( ) . Style
, , C++Builder 6
.
lbOwnerDrawFixed lbOwnerDrawVariable . lbOwnerDrawFixed ,
, lbOwnerDrawVariable ,
. lbVirtual lbVirtualOwnerDraw
.
Style, lbOwnerDrawFixed lbOwnerDrawVariable,
, - ,
OnDrawItem. :
void

fastcall

TForml::ListBoxlDrawItem(
TWinControl *Control,
int Index, TRect SRect,
TOwnerDrawState State)

6 C++Builder 6

162

Control , . Index , . Rect THnaTRect (. . 17.4) ,


. TOwnerDrawState , odSelected
, odFocused .
OnDrawItem .
Style lbOwnerDrawFixed
OnDrawItem. Style = lbOwnerDrawVariable OnMeasureltem, . :
void

fastcall TForml::ListBoxlMeasureItera(
TWinControl "Control,
int Index, int SHeight)

Control Index , OnDrawItem, Height


.
. , , . ,
, ,
.
ToolBar (.
. 3.9.4)
, . 3.8. , , .
ListBox,
lbOwnerDrawFixed, : ( ), . , ,
OnCreate, :
ListBoxl->ItemHeight = ToolBarl->Images->Height;
for (int i=0; i < ToolBarl->ButtonCount; i++)
ListBoxl->Items->Add("");


(ListBoxl>ItemHeight) Height ,
ImageList (. . 4.2), ToolBarl Images. for ,
(ToolBarl>ButtonCount). , OnDrawItem.
. 3.8


'

I

C++Builder

163

OnDrawItem ListBoxl :
void

fastcall TForml::ListBoxlDrawItem(
TWinControl *Control, int Index,
TRect SRect, TOwnerDrawState State)

{
//
ListBoxl->Canvas->FillRect (Rect) ,ToolBarl->Images->Draw(ListBoxl->Canvas, Rect.Left + 5,
Rect.Top, ToolBarl->Buttons[Index]->lmagelndex, true);
ListBoxl->Canvas->TextOut(Rect.Left + 30, Rect.Top,
GetLongHint(ToolBarl->Buttons[Index]->Hint));
(

FillBect ,
Rect. Draw
ImageList (. . 4.2, . 4). ListBoxl ( . . 6.1.3). 5 (Rect.Left + 5). Index ToplBarl.Buttons
. ImageList Imagelndex.
TextOut Hint ( . . 5.1.9).
GetLongHint.
, , , Style lbVirtual lbVirtualOwnerDraw. .
OnData, OnDataFind, OnDataObject.
, , Count .
OnData ,
. :
void _fas'tcall TForml:: ListBoxlData (TWinControl Control,
int Index, AnsiString &Data)

Control , . Index , .
Data . ,
Data = " " + IntToStr(Index + 1 ) ;

..., .
- , OnDataObject, :
void

fastcall TForml::ListBoxlDataObjeet(
TWinControl Control, int Index,
TObject *SDataObject)

Index , DataObject
.
, ,
, OnDataFind. :
int

fastcall TForml::ListBoxlDataFind(TWinControl Control,


AnsiString FindString)

FindString , return.

164

List Box. ,
ListBox CheckListBox.
, ListBox ( . 3.7), , . ,
- , , .
CheckListBox, , . 3.7.5. , CheckListBox
, ListBox, , . CheckListBox ,
.
C++Builder 6 CheckListBox , (. . 3.7).
Header ,
, ( true),
( false). Header
( false). ,
CheckListBoxl->Header[l] - true;
CheckListBoxl->Header[9] = true; 1

, . 3.7.
,
HeaderBackgroundColor, , HeaderColor.
ValueListEditor. = . Key
Value . , TitleCaptions TStrings.
(), . ,

, . 3.7.
Strings TStrings . ,
. , (. ).
Strings TStrings.
= .
. TStrings
, , ..
Keys . 1. AnsiString Values[const AnsiString Key]
Key. , Key ,
. , Key , .
Strings>Names
Strings>Values ( TStrings).
AnsiString Cellsjmt
ACol]fint ARow]. ACol = 0 , a ACol =1
. ARow = 0 , a ARow > 0 .

C++Builder

165

BowCount , .
KeyOptions , . , keyEdit, keyAdd, keyDelete, keyUnique.
keyEdit .
keyAdd , Insert
. keyAdd keyEdit.
keyDelete Delete.
keyUnique ,
. .
ItemProps
. , ( 0). ItemProps
TItemProp,
. :
EditMask

(. 3.2.3).

EditStyle

KeyDesc

esSimple

esEUipsis

, OnEditButtonClick.
-
.

esPickList

, PickList OnGetPickList ( ,
PickList
OnGetPickList).

,
Key.

MaxLength .
PickList

TStrings,
EditStyle = esPickList.

Readonly

, . , Readonly = true EditStyle, esPickList


esEUipsis, , .

ItemProps.
ValueListEditorl->ItemProps[""]->EditMask =
"!000-00-00;0;";
(. . 3.7).
EditStyle = esPickList ,
(. 3.9 ), . ReadOnly =
true, , .
, ,
. 3.9 :

166

3
Valedit::TItemProp

*ItemProp_ =
VlueListEditorl->ItemProps[ '" ]
ItemProp->EditStyle - esPickList:;
ItemProp->PickList->Add("");
ItemProp->PickList->Add("Uex 1") ;
ItemProp->PickList->Add("Uex 2 " ) ;
ItemProp->ReadOnly - true;
)

. 3.9

EditStyle = esPickList (a)
EditStyle = esEllipsis ()

123-45-67

* 1

^}

1
2

123-45-G7

[!1!!

EditStyle = esEllipsis ,
(. 3.9 ).
OnEditButtonClick. , ,
- , - . , . :
ValueListEditorl->Values[""] - "";

ReadOnly = true,
, .
DisplayOptions , doColumnTitles ( ),
doKeyColFixed , doAutoColResize .
Options ,
, ..
: ComboBox Combo. . 3.10.
. 3.10

v
ComboBoK. Style csSimple

CombaSo--x1

J^J

. Style = ciDmpDown
3

C++Builder
ComboBox Style.
:
csDropDown


, (
. 3.10).

csSimple


,
(
. 3.10). ,
.

csDropDownList

,
.

csOwnerDrawFixed

,
.

csOwnerDraw Variable , .
csOwnerDrawFixed csOwnerDrawVariable OnDrawItem ,
ListBox. csOwnerDrawVariable
OnMeasureltem, .

Text. , ListBox Itemlndex. Itemlndex
ComboBox. ComboBox Itemlndex , ListBox. , , ,
, .
C++Builder 6 Itemlndex ,
, , . C++Builder 6 .
Itemlndex .
, Itemlndex = - 1 .
, .
MaxLength , . MaxLength = 0, .
DropDownCount , .
ListBox, Sorted '
. Sorted = true ,
.
ComboBoxEx.
ComboBox. , , , ComboBoxEx ,
ComboBox, . ,
ComboBox, , , ComboBoxEx . .

168

, ,
ImageList (. . 4.2). Images.
, ItemsEx. , . 3.11.
Add New () .
, .
: Caption , Imagelndex ImageList, Indent .
. 3.11

0
1 -
2
3
4

Style csExDropDown, csExSimple csExDropDownList. ComboBox.

3.2.6 StringGrid
StringGrid (. . 3.12) ,
. . , . , ,
.
.
StringGrid . . 3.6.2 ,
.
, :
System:: AnSiString Cells
[int ACol][int ARow]

, ACol ARow

Classes::TStrings* Cols[int Index] ,


Index
Classes::TStrings* Rows
[int Index]

,
Index

System::TObject* Objects
[int ACol][int ARow]

, ,
ACol ARow

. ,
TStrings (. . 3.2.4 . 17).

C++Builder

,
ir.~ I, J;
for (I - 1; I < StringGridl->ColCount; I++)
ScringGridl->Cells[I][0] - " " + IntToStr(I);
for ( 1 = 1 ; I < StringGridl->RowCount; I++)

StringGridl->Cells[0][I] - " " + IntToStr(I);


for (J = 1; J < StringGridl->RowCount; J++)
StringGridl->Cells[J][I]
= I n t T o S t r ( I ) + ':' + I n t T o S t r ( J ) ;
(

, . 3.12.
StringGrid

1 2 3 4}-*
1 1:1

1.2

13

1:4

2 2-1

22

2.3

2-4

3 3:1

3:2

3:3

3:4

4 4:1

4:2

4:3

4:4

ALJ

->

11

1:1. : 1:1

ColCount RowCount
, FixedCols FixedRows , .
FixedColor. LeftCol TopRow .
ScrollBars .
,
, .
Options , : (goFixedVertLine goFixedHorzLine) (goVertLine
goHorzLine) ,
(goColSizing goRowSizing), (goColMoving goRowMoving) .
Options goEditing
.
StringGrid - , . Col Row . , .
StringGrid
OnSelectCell, .
ACol ARow , CanSelect .
CanSelect ,
false. ACol ARow - . ,
L a b e l l - > C a p t i o n = " " + I n t T o S t r ( A R o w ) + ' : ' +
I n t T o S t r ( A C o l ) + ". : " +
StringGridl->Cells[ACol][ARow];

170

Labell ,
(. . 3.12). , ,
,
, .

3.3 ,
3.3.1 ,

C++Builder , , , . , , , . 3.2. , . . 3.4 ,
, .
3.4. ,


-,
UpDown
Win32
Edit
(-)

. Position.

CSpinEdit
Samples
(-
)

-.
, Edit
UpDown.
Value.

DateTimePicker
(
)

( ) .
Date Time.

Win32

MonthCalendar
Win32
( )
Calendar (- Samples
)

FIBook
ActiveX
( Excel)

.
. DateTimePicker ,
.
Month Day.

, Excel.

C++Builder

171

3.3.2
UpDown CSpinEdit
C++Builder ,
UpDown CSpinEdit (. . 3.13).
. 3.13
UpDown CSpinEdit

1 ;
UpDown + Edit
J2002

mixl

CSpinEdit
J2G02

_|

UpDown Edit , , . true Readonly,


- . CSpinEdit Edit
UpDown, .
UpDown Associate,
, Edit.
UpDown, Edit, Edit , , a UpDown . Associate UpDown Editl. UpDown Edit .
AlignButton UpDown, udLeft udRight, ,
. Orientation, udHorizontal
udVertical, , ( . . 3.13) ( . . 3.13). ArrowKeys , .
Thousands (
. 3.13 Thonsands = true).
Min UpDown
, Increment
. Position .
, , . MinMax,
, .
Wrap , . Wrap = false,
, , . Wrap =
true, . ,
. .. .
Edit, UpDown, ReadOnly
true, ,
. , ,
Increment UpDown . -

172

UpDown:
, - . ,
, . 5, . 5.3.2, - , .
CSpinEdit.
CSpinEdit , : Min, Max, Position MinValue,
MaxValue, Value. CSpinEdit
UpDown Edit. , - UpDown ( , ..), CSpinEdit.

3.3.3
DateTimePicker, MonthCalendar, CCalendar

. 3.14.
. 3.14

MonthCalendar

DateTimePiekei

2 2002

4
5 6
11 12 13 14 15 16 1
18 19 20 21 2 2 23 2
25 26 27 28 29 3D 3

J8 20D2

Id

2002 .

4
11
18
25

5
12
19
26

6
13
20
27

7
14
21
28

?*-, O r

1
15
22
29

9
16
23
30

02 03 2002

3
10
17
24
31

<: 02.03.2002
CCalendar

5
12
13
26

13
20
27

4
11
19
25

i
1
7
8
14 15
21 22
28 29

9
16
23
30

Be |
3
ID
17
24
31

DateTimePicker ( . 3.14,
, ). ( ) . Kind : dtkDate
, dtkTime .
DateMode dmComboBox , dmUpDown (. DateTimePicker . 3.10), , UpDown
CSpinEdit.
, . DateFormat, dfShort (, 08.03.02), dfLong (, 8 2002.).

C++Builder

173

Date.
. Date TDateTime, ,
, ,
24- , .*. .
12/30/1899 00 .
Date
DateToStr. ,
Memol->Lines->Add("flaTa: " + DateToStr(DateTimePickerl->Date));

Memol ": 08.03.00".


MaxDate MinDate, , .
dtkTime
Time, TDateTime.
TimeToStr.
MonthCalendar DateTimePicker,
. , MonthCalendar :
( MultiSelect), ( WeekNumbers), , ( FirstDayOfWeek) ..
.
CCalendar
. Date Year , Month , Day .
, , TDateTime. Month
Year,
. , ,
true UseCurrentDate ( ).
. StartOfWeek , .
0 , .
- - . StartOfWeek = 1.

3.3.4 Excel FIBook


FIBook ActiveX.
Excel (. 3.15),
,
.
. , ,
. , , , ,
, ,
..

174
. 3.15
FlBook


h
X

LG


TJOJJ
5

5 LM

100
60.

FlBook
. Workbook Designer. , . 3.16. , Excel, , Excel.
, Excel. , , , . . . 3.15 3.16 , .
.
. 3.16

FlBook

rimila One Workbook

-.;""

"

'*<!.

File Bow Sheet Fcrmat abject Help


O | B S | H 1

1'

"

&

-SUM[E2E9)


N>


3 LG
4
5 LM

LUIT.1
100
50
5
3
40

( .)

<|>|\-_heet1 /!1".
Fn Help, pie F1

50
40

4500

30

50
60
225
70
120
525
!
II

. 3.16
. ,
, ,
, ,
. , .

175

C++Builder

FIBook
- . , Excel,
.
, Help F1.
FIBook,
Properties. , , , , : (Row Heading Column
Heading), (Gridlines), (Formulas) ..
FIBook , -,
Excel. OLE.
. 7.

3.4

.
. , , . , MaskEdit. , . , ,
ListBox, ComboBox, StringGrid, DateTimePicker,
SpinEdit .. , , ,
, . . 3.17
.
Edit
.
ComboBox, SpinEdit, MaskEdit DateTimePicker. ComboBox Style csDropDownList , , . SpinEdit . 3.17


|~~7

1970 3

176

, MinValue MaxValue (, 1
50). MaskEdit
, DateTimePicker ( ) (, 1930 . 1985 .).
C++Builder 6 ValueListEditor (. 3.2.5),
esPickList, esEllipsis, EditMask. . 3.7 3.9 ValueListEditor , . 3.17.

3.5

3.5.1

. ,
, .. ,
, . 3.5.
, , . . 3.10.3.
3.5.

.
F



Windows S5/98/2000

TreeView
(
)

Win32

Outline

)

Win3.1

Win32
List View
(

Windows 95)


Windows 3.x
Windows

3.5.2
TreeView Outline
TreeView Outline (. . 3.18), .
: , ,
..
.

177

C++Builder
3.18
TreeView Outline

TieeView

Outline
->

a .=
1

I-BUBXI

f-S
-

TreeView , Outline.
TreeView 32- , a Outline 16-. Outline , Windows, Windows 3.x.
TreeView, , Items.
Items[int Index]. , TreeViewl->Items>Item[O] 0 ( ).
TTreeNodes, .
, . 3.19.
TreeView
Items .
. 3.19

TreeView

Hem Pioperties
New Item I
New bubltsmj

Xexi
ImagelndeK

j
jo

Selecled Index-[i
State IndeK-

jT

New Item ( ) . , , New Hem.


New Subltem ( ) . , New Subltem.
Delete () . Load . ,
, . . , , . 3.18 3.19, :

1
2
3

Item
Properties . 3.19. Text , -

178

. Image Index Selected Index


, ,
.
, ImageList (. . 4.2). Images TreeView, 0. -1 ( ), . State Index
Item Properties ,
. . , State Index, , ImageList,.
Statelmages TreeView.
. .
TTreeNodes. :
Add(TTreeNode* Node,
const System::AnsiString S)

S
, Node.

AddFirst(TTreeNode* Node,
const System::AnsiString S)

S
,
Node. 1.

Insert(TTreeNode* Node,
const System::AnsiString S)

S
Node
. 1.

AddChild(TTreeNode* Node,
const System::AnsiString S)

S Node.

S
AddChildFirst(TTreeNode* Node,
const System::AnsiString S)
Node.
1.
.
, ,
. 3.18 3.19.
TreeViewl->Items->Clear(); //
// "" ( 0!
TreeViewl->Items->Add(NULL, "") ;

/* " 1" - " 3"


( 1-3) */
TreeViewl->Items->AddChild(TreeViewl->Items->Item[O]," 1");
TreeViewl->Items->AddChild(TreeViewl->Items->Item[O]," 2 " ) ;
TreeViewl->Items->AddChild(TreeViewl->Items->Item[O] , " 3");
/* ""
"'" ( 4) */
TreeViewl->Items->Add(TreeViewl->Items->Item[O], "");
/* "" ""
"" */

C++Bullder

179

TreeViewl->Items->AddChild(
TreeViewl->Items->Item[4],"");
TreeViewl->Items->AddChild(
TreeViewl->Items->Item[4],"");

. , 1 2 1:
TreeViewl->Iterns->AddChild(TreeViewl->Iterns->ItemJl],
" 1");
TreeViewl->Items->AddChild(TreeViewl->Items->Item[l],
" 2") ;

, ,
Text. , TreeViewl->Items->Item[l]->Text 1.
. AddObject, AddObjectFirst, InsertObject, AddChildObject, AddChildObjectFirst, ,
:
AddObject(TTreeNode* Node,
const System::AnsiString S, void * Ptr)

S
Ptr
,
Node.

S
AddObjectFirst(TTreeNode* Node,
const System::AnsiString S, void * Ptr) Ptr ,
Node. 1.
InsertObject(TTreeNode* Node,
const System::AnsiString S, void * Ptr)

S
Ptr
Node .

1.

AddChildObject(TTreeNode* Node,
const System::AnsiString S, void * Ptr)

S Ptr
Node.

AddChildObjectFirst(TTreeNode* Node,
const System::AnsiString S, void * Ptr)

S
Ptr Node.

1.

, ,
Data. , TreeViewl->Items->Item[l]->Data.
: Clear(void), ,
Delete(TTreeNode* Node), Nod . ,
TreeViewl->Items->Clear() ;
,
TreeViewl->Items->Delete(TreeViewl->Iteras->ltem[1]);
1 ( ).
, , .

180

, ,
. BeginUpdate EndUpdate.
, . ,
:
TreeViewl->Items->BeginUpdate() ;
< >
TreeViewl->Items->EndUpdate();
BeginUpdate , ,
EndUpdate.
Count , , .. , .. Count , , .. .
TreeView.
Tree View Selected. , . , . , Selected NULL.
OnChanging ( ) OnChanged
. OnChanging
TTreeNode *Node , , bool &AllowChange . AllowChange = false, .
OnChanged TTreeNode *Node .
, .
TreeView RightCHckSelect,
( true) ,
. OnChanged .
TreeView
. OnExpanding ( ) OnExpanded ( ). TTreeNode *Node . OnExpanding bool &AllowExpansion,
false, .
OnCollapsing ( ) OnCollapsed (
). , , , TTreeNode *Node ,
OnCollapsing bool &AllowCollapse, .
ReadOnly TreeView
. , OnEditing OnEdited, ( OnEditing bool &AllowEdit ).
TreeView: ShowButtons, ShowLines, ShowRoot ,
, , , . , .
SortType .
stNone, , .
SortType stText, -

C++Builder

181

. Data ( SortType stData),


Data ( SortType stBoth) .

OnCompare, , , TTreeNode *Nodel
TTreeNode *Node2 , int &Compare,
: , Nodel
Node2, 0, , , Nodel Node2.
, OnCompare
:
Compare = - AnsiStrlComp(Nodel->Text.c_str(),
Node2->Text.c_str());

OnCompare SortType, stNone, (,


), SortType stNone.
.
SortType = stNone , OnCompare, .. , , .
, SortType = stNone, a
SortType, stNone. OnCompare.
. , AlphaSort(void)
SortType, OnCompare ( ,
AlphaSort ).
AlphaSort SortType = stText
, SortType = stText.
TreeView.
Outline . Items .
1. , Outlinel->Items[l] >Text
1 ( ). Items TOutllneNode.
TreeView.
: Lines TStrings.
,
Lines . ,
, , . , .
, ,
PictureOpen ( ), PictureClosed ( ), PictureMinus ( " - " ,
), PicturePlus ( " + " ,
, ), PictureLeaf ( ,
). Outline
, ,
TreeView .
" Add, AddObject ( ), Insert, InsertObject ( ), AddChild, AddChildObject ( ), Delete ( ).

182


Selectedltem. Selectedltem = 0, . Text: ,
Outlinel->Items[Outlinel->SelectedItem]->Text

,
Outlinel->Lines->Strings[Outlinel->SelectedItem -

1]

3.5.3 Windows
ListView
ListView Windows
, , .
, Windows.
ViewStyle, . : vslcon (. . 3.20
a), vsSmalllcon , vslist (. . 3.20 6), vsReport (. . 3.20 ).
. 3.20, Windows .
. 3.20
ListView
vslcon (a),
vsList () vsReport ()

0 Q
!

DO

DO

1
2
3
1

OO 1
EIO 2
0
DO 4

I .1!2
1
Uexl
5
2
4

ListView.
ListView. ListView, Items. (. 3.21), . ,
Tree View (, 3.19). New Item
New Subltem. :
, vsReport .
.
. , , ,
, .. . 3.21 .

C++Builder
.
<-
~ ListView

Caption ,
. , vsKeport (. ... . 3.20 ).
Image Index .
, ImageList (.
. 4.2). LargeImages vslcon Smalllmages vsSmalllcon, vsList
vsReport. 0. 1 ( ), .
State Index Item Properties . . , State Index, , ImageList, -;
Statelmages ListView.
, ListView
vslcon vsSmalllcon .
MainMenu (. . 3.8.1). , Drag&Drop, . 5, . 5.4.1.
, , -
5, .
:
( MI), ( MSmalllcon), ( MList) ( MRepprt)
Grouplndex Radioltem true
Checked ViewStyle ,
:
void
{

fastcall TForml::MIconClick(TObject

*Sender)

ListViewl->ViewStyle = vslcon;
MIcon->Checked = true;
ListViewl->DragMode = dmAutomatic;
void
{

fastcall TForml::MSmallIconClick(TObject Sender)

ListViewl->ViewStyle = vsSmalllcon;
MSmallIcon->Checked = true;
ListViewl->DragMode = -dmAutomatic; <

void
fastcall TForml::MListClick(TObject *Sender)
{
ListViewl->ViewStyle = vsList;
MList->Checked = true;
ListViewl->DragMode = dmManual;
void
fastcall TForml::MReportClick(TObject *Sender)
{
ListViewl->ViewStyle = vsReport;
MReport->Checked = true;
ListViewl->DragMode = dmManua^;
}

, OnDragOver
OnDragDrop ListView:
void

fastcall TForml::ListViewlDragOver(TObject 'Sender,


TObject Source, int X, int Y,
TDragState State, bool SAccept)

(
Accept - (Source = Listviewl);
void

fastcall TForml::ListViewlDragDrop(TObject *Sender,


TObject *Source, int X, int Y)

{
((TListView*)Sender)->Selected->Position = Point(X,Y);
)

. , , Windows.
Arrange:
void
fastcall Arrange(TListArrangement Code];
vslcon vsSmalllcon.
Code :
arAlignBottom

arAlignLeft

arAlignRight

arAlignTop

arDefault

( )

arSnapToGrid


ListViewl->Arrange(arAlignTop);


, .

SortType, TreeView.
Checkboxes, true, (. . 3.20). ,
,

C++Builder

185

.: Statelmages. ,
, .
. ,
Items[i], Checked.
:
for (int i=0; i < ListViewl->Items->Count; i++)
if (ListViewl->Items->Item[i)->Checked)
ShowMessage(" " +
ListViewl->Items->Item[i]->Caption);

,
. , ,
- .
HotTrack HotTrackStyles
.
HoverTime .
Selected . - . ,
- , OnDblClick ListView :
if (ListViewl->Seleoted != NULL)
ShowMessage{ListViewl->Selected->Caption);

if , - , .. , . , - (
).
Columns vsKeport
(. , . 1, . 2 -. 3.20 ) ShowColumnHeaders ( ), true. Columns
,
ListView
Columns .
,
. 3.22. Add New ( ) , Delete Selected ( ) , Move
Selected Up Move Selected Down ( ) .
. 3.22

'

*}

1.3
-
1 -. 1
2-. 2

, , . Caption
. Imagelndex
, . MinWidth MaxWidth .
.

186

Width. OnSectionResize.
.
ListView. , , WorkAreas,
[4].

3.6

3.6.1

C++Builder , . 3.6.
..

Image
()

Additional

: ,
.

PaintBox
(
)

System


,
.

DrawGrid
Additional
( )

Chart
(
)

Additional


TeeChart,
.

Chartfx
(
)

ActiveX

FIBook
(
Excel)

ActiveX

( ), Excel.

*.

VtChart
ActiveX
()
Animate
Win32
(
)

MediaPlayer System
( )

.

AVI, Windows ..

,
.

C++Builder

187

ProgressBar Win32
(
)


,
-

Gauge
(
)

,
, .

Samples

, , Canvas .
Image, PaintBox, Animate MediaPlayer
6. Canvas.

3.6.2 DrawGrid
StringGrid
DrawGrid , (. . 3.23).
StringGrid (. . 3.2.6),
DrawGrid. DrawGrid , , StringGrid, , ..
Cells, Cols, Kows, Objects. StringGrid , DrawGrid,
, .
- DrawGrid, , .

. 3.23
DrawGrid

:=

>

X
m
- -

to

Jf?
+

DrawGrid StringGrid, , StringGrid, , . 3.2.6.


DrawGrid StringGrid Canvas,
, . 6. CellRect,
, .

Windows::TRect

fastcall CellRect(int ACol, int ARow);

188

ACol AKow , 0,
. , . ,

DrawGridl->Canvas->CopyRect(DrawGridl->CellRect(1,1),
BitMap->Carwas,Rect(0,0,BitMap->Height,BitMap->Width));

CopyKect (. . 6 . 6.1.5.2.) (1,1) DrawGridl BitMap.


, 0. , , ,
.
DrawGrid StringGrid,
, , , .
, . 6, . 6.1.7,
OnPaint . DrawGrid .
DrawGrid OnDrawCell. . :
void
fastcall TForml::DrawGridlDrawCell(TObject *Sender,
int ACol, int ARow, TRect SRect, TGridDrawState State)
ACol ARow ,
. Rect TRect (. . 17.4)
. . State . ,
: gdSelected , gdFocused , , gdFixed
. State . ,
if (State.Contains(gdFocused) ...
else .. .

OnDrawCell. , ImageListl (. . 4.2):


void
f a s t c a l l TForml::DrawGridlDrawCell(Tobject Sender,
i n t ACol, int ARow, TRect SRect, TGridDrawState State)
{

int ind = ARow * DrawGridl->ColCount + ACol;'


if (ind <= ImageListl->Count - 1)
ImageListl->Draw(DrawGridl->Canvas, Rect.Left+10,
Rect.Top+10, ind, t r u e ) ;

)
ARow ACol
ColCount ImageListl,
. , Draw ImageListl, . 4.2. 10
.
, . 3.2.3.
,
, . 3.2.6.
,
.

C++Builder

189

3.6.3 Shape
Shape , .
Shape (), :
stRectangle

stRoundRect

stRoundSquare

stEUipse

stSquare

stCircle

'

. 3.24.
. 3.24
Shape

Shapes stCiicle
Bru>h->St;le-lSolid

Shape - .(Ellipse
eiuh->Styla b*BDiagonat

Shape = stSquate
Biuh->Style =* biD

.Shape = gtRoundSquare
:Brush->Slyle = bsCtost

Shape = itRectangle
B S l bDi

'Shape =VlRoundRect
Bfush->StylB bsFDiagonal

Brush (). TBrush, , :


(Brush.Color) (Brush.Style) . Style . 3.24.
Shape Pen (), . Brush
. 6. . 17.

3.6.4 Chart
Chart , (. 3.25). ,
, , , . Chart.
C++Builder , .
, , , , Chart,
, [3].
Chart Series TChartSeries
, .
. ,
.

190
. 3.25


:

()



(6)

,
, (, ) , , . Chart . ,
, , .
( . 3.25)
Chart . .
AllowPanning

,
. : pmNone , pmHorizontal, pmVertical pmBoth
, .

AllowZoom

, ! ( . 3.25
,
. 3.25 ).

Title

Foot

. . Text.

Frame

Legend

MarginLeft,
MarginRight,
MarginTop,
MarginBottom

, , .

BottomAxis,
LeftAxis,
RightAxis


, .
.

C++Builder

191

LeftWall,
BottomWall,
BackWall

, - .
(. . 3.25 , ).

SeriesList

, .

View3d

View3DOptions .
Chart3DPercent ( . 3.25 ).
,
,
. Chart
Edit Chart .
, . 3.25,
Chart. (. 3.26) Chart, .
, Series.
Add . (. 3.27), . Pie . Titles, , Legend ( ) , Panel .^, , 3D : , , ..
. 3.26
, Chart,
Series

j Sw
Swes | Qener^j | Tftss | Legendj Panel | Paampl Wals j 30

, Chart (. 3.28). , .
Series, " ,
. ,
Format Circled Pie,
Chart .

192

. 3.27

. 3.28
. 3.25

Marks Style , ,
: Value , Percent , Label .. . 3.25
Percent, General , .
, , Chart , Series Chart Clone,
Change () , , Bar. ,
. Series,
( , ).
,
Chart . ,
-. ^ ' ^ Line. -

C++Builder
, Axis Wolls .
.
, , .
, .
Series.
.
Clear .
Add:
long int Add(const double AValue,
const String ALabel, TColor AColor) ;
. AValue , ALabel ,
, AColor . ALabel ,
: "".
AddXY:
long int AddXY(const double AValue,
const String ALabel, TColor AColor);
. AXValue AYValue . ALabel AColor ,
Add.
, , , :
int 1=155;
int A2=251;
int A3=203;
int A4=404;
const Pi=3.14159;
Seriesl>Clear();
Se iesl->Add(Al,"
Se iesl->Add(A2,"
iesl>Add(A3,"
Se iesl>Add(A4,"
ies2->Clear();
Se ies3>Clear () ;
fo ( i n t i = 0; i <=

l",clYellow),
2",clBlue);
3",clRed);
4",clPurple);
100; i++)

Series2->AddXY(0.02*Pi*i,sin(0.02*Pi*i),"",clRed);
Series3->AddXY(0.02*Pi*i,cos(0.02*Pi*i),"",clBlue);
- ,
OnCreate . Clear ,
.
Add AddXY
, .
, , , ,
Seriesl Series4 Pie , ,
.
OnClick - , , ,
Chart.
Series4 ,

Series4->Assign(Seriesl) ;
Series4->Active = false;

194

, Seriesl, Series4. Series4.


Seriesl->Active = ! Seriesl->Active;
Series4->Active - ! Series4->Active;

. 3.25
.
Chart. , . ,
, ,
,
. .
C++Builder [3], .

3.6.5 Chartfx
C++Builder ActiveX ,
. , ,
. 3.3.4 FIBook.
. 3.15 , FIBook , .
ActiveX Chartfx.
(. 3.29). ( . 3.25
Data Editor), , .chf ,
Clipboard . (, Word) ..
ActiveX, Chartfx

Properties
().
(. . 3.30), . , , .
. 3.29

Chartfx

_-Jnl*J

195

C++Builder
3.30
)
Chartfx:
Data Values () ()

Styles
|

Data Values

Labels j
| XlView

Element! I
DalaValics

|
| Tools

Lines

This dialog lets you change numenc values


contained in the chart, just wfite the desired value
foi each obiect listed.

Sljtes |

Labds

| DalaVabes | Tools
Efemenls |

Jfcwpr.

|75

>t @Sm
i Sun

"" Anal
'f|' Anal8altic
7fc Anal Black
f( Anal CE

L,,e8

Appearance j 3DViem

:
d

" .

"
:

Series Data Values (. 3.30 ) (


NSeries) (
. 3.29 2). Points ( NValues) (
. 3.29 4). Elements - ( Value Text, . 3.29 40 ), - (
From Calar, . 3.29 0-20 20-40), ( ID Width Text).
, , , , .
(. 3.30 ).
, , , .
, (, TopFont
), , ,
. .
(. . 3.29). -

196

. xhf . Clipboard, - (, Word) . .


, . . , .. . ,
, , Data Editor. ,
,
. ,
. , , Data Editor.
, .
ActiveX
VtChart. He , , ,
Chartfx, ,
. , , - . , , VtChart, Chartfx, ,
Chart,
.

3.6.6
ProgressBar CGauge
ProgressBar Win32 CGauge Samples , , , , , .. ProgressBar CGauge . 3.31.
. 3.31

ProgressBar CGauge

C++Builder

197

, :

ProgressBar CGauge

MaxValue

(Position, Progress), . 100.

Min

Min Value

(Position, Progress), .

Position

Progress

, , Min Min Value ,


MaxValue . ,
.
( true)
. . 3.31 ProgressBar Smooth = true,
false.

Smooth

Step

,
Steplt. 10.
: pbHorizontaJ , pbVertical . pb Vertical, (. . 3.31 ).

Orientation

ForeColor

ShowText

Kind

: gkHorizontalBar
, gkVerticalBar ,
gkPie , gkNeedle
, gkText .

, Position ProgressBar Progress CGauge. , Count (


, , - ),
Current, ,
(.. 0 100),
ProgressBarl->Position - 100 * Current / Count;
CGaugel->Progress = 100 * Current / Count;

ProgressBar CGauge.
: Count, Current. :
CGaugel->MaxValue = Count;
CGaugel->Progress = Current;

198

ProgressBar , : StepBy(Delta: Integer)


Delta, Steplt , Step. Steplt:
ProgressBarl->Max = Count;
ProgressBarl->Step = 1;
roaressBarl->StepIt();

3.7 , ,
3.7.1
, ,
. . 3.7
. ,
, . 9. UpDown . 3.3.2.
3.7. ,

Ii

lasei

<*

Button
,
Standard

(
.
)
BitBtn
Additional ,
( (, ).
)
SpeedButton
(

)

Additional

,
.

RadioGroup
( )

Standard


GroupBox
RadioButton;
.
,
.

RadioButton Standard
()

,
.
, (,
..).

C++Builder

GroupBox
(
)

.-11 i-i


Standard

,
, , !
RadioButton, Checkbox ..

UpDown
Win32
(-)

-, Edit .

Checkbox
(

Standard

CheckListBox Additional
( )


ListBox CheckBox .

()

System

Scrollbar
(
)

Standard

Windows
.

Timer
()

Win32

,
.

,
Button , BitBtn.
SpeedButton
, .
RadioGroup ,
. , RadioButton, GroupBox. , , , Checkbox.
, , ,
Action. ,
, C++Builder.
. , Action. , . 4.

3.7.2 Button BitBtn


., 3.32 Button, BitBtn SpeedButton. , , Button ( . 3.32

200

), Standard.
BitBtn ( . 3.32 ), , ,
. , .
. 3.32

Button

\ SpeedButtofi

BitBtn
; Layout-blGlyphLeil

: LayouNblGlyphBottom
|

%t

.[)1

Caption ().

, . ,
, "&.". , .
Alt .
, -
, Caption &. . Alt-B, .
OnClick, .
,
. , .
. 5, . 5.3.
OnClick ,
Action - . 3.7.1, 4.
Cancel, true, , Esc .
true
, , Esc.
Default, true, , Enter ,
. , ,
- .
Enter , - . Default true,
Enter , (. . 5.1.8).
ModalResult , . 5.5.2.
mrNone.
, , Click. , ..

C++Builder

201

OsCliek. , , -
-**: . , , ,
Z'li & "" "" >: , OnClick Buttonl. , Hart :;:: , .
^:-: , KeyPreview
= true (. . 5.3.2). OnKeyPresss
--.
if ((==')||(=='')) Buttonl->Click();

"" "",
Buttonl.
Button, BitBtn. BitBtn.
Glyph.
Glyph ,
. 3.33. Load,
.bmp,
. , C++Builder . \lmages\Buttons,
Images C++Builder ...\Program Files\Common Files\
Borland\Barland Shared.
. 3.33

Load
, .
16 16. . , Enabled false.
.
SpeedButton,
, .
. NumGlyphs,
.
. . 6.1.2.3.

Margin, Layout Spacing. Margin -1 ( ), . -

202

Layout, : blGlyphLeft (, . BitBtn . 3.32), blGlyphRight (),


blGlyphTop (), blGlyphBottom ( . BitBtn
. 3.32). Margin > 0, Layout
,
, Margin.
Spacing , . Spacing = 4. Spacing = 0,
.
Spacing = 1, .
BitBtn Kind . bkCustom .
: bkOK, bkCancel, bkHelp, bkYes,
bkNo, bkClose, bkAbort, bkRetry, bklgnore, bkAll. , , .
- . -,
. -, .
, , . .

3.7.3 SpeedButton
SpeedButton

(. . 3.32). , , , .
SpeedButton, , Caption
, , . Glyph
, . 3.7.2 BitBtn. NumGlyphs , Layout
Margin , Spacing
(, , -
).
SpeedButton Grouplndex (
), AllowAllUp ( )
Down ( ). Grouplndex = 0,
, Button BitBtn. , . AllowAllUp Down .
Grouplndex > 0 AllowAllUp = true, .

( , ,
AllowAllUp = true). Down
true, .
, GroupIndex, . , ,

C++Builder

.
AllowAHUp. true, , , .
AllowAHUp false, . , , , OnClick, .
Down: true, . OnClick
Down ,
.

3.7.4 RadioGroup,
RadioButton GroupBox
,
. , , ,
, . ,
, .
. . 3.34.
. 3.34

RadioGroup

GtoupBox + RadioButton
: !

i* |^ 1

" . 1 3)


; .

2 4

" 3
4 1

RadioGmup -

* 1

1 '&

CheckBox: ^ 1

~ 2

RadioGroup . ,
. i;.'.!ie.iH (.
. 3.34) Caption. Items, TStrings. ,
, . 3.2.4 (. 3.6).
, , .
. , RadioGroup . 3.34 Items :

1
2
3

'

204

, Items, ( 17), Columns.


Columns = 1, .. . . 3.30
Columns = 3.
, ,
Itemlndex, . ,
C++Builder, 0. Itemlndex = - 1 , . ,
- ( ), Itemlndex . , , Itemlndex
.
RadioGroup , . ,
(
) . , . 3.34
.
: , . , . A RadioGroup .
, , , 5.
.
RadioButton, GroupBox
( . 3.34). GroupBox ,
RadioGroup,
Caption. .
, , RadioButton.
RadioButton , , .
CheckBox. , .
, GroupBox.
RadioButton. Caption
, . Alignment ,
: taLeftJustify , taRightJustify ( ). Checked , , . ,
, Checked true . , , true Checked .
RadioButton GroupBox,
. 3.34, RadioGroup .
RadioButton GroupBox,
, .
,
. , , , . ,
, , ,
.. Checked true.

C+-i Builder

205

3.7.5 CheckBox CheckListBox


CheckBox (. . 3.34, . 3.7.4)
, - , .
,
: ( ), ( ) ( ).
State: cbChecked, cbGrayed, cbUnchecked. , AllowGrayed true.
AllowGrayed = false ( ),
: . State, AllowGrayed .
,
- . ,
, - , ,
, ,
.
State,
Checked. Checked true, , ..
State = cbChecked. Checked false, State cbUnchecked
cbGrayed. Checked true State cbChecked.
, CheckBox
Caption, Alignment.
, CheckListBox.
. 3.2.5 List Box,
, (. . 3.7).
, CheckListBox ListBox, , ,
, . 3.2.5.
: State Checked. ,
. Count (
). 0, Count 1.
State Checked , . ,
CheckListBoxl->Checked[l] = t r u e ;
CheckListBoxl->State[2] = cbGrayed;

CheckListBoxl , (,
0).

for (int i = 0; i < CheckListBoxl->Items->Count; i++)


if (CheckListBoxl->Checked[i]) ...

,
- (
).
CheckListBox OnClickCheck, . .

206

3.7.6
TrackBar ScrollBar
TrackBar ,
. , - : , .. . 3.35 . , , , , - .
. 3.35

. J
!

JQlxl

Position.
.
Position,
, .
OnChange.
Position - .
Position , ,
Min . Min = 0, = 10,
Position 11 0 10.
, Position MinMax.
Orientation : trHorizontal , trVertical .
TickMarks
: tniBottomRight
( . 3.35), tmTopLeft ( . 3.35), tmBoth ( . 3.35).
TickStyle . : tsAuto , tsNone , tsManual
SetTick(Value: Integer), , Value. , TickStyle = tsManual.
TickStyle = tsAuto Frequency. , Position
. , Frequency = 2,
( Frequency . 3.35).
LineSize PageSize , ,

PageUp PageDown.

C++Builder

207

SelStart SelEnd (. . 3.35), -


, , .
.
ScrollBar, . Windows. (,
C++Builder ), ,
.
ScrollBar Position, Min ,
. Kind, sbHorizontal sbVertical, Orientation .
, : SmallChangc LargeChange.
, PageUp
PageDown.
, OnScroll.
ScrollPos , , , ScrollCode, . :
scLineUp,
scLineDown

:

.

scPageUp,
scPageDown

:
PageUp PogeDown.

scPosition

scTrack

scTop,
scBottom

scEndScroll

ScrollPos , , ,
, ScrollPos.

3.7.7 HeaderControl Header


HeaderControl Header ,
. , .
Align HeaderControl alTop, . , , alNone .
HeaderControl Sections. THeaderSection,

208

. Sections , HeaderControl. , . 3.5.3


. 3.22.
. . .
, , . Text
. MinWidth MaxWidth .
.
Width. OnSectionResize.
, , : - , , ..
AllowClick, true,
. OnSectionClick HeaderControl,
, .
Style hsText Text, hsOwnerDraw , , OnDrawSection HeaderControl.
Header ,
HeaderControl. Sections TStrings
, ,
.. , Header 16- .
. [4].

3.7.8 Timer
Timer . : , - , , , - ,
,
, .
,
. , : Interval Enabled . Interval . , Interval,
, Interval , , OnTimer. .
Interval = 0 Enabled = false, .
Enabled = true,
Interval, Interval,
Enabled = false.

C++Builder

209

, , 5
;-^;-:: , ,
, Interval = 5000,
OnTimer Close, .
,
, , 5 ,
, . (Enabled = true), Interval 0. , ,
,
Timerl->Interval = 5000;

5 OnTimer.

Timerl->Interval = 0;

, .

Enabled. Interval = 5000
Enabled = false. ,
Timerl->Enabled = true;

OnTimer, 5 ,
Timerl->Enabled = false;

.
Interval,
. , ,
.

3.8
3.8.1 MainMenu
C++Builder , : MainMenu
, PopupMenu .
Standard. .
MainMenu.
, ..
, , .
MainMenu.
Menu.
MainMenu , . Menu . , .
Items. , MainMenu Items . ,

210

. 3.36. . . 3.37
, . 3.36.
. 3.36

. $

:. ..,

F2

.,,

,..

. . ' 1 . 1 1 1 1 1 1 " " " " " " " " 1 1


2

. 3.37

_.

|
&

...
,.
!j
.,
...
1
2

, , (.
. 3.36). , , . ,
. -
Insert,
. Create
Submenu, (. . 3.36, 3.37).

. , , .. Items, TMenuItem,
, , .
Caption . ,
(. . 3.7.2),
. Caption "", (.
. 3.36 3.37 ).
Name , .
, N21. MFile,
MOpen, MSave ..
Shortcut
, , ,

C++Builder

2V1

, . ,
Shortcut
. (. . 3.36, 3.37). . 3.8.3 .
Default , , .. , .
, (. . 3.36, 3.37).
Break ,
. Break: mbNone ( ), mbBarBreak mbBreak
,
(mbBarBreak) (mbBreak).
Checked, true, ,
, , (.
. 3.36, 3.37 ). C++Builder 6
AutoCheck. true,
, , .
C++Builder
OnClick
MAutoSave->Checked = ! MAutoSave->Checked;

( , MAutoSave).
, , Radioltem. , true, , ,
Grouplndex. GroupIndex 0. ,
Grouplndex Radioltem = true, , ( . 3.36,
3.37 Radioltem true 1 2.
Grouplndex). Checked = true, Checked false.
, , ( C++Builder 6) true AutoCheck.
:
, .
, ,
. , . , AutoCheck ( false) Checked . ,
:
if

(! ((TMenuItem *)Sender)->Checked)
[(TMenuItem *)Sender)->Checked = t r u e ;

,
. ( Sender . . 1.9.6.2) .
, , .

212


Enabled () Visible (). Enabled = false, . Visible =
false, , , . Enabled Visible ,
.
C++Builder . Bitmap Image-Index.
,
. , ImageList (. . 4.2).
Images MainMenu. 0.
1 ( ), .
OnCIick,
.
,
. Action.
3.7.2, 4. , ,
,
, .
OnCIick, . 4, , .

. , , MainMenu. , , . ,
.
:
MDI ,
. MDI Word Excel. . 5.1.2 5.5.4. : . MDI
. AutoMerge
TMainMenu. , ,
AutoMerge true. AutoMerge false.
Grouplndex.
Grouplndex,
. ,
Grouplndex. ,
Grouplndex, - , .
Grouplndex. GroupIndex , ,
.

C++Builder

213

, , Grouplndex:
1 2
2 - 4 1 - 3

I
2

! '
1 3

, ,
:
1 - 2 - 3 - 4
1 1 1 1
1 2
3
4

,
Grouplndex. , .
, , , Grouplndex.
, MDI. , .
(. . 3.38), , .
, . ,
.
. 3.38
MDI


1 1
2 Z
3 3

,
WindowMenu MDI , . , . . 3.38 ,
.
. 5.1.6 ,
Windows. . Save As Template ,
.
, . 3.39.
(), .
, Insert
From Template.

214

. 3.39

Edit Me
File Menu
File Menu (tor TexlEdil Example)
Help Menu
Help Menu (Expanded)
MDI Frame Menu
Wndow Menu

MainMenu. . 3.8.3

. 4 .

C++Builder [3].

3.8.2
PopupMenu
. ,
, ,
. ,
.
PopupMenu. , PopupMenu
. : , ,
. PopupMenu, ,
PopupMenu,
.

, PopupMenu,
, . . , . ,
PopupMenu, Select Menu ( ).
, .
( Shift
, Ctrl , ).
, Ctrl-C. , Select Menu . , ,
Ctrl-V. .
PopupMenu MainMenu. :
.

C++Builder

3.8.3 HotKey
HotKey, Win32, ,
, .
, ShortCut.
HotKey Edit.
, >:
TShortCut, . , Ctrl-, HotKey Ctrl - .
HotKey,
Alt-A. Shortcut - . ,
MOpen->ShortCut = HotKeyl->HotKey;

, HotKeyl.
Modifiers ."=^:, . , :;-:^
hkShift, hkCtrl, hkAlt, bkExt,
Shift, Ctrl, Alt, Extra. Modifiers =[hkAIt]. , ,
,
:
HotKeyl->Modifiers,Clear() ;
HotKeyl->Modifiers << hkCtrl;
InvalidKeys .
, hcNoae, kcShift,
hcCtrl, hcAlt, hcShiftCtrl, hcShiftAlt, hcCtrlAlt, hcShiftCtrlAIt,
Shift, Ctrl, Alt, Shift-Ctrl, ShA-All, Grf-Ah,
Shift-Ctrl-Alt.
HotKey .
, MainMenu ,
. , , MainMenu:
(.. );
Caption ;
.
, .
, MainMenu
, . - .
.
( File | New rorrr). .

E'orm2->ShowModal () ;

.. , -

216

. , Unitl
Unit2.
include "Unit2.h"

, Unitl, File | Use Unit , Unit2. Unit2 Unitl, Unit2 Unitl.


. ,
. 3.40. ListBox (. .
3.2.5): ListBoxl, , ListBox2,
, . HotKey Button, .
HotKey HotKey,
.
. 3.40

.
|

,
ListBoxl ListBox2

Forml. :
void
fastcall TForm2::FormShow(TObject
{
/* ListBoxl
OnShow Form2 */

*Sender)

ListBoxl->Clear{) ;
for(int i = 0; i < Forml->MainMenul->Items->Count; i++)
LiatBoxl->Itema->Add(
Forml->MainMenul->Itema->Itsms(ij->Caption);
ListBoxl->ItsrnIndex = 0;
// ListBox2
ListBoxlClick(Sender) ;
//
void
fastcall TForm2::ListBoxlClick(TObjsct Sender)
{
/* ListBox2
MainMenul->Items->Items[ListBoxl->ItemIndex],
ListBoxl
OnShow Form2 */
ListBox2->Clear() ;

C++Builder

217

fcr(int i = 0,- i < Forml->MainMenul->Items->Iterns [


LiatBoxl->ItemIndex]->Count; i++)
ListBox2->Items->Add (Forml->MainMenul->Itema->Iterns[
ListBoxl->ItemIndex]->Items[i]->Caption);
LiatBox2->ItsmIndex = 0;
// ListBox2Click
ListBox2Click(Sender);

)
//
void
fastcall TForm2::LiatBox2Click(TObjsct *Sender)
(
/* ListBox2
HotKeyl */

HotKeyl->HotKey = Forml->MainMenul->Iterns->Itema [
LiatBoxl->ItemIndex]->Items[
ListBox2->ltemIndex]->shortCut;
)
//

void _ fastcall TForm2::ButtonlClick(TOb]ect Sender)


{

/*
*/

Forml->MainMenul->Itema->Itema[
ListBoxl->ItemIndex]->Items[ListBox2->ItemIndex]->ShortCut
= HotKeyl->HotKsy;
Cloae () ;
)
OnShow Form2 ListBoxl . 0 Forml>MainMenul>Items>Count 1. Count .
ListBoxl
ListBox2. Forml>MainMenul>Items>Items[ListBoxl>ltemlndex]>
Items[i]. Forml->MainMenul >Items>Items[ListBoxl->
Itemlndex] , ListBoxl.
.
Items[i] i. ListBox2Click, HotKeyl.
ListBox2
HotKeyl . , HotKeyl .
HotKeyl ,
. .
.

3.9
3.9.1
, . , , ,

218

, .
. 3.7.4 .
. 3.8 ,
, C++Builder 6. , ActionTooIBar, . 4, . 4.5.
3.8.

GroupBox
Standard
( )

,
, , RadioButton,
Checkbox ..

Panel
()

Standard


.

, ,
.

Bevel
()

Additiona

,
.

.

ScrollBox
Additiona
( )

Splitter
Additional
( )

ControlBar
( )

Additional

TabControl
( )
PageControl
( )

Win32


Windows,
.

Win32


Windows,
,
.

_J

StatusBar
( )

Win32

,
.

ToolBar
( )

Win32

ill4

C++Builder

( )

Win32

, .
I

PageScroIIer
Win32
( )


, , .

ActionTooIBar
Additional
( )

, ActionManager.
C++Builder 6.

TabSet
( )

Win3.1

TabbedNotebook Win3.1
( )

Notebook
( )

Win3.1


, TabSet.

Frame
()

Standard



. ,
.

3.9.2 Panel,
GroupBox, Bevel, ScrollBox, Splitter
. 3.41 , ,
Panel, GroupBox, Bevel, ScrollBox.
Panel .
.
. 3.41

Panel
Bevellnn.,.b,Nons. BevsO
l utefbvRaK
i ul

Gio upBc

,8D,d5l,l-b.Non.:

kevellm

'. BeveO
l utesibvRaued

BaideiStyJe-biSinsJe
1
Llevel

Bevellnne=bvNt>n
.
(

D e v e l O u t e i ^ b v R a i i e d-

SevellnneibvNone.

BevelOulm-bvlivsed

Bord~Sli.l.b.HMn.
meied
jsBux

a i J 1

| Bevellnnei-bvNon..8., .,.,. B , d . , . b . N n .
I
| Bevelln * H - , B e v e l O u t e i - b v R a n e d BaideiStyle-bsNone
1

Be veilinei-bvtio e,

S l y f c

.d

sLiox

Style-bsLoweied
Shepe-bsFieniB

Style^biLoweied
Shape-bsSpacef

I 3 T Q Scroll . . P

B c v d Q u r e r i ' b v N o n e , BofderStyle-biHone
L

220

Panel .
(, , ), .
. Panel , .., , .
, RadioButton (. . 3.7.44). , , :
. SpeedButton (. .
3.7.3), Grouplndex.
SpeedButton, , Grouplndex.
. 5, . 5.2.
Panel. Panel
Bevellnner , BevelOuter
, BevelWidth , BorderStyle , BorderWidth .
. 3.41.
. , ( None).
.
( Caption), , , , ,
.

. 3.2.2, . 5.2. , . C++Builder Splitter,
. Beveled ResizeStyle, , MinSize,
, . 5.2.3.
GroupBox
, Panel. (.
. 3.41), . ,
, GroupBox .
Bevel , . , Bevel . Bevel
. . 3.41 Bevel.
Bevel Style, bsLowered , bsRaised .'1
Shape, :
bsBox , bsFrame , bsSpacer ,
bsTopLine, bsBottomLine, bsLeftLine, bsRightLine ,
, . Style
.
. 3.41.

C++Builder

221

ScrolIBox .
, , , ScrolIBox. , ScrolIBox
, . . 3.41
ScrolIBox : ScrolIBox,
. ScrolIBox .
ScrolIBox , ,
,
ScrolIBox .
ScrolIBox
, , , , . ScrolIBox , , . . ScrollBox .
BorderStyle ScrolIBox. AutoScroll
,
, . -
, HorzScrollBar VertScrollBar .
, , Range . ,
Smooth true.
Increment.

3.9.3 TabControl,
PageControl, TabSet, TabbedNotebook, Notebook
;:-..-:: ,
. . 3.42 PageControl.
.
. 3.42

PageControl

MultiLine- lalte

Sye

fe ) i | 1
:

i < i

>

|
l"

';

'""

_ _ O K j

*3i

taTahs

&

DK.

S t y l e > t s F l a t B u t t o n s

[&~^7;

f?

(^

E^j 1

**-.

!^1

Style =tsButtons
|&

Mu til ine -- due

2 j @ 3

: "


: (

t?
f"

[?

222

PageControl . , .
: New Page , Next Page , Previous Page .
TTabSheet.
, , .. , ,
, , . :
Name

Caption

Pagelndex

Imagelndex

PageControl :
Style

: tsTabs ( . 3.42), tsButtons


( . 3.42), tsFlatButtons ( . 3.42).

MultiLine

, ,
( . 3.42
, MultiLine = false, true; MultiLine = false
C++Builder).

TabPosition

: tpBottom , tpLeft , tpRight tpTop


(
. 3.42).

TabHeight

TabWidth

. 0,
.

Images

ImageList (. . 4.2), . Imagelndex , .

ScrollOpposite
( , ).
ActivePage

Pages
[int Index]

( 0).
.

PageCount

. .

, ,
, , .

C++Builder

223

C+^Builder. OnChanging OnChange.



. AllowChange . AllowChange = false, .
OnChange .
TabControl.
, PageControl, : Style, MultiLine,
TabPosition, TabHeight, TabWidth, Images, ScrollOpposite, OnChanging OnChange. PageControl , TabControl ().
. OnChanging OnChange, ,
.
MultySelect, .
true,
.
Tabs TStrings.
. ,
. Tablndex. , .
OnChanging OnChange , , .
TabControl ,
. , , TabControl , PageControl.
, , TabControl
OnChange :
if (TabControll->TabIndex =- 0)
Panel2->Visible = false;
else Panel2->Visible = true;

Fanel2 , (Tablndex = 0)
.
PageControl , PageControl. A TabControl ,
- .
TabSet, TabbedNotebook
Notebook. 32-
.
TabbedNotebook PageControl. -. Pages, .
ActivePage . Pagelndex
(0 ). , , ActivePage, Pagelndex.
OnChange, , NewTab, , AllowChange .
AllowChange = false.

224

TabbedNotebook
: () Notebook TabSet.
. TabSet 32- TabControl.
,
. Tabs ranaTStrings. . StartMargin
EndMargin . . TabSet
. AutoScroll
, , PageControl TabControl MultiLine = false. Tablndex, OnChange,
TabbedNotebook.
Notebook ,
Pages, TabbedNotebook. Pagelndex. .
- , ,
.. Notebook TabSet , ,' , TabbedNotebook. OnChange
TabSet
Notebookl->PageIndex = NewTab;
: TabbedNotebook.

3.9.4
ToolBar PageScroller
, ,
.
Panel, SpeedButton .
. . , , , , .
,
, ToolBar. ,
, . 3.43.
. 3.43
ToolBar
...
1
2

C++Builder

Z2S

ToolBar , , Align .
, , Align = alNone,
.
, ,
.
.
New Button.
TTooLButton. ,
, .
Style,
tbsButton . .
SpeedButton.
Glyph, Imagelndex.
, ImageList (. .
4.2). , Images, Disabledlmages ( ) Hotlmages (
, ).
Menultem
(. . 3.8.1 3.8.2), . , ( Hint),
Hint .
Enabled () Visible (). ,
Menultem. , .
Menultem, , .
Wrap, true, ,
.
Style, . Style =
tbsCheck , . . SpeedButton AllowAllUp Down (. . 3.7.3). Grouped = true,
, .
Style = tbsDropDown . . Menultem , .
. 3.43 tbsDropDown .
Menultem , .
3.8.1 . 3.37. Style = tbsDropDown
Menultem DropDownMenu,
( PopupMenu), .
Style = tbsSeparator , .
Style = tbsDivider . , New Separator.

226

Indeterminate
. true ,
.
Marked .
. . ,
. ,
ComboBox ( . 3.43), CSpinEdit .
ButtonHeight
ButtonWidth , Wrapable , . , .
, : BorderWidth , Edgelnner EdgeOuter ( ), EdgeBorders (, , , ).

.
. C++Builder. PageScroller, .
, PageScroller , . , - . . 3.9.2 ScrollBox. : PageScroller
. PageScroller
ScrollBox.
PageScroller . 3.44.
, . 3.43. , . 3.43. , PageScroller .
. 3.44

PageScroller

] - '

G-|L

PageScroller Control. , PageScroller.


, , , PageScroller . , ,
PageScroller Control. PageScroller , , .

+-Builder

Margin PageScroIler i n-::-


, PageScroIler ^.
. , :->
Margin . ": > ~.~ .
AutoScrolI , ^~. :
, .
. , AutoScrolI false, ,

3.9.5
CoolBar ControlBar
.
. C++Builder 6,
. , ..
CoolBar. , (bands). TooIBar : , ..
CoolBar.
, , .
.
. .
, , Edit.
CoolBar ,
CoolBar. ,
. ,
,
. (.
. 3.45).
. 3.45

CoolBar

-IQLxJ

I; > 1 |Edi(l

Ol 1 [E d

.
. 3.5.3 (. . 3.22). :
Bands, CoolBar , Bands Editor. , . .
Control . Break

228

, CoolBar, . , . 3.45,
Break = true, Break =
false.
Text , . . 1, 2, 1, 2 . 3.45
.
Text ( ) ImageIndex ImageList (. . 4.2),
Images. (. . 3.45).
MinHeight MinWidth
.
FixedSize ,
. FixedSize = false,
.. . , FixedSize = true.
CoolBar ,
, BandMaximize. , , : bmNone , bmClick
, bmDblClick . , -, bmDblClick bmNone, bmClick
.
FixedOrder, true,
. ,
, , false,
.
Vertical
. Vertical = false, .
, ,
. , .
ControlBar.
CoolBar
Drag&Doc,
. 5, . 5.4.2.
ControlBar.
ControlBar
, , TooIBar Edit. (. . 3.46), , ControlBar, , Drag&Doc.
, ControlBar, DragMode =
dmAutomatic DragKind = dkDock. Drag&Doc (. . 5.4.2).
ControlBar RowSize RowSnap
. RowSize , , a RowSnap . AutoDrag , ( true),
ControlBar.

. AutoDrag true, ^ , ^- .-

,---,

, cninm.onv^ )'-

C++Builder

(. . 3.46 ).
ControlBar, .
Drag&Doc . 5.4.2.
. 3.46

ControlBar ()
()

)
Edit2

3.9.6 StatusBar
StatusBar ,
Windows. .
. 3.2.4, . 3.5.
SimplePanel ,
. SimplePanel - true, , SimpleText.
SimplePanel = false, , Panels. SizeGrip ,
.
TStatusPanels.
.
. 3.5.3 (. . 3.22).
:
Panels, StatusBar
, Panels Editor.
, .
.
Text, . ,
. Width ().

Panels Items. , :
S t a t u s B a r l - > P a n e l s - > I t e m s [ 0 ] - > T e x t - " 1";

1 .
Count
Panels. , :
for (int i 0; i < StatusBarl->Panels->Count; i++)
(
StacjsBarl->Panels->lteras[i]->Text = " " ;

. 3.5
RichEdit, .

230

, , ,
, .
, .
Down, OnKeyUp, OnMouseDown OnMouseUp RichEditl
OnResize :
StatusBarl->panels->Items[0]->Text =
IntToStr((int)RichEditl->CaretPos.y+1)+": ,"+
IntToStr((int)RichEditl-CaretPos.x+l);
if (RichEditl->Modified)
Statu5Barl->Panels->Items[1]->Text = ".";
else StatusBarl->Panel5->Item5[1]->Text = "";
.
. 5.1.9.

3.9.7
C++Builder 5, VCL Frame
, .
.
, :
, ;
.;
, , ,
;
, ,
.
, :
Windows
;
, , , , .
, , .. ,
, .
File | New | Frame
File | New | Other Frame New . ,
, :
include "Unit2.h"
TFrame2 *Frame2;
/*
, , ,
.
.
, ,

//
fastcall TFrame2::TFrame2(TComponent* Owner)
: TFrame(Owner)

C++Builder

231

:
//
class TFran\e2 : public TFrame
{
published:
// IDE-managed Components

7*

C++Builder , .

V
private: // User declarations
/*
.
, ,

V
public:

// User declarations

.
,
*/
//
fastcall TFrame2(TComponent* Owner);
);

,
. , ,
.
. :
int A;
, ,
static. :
static int A;

, ,
i n t TFrame2::A = 0;

TFrame2 "::". ,
. , - , , , . 14.
, ,
, , ..
, , , .
- Sew j Frame.
GroupBox (. . 3.9.2). Label Button. ,
. 3.47, (Caption)
BSetup, Bine, BShow.
, ,
.
:

232

. 3.47

class TFrame2 : public TFrame


{
published:
// IDE-managed Components
TGroupBox *GroupBoxl;
TLabel "Labell;
TButton *BSetup,TButton *BInc;
TButton *BShow;
void
fastcall BSetupClick(TObject *Sender);
void
fastcall BIncClick(TObject *Sender);
void
fastcall BShowClick(TObject *Sender);
private:
// User declarations
//
int ;
public:
// User declarations
//
int ;
static int ;
fastcall TFrame2(TComponent* Owner);
);
//
int TFrame2;:C = 1;

:
TFrame2 *Frame2;
// D
int D;
//
.
fastcall TFrame2::TFrame2(TComponent* Owner)
: TFrame(Owner)
//
void
fastcall TFrame2::BSetupClick(TObject *Sender)
{
A = = = D =1;
Labell->Caption = "A=" + IntToStr(A) + " B=" + IntToStr(B) +
" C=" + IntToStr(C) + " D=" + IntToStr(D);
//
void
fastcall TFrame2::BIncClick(TObject *Sender)
{
A += 1;
+- 1;

C++Builder

233

+= 1;
D += 1;
Labell->Caption = "=" + IntToStr() + " =" - IntToStr() +
" =" + IntToStr() + " D=" - IntTcStr(D);

void
fastcall TFrame2::BShowClick(TObject *Sender)
{
J J a b e l l - > C a p t i o n = "A-" + I n t T o S t r (A) + " B=" + I n t T o S t r (B) +
" C=" + IntToStr(C) + " D=" + I n t T o S t r ( D ) ;
}

:
;
;
; ;

;
"::" ; ,
D ; ;
D,

1 ( TFrame2::BSetupClick), 1 ( TFrame2::BIncClick), ( TFrame2::BShowClick).
. Frame ( Standard). ,
, .
Frame2 . , , . (. 3.48). Show, , Align alTop Alignment taCenter.
, .
- . , (Caption) GroupBox (. . 3.48 ). , ,
. . . (. 3.47) (Font>Style) . ,
.
.
. , ,
, . , .

234

. 3.48
: ()
()

)
Labeli
1

: 1

; Label!

LabeD
Selup

Setup

Inc

Inc

Stiow

Show

Sho

6)

JSJ*J
; 1
i A-2 B-Z C-5 D=5

. . , :
IFraroe2 *Frame21;
TFraroe2 *Frame22;

. , , . Frame21 Frame22. , , . ,
BShow, .

Labell->Caption = "(Frame21)=" + IntToStr(Frame21->B) +
", B(Frame22)=" + IntToStr(Frame22->B) +
", C=" + IntToStr(TFrame2::C);

Label 1 . TFrame2::C.
: Frame21>C
Frame22>C. .
D ,
. ,
.
, .
, (. . 3.48 ), , D .
D.

C++Builder

235

. . , . 3.49. GroupBox, , , ,
Windows . , .
,
, .
. 3.49

.
File | New | Frame. GroupBox. Edit,
Button, Label, OpenDialog (. . 3.10.2) ApplicationEvents (. . 4.6). , . 3.49.
Filter OpenDialog - , , )*.*. Showffint ( ) Edit Button true. Button Hint, , | .
OnShowHint ApplicationEvents
:
if (Hintlnfo.HintControl == Editl)
if (Labell->Canvas->TextWidth(Editl->Text) > Editl->ClientWidth)
{
HintStr = Editl->Text;
ApplicationEventdl->CancelDispatch();
)

, , ,
(Hintlnfo.HintControl) Editl. , , Editl. , (HintStr) , , ( CancelDispatch), ApplicationEvents, . . . 4.6.
FileName
AnsiString, .

if (OpenDialogl->Execute() )
{
Editl->Text = OpenDialogl->FileName;
FileName = OpenDialogl->FileNarae;

236


Editl FileName , ,
.
OnExit Editl
FileName = Editl->Text;

FileName ,
, .
. ,
. ,
, .
, ,
(. 3.50 ).
. 3.50
:
() ()

-la(x!

4.

... j

)
;

I
!

[FTre,,,

\Fiame \Unii
F

... 1
fameWntl.cpp!

\1

...

- ,
, ..
, (. 3.50 ).
,
.
Add To Repository Add
Palette. - , , ,
. , , . - , ,
. ,
. . 2, . 2.6.

237

C++Builder

3.10
3.10.1
: , , ,
..
C++Builder ,
, . Dialogs.
. , , - ,
. C++Builder , .
.
. 3.9 , , , .

3.9.

OpenDialog

Dialogs

SaveDialog

Dialogs

OpenPictureDialog

Dialogs

,
.

SavePictureDialog

Dialogs

FontDialog

Dialogs

ColorDialog

Dialogs

ColorBox

Additional



. C++Builder 6.

238

PrintDialog

Dialogs

Printers etupDialog Dialogs


FindDialog

Dialogs

ReplaceDialog

Dialogs

CustomizeDlg
Additional

,
. C++Builder 6.

FileListBox
( )
Directory ListBox
( )

Win 3.1

Win 3.1

DriveComboBox
( )
FilterComboBox
( )

Win 3.1

Win 3.1

Samples

, .

CDirectoryOutline
( )

, . , Windows
. -. , Windows ,
.
, ,
Execute. ,
- , true. ,
.
Esc, Execute false.
;
if (< - > -> Executed)
<.,

C++Builder

239

3.10.2
OpenDialog, SaveDialog,
OpenPictureDialog, SavePictureDialog
OpenDialog SaveDialog ..., , , . . 3.51 3.52.
. 3.51

z\ * ft) Cf ES-

] B5_12d
.oc
15_13 doc
1~*B6_3 doc
~~8
i6_7,doe
pB5_Zd
.oc

BS J5.doc
S]B5.i6.doe
W] B6J.doc
H]86_1NeM.dtic
ff)B6_?,d(K
B]E6_6 doc

B6_7.doc
jjfe 9d
.oc ]
] B6_9.doc
ff]B5J0.doc

|66.3*,c
." doc]
/

. 3.52

) Cf -

B"l85 * dx
-$6_LNew.do a3e5_7.doc
' "$B6_i,doc
-iBb_2.doc JBS_1O dQC
1
jse_3doc SJB5JL.doc
- iBt_7 doc ] B5_12.doc
] B5J3.doc
^]B5_2 doc
}5 J4.doc
a]B5_3d

f^ G _d doc

Inn

( [ lid.^toc]

S]85 15.doc
S]B5_16doc
B6_l.doc
S] BD_lrJeKii.doc
S^B6 _2.doc
| 3.rJoC

S]B6 9.doc

, . , , FileName.
. (. . 3.51, 3.52).
,
(. 3.51, 3.52), Filter.
,
.
, . 3.53. Fi'ter Name ,
. Filter
. . 3.53 : .txt .doc "*.*".

240

. 3.53

Filer Name
(* txt. *doc}

I Filter
, "doc

Filter :

(*.txt,

* .doc) | * . t x t ;

*.!| |*.*

.
, , Filter
.
Filterlndex ,
. , FilterIndex = 1 .
InitialDir ,
.
, ,
.
DefaultExt .
,
. DefaultExt, .
.
Title .
, , (, . 3.52). , . ,
.
Options . , , :
ofAllowMultiSelect

ofCreatePrompt

, , ,
.

ofEnablelncludeNotify

ofEnableSizing

ofExtensionDifferent

, , , , , DefaultExt.

C++Builder

241

ofFileMustExist

, , .

offlideReadOnly

. . 3.51 .

ofNoChangeDir

, , .

ofNoDereferenceLinks

ofNoLongNames

8
.

ofNoNetworkButton

.
ofOldStyleDialog .

ofNoReadOnlyReturn

,
.

ofNoTestFileCreate

ofNoValidate


, .

ofOldStyleDialog

(.
. 3.54).

ofOverwritePrompt

, , ,
,
.

ofPathMustExist

,
.

ofReadOnly

ofShareAware

, ,
.

ofShowHelp

.
. 3.52 .

C++Builder 5 OptionsEx, .
ofExNoPlacesBar.
Windows. . 3.51 ,
. 3.52 . ,
.
Options OptionsEx,
ofHideReadOnly, . , ,
.
ofAllowMultiSelect
, Files
TStrings.

242

, 32- C++Builder. ofOldStyleDialog


, . 3.54 16-
Windows. . 3.54 Title
.
. 3.54


OfOldStyleDialog

*I
:

( [', ".deep-]

[ S g: DOC

. , , , ,
.
OnCanClose
. , Esc .. OnCanClose .
OnCanClose , ,
false
CanClose. .
OnFolderChange
, OnSelectionChange , OnTypeChange . - .
OpenDialog SaveDialog.
RichEditl (. .
3.2.4), MainMenu (. . 3.8.1) - , , , .
OpenDialog SaveDialog. , OpenDialogl SaveDialogl.
, , , , , , MyFName. :
AnsiString MyFName ="";

:
if (OpenDialogl->Execute ())
MyE'Name - OpenDialogl->bileNamt;
RichEditl->Lines->LoadFromFile (OpenDialogl->FileName);

C++Builder
, ,
( , Execute true),
(OpenDialogl->FileName) MyFName RichEditl LoadFromFile.
:
3aveDialogl->FileName = MyFName;
if (SaveDialogl->Execute0)
(
MyFName = SaveDialogl->FileName;
RichEditl->Lines->SaveToFile(SaveDialogl->FileName);
}

FileName SaveDialogl . . , , RichEditl.



if(MyFName

!=

"")

RichEditl->Lines->SaveToFile(MyFName) ;
else
if (SaveDialogl->Execute() )
{
MyFName = SaveDialogl->FileName;
RichEditl->Lines->SaveToFile(SaveDialogl->FileName);

MyFName , .. , - . SaveToFile. ,
SaveDialogl , .
.
C++Builder
: OpenPictureDialog SavePictureDialog.
, , , . 6.2
. 6.1.1.1, . 6. , OpenDialog SaveDialog (. 3.51, 3.52), .
OpenPictureDialog SavePictureDialog OpenDialog SaveDialog. Filter OpenPictureDialog
SavePictureDialog. :
All (*.jpg;*.jpeg;*.bmp;*.ico;*.emf;*.wmf)

*.jpg;*.jpeg;*'.bmp;*.ico;*.emf;*.wmf

JPEG Image File f.jpg)

'ipg

JPEG Imoge File (*.|peg)

"ipeg

Bitmaps (*.bmp)

*.bmp

Icons (*.ico)

jco

Enhanced Metafiles f.emf)

*.emf

Metafiles f.wmf)

*.wmf

244

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

3.10.3
DriveComboBox, DirectoryListBox,
FilterComboBox, FileListBox CDirectoryOutline
, C++Builder
, :
() DriveComboBox () FilterComboBox, DirectoryListBox FileListBox, CDirectoryOutline.
. 3.55. , . ,
- (, ..) . . ,
, CDirectoryOutline, Win 3,1 . , 32- .
, -, DirectoryOutline. ,
- C++Builder. , ,
32- ,
, ComboBox.
. 3.55

Q
D
Q

applelGO bpl
bcb.-dro
bcb~dsk
bcbbcl
bcbdci

bcbdmt

FilteiComboBox

DirectoiyListBox
D \ \C8uildeiG\Bin
iogiam Files
3 Borland
3 CBuiiderG

CDiiectoiyOutiine

l-O Documents and S e t r


" fj
-S Program Files
' ahead
BBoiland
L
"""

Metscap3
DtiveComboBoH


DriveComboBox ().
. Drive, , Text.
TextCase : tcUpperCase , tcLowerCase .
DriveComboBox , DirectoryListBox, DirList DriveComboBox.
DirectoryListBox.

C++Builder

245

, OnChange DriveComboBox
EirectoryListBoxl->Drive = DriveCoraboBoxl->Drive;

,
DriveComboBoxl, Drive DirectoryListBoxl.
DriveComboBox CDirectoryOutline:
CDirectoryOutlinel->Drive = DriveComboBoxl->Drive;

FilterCombo. Filter, , . ,
Text Mask .
TFileListBox , FileList.
DirectoryListBox ,
Drive.
. , DriveComboBox ,
DirectoryListBox DriveComboBox.
TFileListBox,
, FileList. , Directory
OnChange.
DirectoryListBox Label.
. , (. . 3.55)
MinimizeName. , ,
DirLabel.
FileListBox. Drive,
Directory Mask , .
FileListBox DriveComboBox, DirectoryListBox
FilterComboBox. FileType ,
, . FileType , .
: ftReadOnly , ftHidden , ftSystem , ftVolumelD , ftDirectory
, ftArchive , ftNormal .
ShowGlyphs
( . 3.55 = true).
MultiSelect .
, FileName.
Edit,
(. . 3.55).
FileEdit.
CDirectoryOutline, . Drive. , , Directory.
TextCase : tcLowerCase
, tcUpperCase , tcAsIs
( . 3.55). OutLine, npnvep.
...\source-sa~c es.

246
3.10.4 FontDialog

FontDialog ,
. 3.56. ,
(), .

. 3.56

".
4t

MS belli
'ft
MV Boli
0 Palatiro Lhotope
0 Raavi
Roman

3
f

"

1
2
14
1
24

OK

I
j

zl

-
' *

; P

I :
: | 1

rj

.
. j

Font TFont (. . 5.1.5),


,
.
MaxFontSize MinFontSize . 0
( ), .
(
, ),
(. . 3.56) ,
.
... . , Windows.
MaxFontSize MinFontSize
fdLimitSize (. ).
Device ,
: fdScreen ( ), fdPrinter , fdBoth .
Options :
fdAnsiOnly

Windows,
.

fdApplyButton

,
OnApply.

fdEffects


( .) .

fdFixedPitchOnly .
fdForceFontExist

, .

C++Builder

247

fdLimitSize

MaxFontSize MinFontSize, .

fdNoFaceSel

fdNoOEMFonts

OEM.

fdScalableOnly

,
( bitmap).

fdNoSimulations

,
, , .

fdNoSizeSel

fdNoStyleSel

fdNoVectorFonts

( Roman
Script Windows 1.0).

fdShowHelp

fdTrueTypeOnly

TrueType.

fd Wysiwyg

, , ,
.

, fdEffects, ;.
fdApplyButton, OnApply, , ,
.
FontDialog. Memol, . FontDialog, FontDialogl.
:
if (FontDialogl->Execute())
Memol->E'ont->Assign (FontDialogl->Font) ;

,
, , FontDialogl->Font, , Memol>Font.
.
FontDialogl fdApplyButton, OnApply:
Memol->Font->Assign(FontDialogl->Font) ;

'

Memol,
. ,
.

RichEdit,
.
:

248

3
if (FontDialogl->Execute() )
RichEditl->SelAttributes->Assign(FontDialogl->Font);


, .
:
if (FontDialogl->Execute() )
Font->Assign(FontDialogl->Font) ;

Font
.

3.10.5
ColorDialog ColorBox
ColorDialog , . 3.57. ,
, ( . 3.57
), , .
( . 3.57)
.
.
.
. 3.57

-

era

3"

:-'

i
1

1
^jenor.j 1 ?*! _: 2

^ 0 _ ] 1

.[228 ^: |225

||

ColorDialog Color. , .
, , Color .
CustomColors TStrings ,
.
< >=<

>;

ColorA ( ) ColorP (, ). ,
ColorA-808022

. .
17.

C++Builder

249

Options :
cdFullOpen

cdPreventFullOpen

, .

cdShowHelp

cdSolidColor

Windows , ( ).

cdAnyColor


( ).

.
ColorDialog. , - , , Memol,
if(ColorDialogl->Execute() )
Memol->Color - ColorDialogl->Color;
ColorDialog Windows. , , , ,
. C~+Buiider 6
:-: ColorBox ( Additional).
Style , ,
.
::
ebStandardColors

16 clRed, clBlack ..

cbExtendedColors

clMoneyGreen, clSkyBlue,
clCream, clMedGray.

cbSystemColors

, Windows.

cblncludeNone

clNone.
, NoneColorColor ColorBox, , . cbSystemColors.

blncludeDefault

clDefault . , DefaultColorColor
ColorBox, , .
cbSystemColors.

aCustomColor

Custom.... , . 3.57,
() .

bPrettyNames

, : , Black, clBlack.

250

, , ,
clDefault , clNone
, Windows. Windows 98
Windows 2000 NT. clDefault - ,
, . , clNone , .
DefaultColorColor , clDefault. NoneColorColor , clNone. , , , .
, , Selected.
OnSelect,
. ,
Memol->Color = ColorBoxl->Selected;

, Memol , .
Colors ( 0). ColorNames .
, , ColorBox ComboBox (. 3.2.5). , Items TStrings. , ,
Itemlndex.
, OnCreate, Itemlndex
IndexOf. , clDefault:
ColorBoxl->ItemIndex = ColorBoxl->Iterns->IndexOf("clDefault");

3.10.6
PrintDialog PrinterSetupDialog
PrintDialog ,
. 3.58. ,
, , .
PrintDialog . . Printer ( . . 5.6.1).

, , Font, . PrintDialog ,
. :
PrintRange


: prAHPages , prSelecti ,., .,., prPageNums .

251

C++Builder

Fi wPage


... ....

ToPage


... ....

PrintToFile

, .

Copies

Collate

, .

3.58

.iJxl

." -

?
i :

| Epson LX-100

I :
:
:

jj

Epson LX-100
LPT1:

I f* J1

;
i

|2

no'jiLi

f
1^ .

, , MaxPage MinPage .
... .... , Options:
poDisablePrintToFile

.
poPrintToFile.

poHelp

. Windows 95/98.

poPageNums

, 1
.
|

poPrintToFile

--\

poSelection

,
.

poWarning

, .

PrinterSetupDialog, " . ,
,
;: . ,
, .
.

252

3.10.7
FindDialog ReplaceDialog
FindDialog ReplaceDialog, (. 3.59 3.60),
, , ReplaceDialog. , ReplaceDialog
FindDialog.
. 3.59

4TJ- |RichE*1
~ f
~

. 3.60

; f

(RidiEdiH

- fffichEde

V

:
FindText

, . , .

ReplaceText

ReplaceDialog ,
FindText.

Position

,
TPoint , X (
) Y ( ).

Left

, , Position.X.

Top

, , Position.Y.

Options

Options :
frDisableMatchCase

frDisableUpDown


,
.

frDisableWholeWord

: - i - - o a C++Builder

253

frDown

. ,
.

frFindNext

, ,
.

frHideMatchCase

frHideWholeWord

frHideUpDown

frMatchCase

,
.
, .

frReplace

ReplaceDialog. , ,
( ) FindText ReplaceText.

frReplaceAll

ReplaceDialog. , , FindText ReplaceText.

frShowHelp

frWholeWord

,
.
, .

FindDialog ReplaceDialog , . .
.
OnFind, , ,
OnReplace, ,
. OnReplace , , frReplace frReplaceAll.
RichEdit , FindText, :
int

fastcall FindText(const System::AnsiString SearchStr,


int StartPos, int Length,
TSearchTypes Options);

RichEdit , SearchStr. , StartPos ( ), Length .


Options , stWholeWord
( ) stMatchCase ( ). . , 1.

254

,
RichEditl. :
/* - ,
RichEditl
*/
FindDialogl->FindText - RichEditl->SelText;
FindDialogl->Execute();

,
RichEditl, FindDialogl.
OnFind FindDialogl :
void __fastcall TForml::FindDialoglFind(TObject *Sender)
{
int FoundAt, StartPos, ToEnd;
TSearchTypes Option;
/* ,' ,
, . - */
StartPos = RichEditl->SelStart;
if (RichEditl->SelLength)
StartPos += RichEditl->SelLength;

'

/* ToEnd - ,
*/
ToEnd = RichEditl->Text.Length 0 - StartPos;
/*
*/
if (FindDialogl->Options.Contains(frWholeWord))
Option << stWholeWord;
else Option >> stWholeWord;
/*
*/
if (FindDialogl->Options.Contains(frMatchCase) )
Option << stMatchCase;
else Option >> stMatchCase;
FoundAt = RichEditl->FindText(FindDialogl->FindText,
StartPos, ToEnd, Option);
if (FoundAt != -1) //
{
RichEditl->SetFocus();
RichEditl->SelStart = FoundAt;
RichEditl->SelLength = FindDialogl->FindText.Length();
)
else ShowMessage(" '" + FindDialogl->FindText +
"' ");
)

FindDialoglFind ,
. .
( StartPos ToEnd),
. Option . FindText .
( FindText -1), ShowMessage.
RichEdit. Memo Pos
AnsiString (. . 17), :

C++Builder
tr.z

255

fastcall Pos (const AnsiStringk subStr) const;


subStr , . 1.
subStr , 0.
AnsiString:
Substring LowerCase. :
AnsiString

fastcall Substring(int index, int count) const;

, index count .
LowerCase,
AnsiString

f a s t c a l l LowerCase()

const;

S, .
. Memol MFind , Memol. .
, , :
void
fastcall TForml: :MFindClick (TObject *Sender)
{
/* - ,
FindDialogl->FindText = Memol->SelText;
FindDialogl->Execute();

Memol

*/

void
fastcall TForml::FindDialoglFind(TObject 'Sender)
{
int FoundAt, StartPos, ToEnd;

/* 0 , ,
, - */
StartPos = Memol->SelStart;
if (Memol->SelLength)
StartPos += Memol->SelLength;
/* ToEnd - , */
ToEnd - Memol->Text.Length() - StartPos;
/*
*/
if (FindDialogl->Options.Contains(frMatchCase))
FoundAt = StartPos +
Memol->Text.Substring(StartPos+1, ToEnd).Pos(FindDialogl->FindText);
else
FoundAt = StartPos +
Memol->Text.Substring(StartPos+1,
ToEnd) .LowerCase () .Pos(FindDialogl->FindIext.LowerCase());
if (FoundAt != StartPos) //
(
Memol->SetFocus();
Memol->SelStart - FoundAt-1;
Memol->SelLength = FindDialogl->FindText.Length();
)
else ShowMessage(" '" + FindDialogl->FindText + "' ");
)

RichEdit , .

34

, FindDialogl ReplaceDialogl. OnReplace


ReplaceDialogl. ,
. OnFind , ,
(. . 3.60), OnReplace. , RichEdit, :
void
(

fastcall TForml::ReplaceDialoglFind(TObject Sender)

// " ",
if(ReplaceDialogl->Options.Contains(frReplaceAll))
ReplaceDialoglReplace(Sender);

void
fastcall TForml::ReplaceDialoglReplace(TObject 'Sender)
(
if (RichEditl->SelText != "")
//
//
RichEditl->SelText = ReplaceDialogl->ReplaceText;
else if (ReplaceDialogl->Options.Contains(frReplace))
{
ShowMessage(" '" + ReplaceDialogl->FindText +
"' ");
return;
]
// " ",
if (ReplaceDialogl->Options.Contains(frReplaceAll))
ReplaceDialoglFind(Sender);
}

ReplaceDialoglFind .
, ReplaceDialoglReplace,
,
ReplaceDialoglFind. . , , (. . 3.60) . , ReplaceDialoglFind. ReplaceDialoglReplace, .
RichEdit.
Memo RichEdit 1 Memol.

II

, ,

C++Builder

C++Builder 6

4.1
C++Builder , , . C++Builder ,
(. . 3). : ,
.
, .
, .
. , ,
,
- . ,
, ,
.
, , , . , C++Builder . ,
, ,
.
. 1 - .

. - , .. , . . ,
. , .

,
,
. ,
.
.
- .
, , . .
. , ,
, ,
, . .

260

, . , -
, . - :
.
, C++Builder , , .
. :
, , , . , . ,
, . C++Builder , . , , .
, , , ,
. , .
, .
Action. ,
, , .
. , ? - (,
), , .
.
C++Builder . , ++ilder 4, ActionList. , . C++Builder 5 , ActionList, . C++Builder 6 60. ,
C++Builder?
, C++Builder 6 , : ActionManager, ActionMainMenuBar, ActionToolBar, CustomizeDlg.
, , , ,
. ,
, ActionList - CLX (. . 8.1), a ActionManager Windows.
, C++Builder.
.
. -, ImageList,
. -,
C++Builder , Application .
. Application ApplicationEvents,
. , Screen ,
.

261

. , , , .
(action) , , ,
. - ,
, , , , - , .
. , .
C++Builder ,
TAction. , .
, ,
, - , .. (
) , .
, ,
, ,
, , .
,
. C++Builder 4 5 ActionList. , , , , , , .. C++Builder 6 ActionManager, ActionList.
, , .
, .
,
. ActionList
,
( , ), ActionList. , , . ActionManager .
ActionManager .

. ImageList. ImageList .
.
, :
1. , , , .

262

2.

,
,
ImageList.
3. : ActionList ActionManager. ImageList.
.
4. : Name () Caption (, ), Shortcut ( ), Imagelndex ( ImageList), Hint ( ), HelpContext HelpKeyword ( ) . .
. , ,
. ,
. ,
, , . HelpContext HelpKeyword
.
5. .
. , , .
, ActionList,
ActionManager. ActionList :
6. MainMenu ,
ImageList,
, ActionList.
7. (, ToolBar).
ImageList, ,
ActionList.
ActionManager, :
. ActionMainMenuBar
. ActionManager. ActionManager , , .
7. ActionManager ,
. .

, .
.

4.2 ImageList
ImageList , , 0.
, . 3 , . ,
ImageList.
. , .

263

TImageList . , . 4.1, TImageList



;
mogeList Editor.
. 4.1

SaJ
S
f
I
i
n
ivsp
sl
.
t
f
|
c
O
e
l
i
a
m
g
e
s-3I
IAdd.
ent Colo,

X
34
I

Options
Dap
J

: ;

<~ Cenler

Cancel I
AEPi-

Help

35

i
_JjJ;
Ejpot.. j :

lea

, Add, Delete,
Clear. ,
. , , ...\Program Files Common Files\Borland Shared\Images\
Buttons. , . , , , ,
. ,
, (. . 3.7.2).
: Bitmap dimensions
for ... are greater then imagelist dimensions. Separate into ... separate bitmaps?
( ... . ... ?). ,
. . . , ,
, Delete.
. 4.1,
. , , .., .
, .
, , : Transparent Color Fill Color. ,
. , , :
.
Transparent Color ,
. . , .

264

Fill Color , . clNone.


Options , , :
Crop

, ,
.

Stretch

,
. .

Center

, , .

TImageList :

Height

Integer

Width

Integer

AllocBy

Integer

, .

Count

Integer

.
.

.
C++Builder
[3].
ImageList.
- , . 6,
.
, Draw:
void

fastcall Draw(Graphics::TCanvas* Canvas, int X, int Y,


int Index, bool Enabled - true);

(. . 6.1.3) Canvas ,
Index. X Y
. Enabled , , ( false), . Enabled true,
.
Draw . . 3.2.5 3.6.2, . 3.

void
void

fastcall GetBitmap (int Index, Graphics : -.TBitmap* Image);


fastcall Getlcon(int Index, Graphics::TIcon* Image);

Index Image.
.
:
int
int
int

fastcall Add(Graphics::TBitmap* Image,


Graphics::TBitmap* Mask);
fastcall Addlcon(Graphics::TIcon* Image);
fastcall AddMasked(Graphics::TBitmap* Image,
Graphics::TColor MaskColor);

265

Image , . Mask
. Masked false, .
AddMasked Add,
MaskColor . , , .

HIDESBASE void
fastcall Insert(int Index,
Graphics::TBitmap* Image, Graphics::TBitmap* Mask);
void
fastcall Insertlcon(int Index, Graphics::TIcon* Image);
void
fastcall InsertMasked(int Index,
Graphics:rTBitmap* Image,
Graphics::TColor MaskColor);

, , Index. .

void
void
void

fastcall Replace(int Index, Graphics::!Birraap' Newlmage,


Graphics:iTBitmap* Mask);
fastcall Replacelcon(int Index,
Graphics::TIcon* Newlmage);
fastcall ReplaceMasked(int Index,
Graphics::TBitmap* Kevlir.age,
Graphics::TColor MaskCnicr);

, Index Newlmage.

void

fastcall

Delete(int

Index);

Index.
void
f a s t c a l l Move(int Curlndex, int Newlndex);
Curlndex , Newlndex.
, Imagelist ,
. , ,
, .

4.3
ActionList
. 4.1. , ActionList.
;, C++Builder 6 ActionManager. ActionList . -,
, +-I-Builder 6. -, ActionList
- , ActionManager Windows. , Action Manager ActionMainMennBar ActionToolBar, , . 3 MainMenu .

266

ActionList, Standard,
, , . 4.1, . .
. 4.2 ImageList
Images ActionList. ,
ImageList .
ActionList .
(. 4.2), .

. 4.2

Categore
i s- Aliens
[Mo Calegoivl *"> AUndo
JbACul

BiAPasle
ABold
Allaire
1! AUnderlinc
\- ABullets
* AUll
ARight
ACenlei
tfAOpan

i
d


: New Action ( ) New Standard Action ( ). .
Actionl, Action2 .. ,
. . 4.4.
, TAction. [AIIActions] ( ),
,
. Name ()

. , , . , , - ,
..
. , ,
"", . 4.2.
(Caption), , ..
( ) , (. . 3.7.2). (Shortcut), (Hint),
(HelpContext)
.
Imagelndex, ( 0) , ImageList. , , .
(. 4.2).

267

Category () . . ,
- . , . 4.2 , . .

: OnExecute, OnUpdate OnHint.
OnExecute ,
, , ( , ),
. , . , OnExecute
AExit ( )
void
fastcall TFMain::AExitExecute(TObject *Sender)
(
Close () ;
)

, .. , . , AExitExecute, , , Button7Click N14Click (


, Button7 N14).
, .. .
OnUpdate . ,
. OnUpdate
- , - .
OnHint ,
, , .
OnUpdate OnHint .

.
, ..,
Action, .
, .
, . ,
, Caption, Hint ., OnCHck , .
, ,
Action,
, . Hint, Caption .
TActionLink .

268

, Caption, Checked, Enabled, HelpContext, Hint, Imagelndex, Shortcut, Visible. , . TActionLink ,


. , . , . , - (, ,
) Button3 N5, ( Do), ActionList :
Button3->Enabled = false;
N5->Enabled - false;

Do :
Do->Enabled = false;

, ,
, , , , .

4.4
New
Standard Action ( ). (. 4.3), (
). . ++ilder 5 26 . C++Builder 6
62. , ,
.
( Edit), ( Format), ( Search), ( Help), (
File), MDI ( Window . MDI
5.5.4), ( Tab), ( List), ( Dialog), ( Internet),
( DataSet) .
. 4.3

Availabb Action Dai


E; (No Category]
TAcliori
;-! Edit
TEdilCut
TEdtCcpy
TEditPeste
TEditSelectWI
TEditUndo
TEdtOelete
:.-; Format
TRichEdilBnW
TRichEdlllalic
TRichEditUndeilne
TRichEdilStukeOut
TRichEditBullets
TRichEdtAlignLdt
TRichEdWoyiHight
TRichEdittlignCentEl
OK

Cancel

269

, .
. , . , .
ActionList ImageList. Images ActionList ImageList.
, . 4.3,
Edil TFileExit File, .
(. 4.4), , , , ImageList .
ImageListl , . , .
,
. , ActionList ImageList. ActionList .
ActionList
ImageList.
. 4.4

_3 - E i
Actont

Ffc

%EdCw,l
BEdPaoel
E*SctAH
"EiSUndol
XEdDdeKI

. 4.4 -
. -, ,
Action. , TAction. . 4.3. , : (Caption), (Hint), (Shortcut). , , :
, ,
, .

, OnExecute. , . OnExecute, , ..
, . ( 3.9.4)
Images ImageListl.
true ShowHint. -

270

, .
Action .
- , , . . 4.5. .
, , , . , , , , . (Paste,
). , . , , Print Screen,
, . , . , , , (), (Cut), (Delete). - ,
(Undo).
, , .
. 4.5

, . ,
( ), . , , , , , , ,
? ,
, .
, , OnExecute.
.
OnExecute.
, , . , FileExitl,
, Ctrl-E.
ToolBarl (Visible = false) . . .
, Ctrl-E, .
.
,
.
C++Builder [3]. -

271

, Windows.
( TFileOpen, TFileSaveAs, TFilePrintSetup, TSearchFind, TSearchReplace,
TSearchFindFirst, TOpenPicture, TSavePicture, TColorSelect, TFontEdit, TPrintDlg) Dialog , . 3.10, . 3. , - .
BeforeExecute ( ), OnAccept (, ) OnCancel (, Esc). OnAccept,
. , KichEditl FileOpenl, RichEditl
, OnAccept
:
RichEditl->Lines->LoadFromFile (FileOpenl->Dialog->Fi-e::=-e) ;
,
Filter Dialog, FileOpenl.

4.5
ActionManager,
ActionMainMenuBar, ActionToolBar, CustomizeDIg
4.5.1 ActionManager
ActionManager, C-t-'-Builder 6,

ActionList. ActionManager . . , .
ActionMainMenuBar ,
ActionToolBar .
, ActionManager. .
ActionManager .
.
.
,
CustomizeDIg, . ,
, .
, , ,
. ActionManager .
, , , , , . , ,

272

. .
ActionManager. State . asNormal :
.
asSuspended asSuspendedEnabled . . State
. , Enabled ,
Enabled true.
, , ,
ActionManagerl, ,

ActionManagerl->State = asSuspended;


. - .
FileName , ActionManager . ActionManager
. .
,
.
. - .
- ,
FileName. , . FileName . - , , .
.

FileName,
.
, . FileName
, FileName .
Images ActionManager ImageList, , .
ActionManager .
ActionManager. ActionManager
. Actions,
. 4.6. Category () Actions ()
. ,
,
New Action New Standard Action. ,
4.3 4.4.

273


. 4.6
Actions
ActionManager
3

Ctrl+S

%)

Ctrl+C

Ctrl+V

Ctrl+Z

Jt

VnaniTK

' Description
?

To add actions to your application simply drag and drop from either
Categories or Actions onto an existing ActionBar,

, Actions
, , . - ,
: Caption, Hint, Shortcut . Hint
Description () .
. 4.6.
Category.
4.3 ActionList, ActionManager
. .
, , (. . 4.6).
Toolbars ( ) ActionManager . 4.7. Toolbars
ActionManager ( ActionToolBar) ( ActionMainMenuBar). ActionMainMenuBar ( )
. 4.7
Toolbars
ActionManager
New...
Oetete

- Ioolbar Options
Caption CV.c-s
(Selective
3
f A; :v caption options Jpal toolbars

274

, .
ActionToolBar , New. Delete
.
New
ActionMainMenuBar,
Actions (. 4.6) . ,
.
Toolbors
. , .
Toolbars ,
. . , (Caption) - , , . . 4.7 , 1, 2. AllowHiding. ( true) . AllowHiding = false, (,
. 4.7). ,
. .
Caption Options (Caption) Toolbars ,
None . . , , .
. . Apply caption options to all toolbars
.
Caption Options Selective, , ,
ShowCaption, . ,
ShowCaption false .
Caption Options None,
ShowCaption . .
Options (. 4.8)
. Menus show recently used items first , Windows 2000/XP, , . , , .
- ,
. , , . , ,
, .
Reset Usage Data . Large icons
. Show tips on toolbars
. Show shortcut keys

275


4.8
'- Options
<;-: ActionManager

*1
Toolbar! j ftcbor.s Options j
PBrsonaloed Menus and Toolbars
p Menu sho- -ntty used terns first
.

Reset usage lata j

. Other

" large icons


7 Show t-ps or tcoba-5
7 Show srio:rjE -^---s ic
; Menu animations; \z*f SJ":

in tips . Menu animation


.

4.5.2
. ,
Memo,
, , ,
,
. , , , . , , , , , .
,
. . 4.9 .
. 4.9


Jr

43 , > *

add tuns to y o u application amply d'-ag -snd drop fie


& of Actions onto an existing ActionBaf,

276

, Memo (. 3.2.4), ImageList (. 4.2), ActionMainMenuBar ActionManager.


ActionManager Images ImageListl,
.
ActionManager.
Toolbors (. 4.7) New,
.
Actions (. 4.6) . New Standard
Action, . (. 4.3) Edit ( , ,
Shift), TFileOpen, TFileSaveAs TFileExit File (
, ,
Ctrl) TCustomizeAdionBars Tools. .
:
. 4.6, .
, . 4.6, .
.
File New Action
.
. 4.6 Actionl.
. .
. 4.6 - , , File. Category
&.
. , . 4.6 Caption Hint (, , , ).
Actionl (Name), , FileSavel.
, Caption (, &), Hint (, |
) , Shortcut (, F2). , . , .
ImageListl filesave.bmp Buttons, C++Builder,
Image Editor, 6.1.2.
, .
, , .
. . 4.6 ActionMainMenuBarl.
.
ActionToolBar. , .
.. ,
, . , ,
.
,
, . FileName ActionManagerl ,
. . ,

277

,
4.4. ,
(, ,
, , , ).
, , , - . , . , - .
( TCustomizeActionBars), ( . 4.9) , . Actions, Toolbars, Options (. . 4.6-4.8).
Actions (. 4.6)
, . Toolbars
New Delete, Reset, . Options ,
(. 4.8). , , - ..
Menus show recently used items first Options, .
TCustomizeActionBars. CustomizeDlg. , .
CustomizeDlg ActionManager ActionManagerl. - , , ( OnDblClick)
CustomizeDlgl->Show();

.
, .
. . ,
. , . ,
.
.
ActionManagerl Actions
. ,
Dialog. , . 3.10.2 OpenDialog. Dialog .
3.10.2, Filter Default Ext. , : ?--< .
, . ,
. , -, .
FileName
, Memo:
AnsiString FileName;

278

4.4, , , BeforeExecute ( ), cept ( ) OnCancel (



Esc). Accept:
FileName = FileOpenl->Dialog->FileName;
Memol->Lines->LoadFromFile(FileName) ;


FileName. , . Memol.
,
, , .
BeforeExecute
OnAccept. FileName :
FileSaveAsl->Dialog->FileName = FileName;

OnAccept Memol:
FileName = FileSaveAsl->Dialog->FileName;
Memol->Lines->SaveToFile(FileName) ;
. , , OnExecute. , , FileName . ,
Memol . FileName , , . , . Execute. :
if (FileName !- "")
Memol->Lines->SaveToFile(FileName) ;
else FileSaveAsl->Execute() ;
ActionManager. , .
ActionManager ActionBars , . TActionBars. Count ,
ActionBars , .
, , TActionBarltem.
ActionBar .
- . ,
for (int i = l ; i < ActionManagerl->ActionBars->Count; i++)
ActionManagerl->ActionBars->ActionBars[i]->
ActionBar->AllowHiding - false;
, ActionManager 1.
ActionManager LinkedActionLists
. LinkedActionLists -

279

ActionManager , , , ActionList (. 4.3). , ,


ActionManager. . 4.6. All Actions
( ) . , , ,
( , ) MainMenu ActionToolBar.
LinkedActionLists
. .
Add New .
ActionList .
ActionManager ,
C++Builder, Action, ActionManager. MainMenu PopupMenu (. 3.8), (. 3.9.4), .. , ,
ActionManager . , .

4.6 ApplicationEvents
Application
Application
TApplication . ,
, , . Application
, , , .
Application. Active
( ) . true,
.
, Active false.
ExeName ,
. , ,
(, , ..), . ExtractFilePath(Application>ExeName) .
ExeName ParamStr(O),
.
Title , . ,
Title, icotion
( Project | Options). , , .
MainForm TForm . ShowMainForm ,
. true,
.
Application>ShowMainForm
false Application>Run() Visible
false, .

280

HelpFile , .
, Help File, Application ( Project | Options).
, .
Application
. Hint Hint ,
. OnHint,
.
Hint , ,
Hint Application. Application>Hint

, .
HintColor TColor . clInfoBk, .
HintPause ( 500
). HintHidePause , (
2500 ). HintShortPause ,
( 50 ).
,
.
Application.
Initialize , Run ,

, Project | View Source.
CreateForm
. , ( Project | Options Forms), ,
:
void

fastcall CreateForm(System::TMetaClass* InstanceClass,


void 'Reference);

InstanceClass ,
classic!, a Reference ( ). :
Application->CreateForm(

classid(TForm2),

SForm2);

Terminate . , Application->Terminate()
Close .
- , , , Application>Terminate().
Minimize ,
Windows.
.
HelpFile, . HelpContext:
bool

fastcall HelpContext(Classes::THelpContext Context);

Context. , . Helpjump:

281

bool
fastcall HelpJump(const System::AnsiString JumpID);
, JumpID
#
, , .
HelpCommand:
bool

fastcall HelpCommand(int Command, int Data);

Command API WinHelp


Data. OnHelp , WinHelp.
WinHelp WinHelp win32.hlp, ...\Program Piles\Common Files\Borland Shared\MSHelp. . HELP_CONTENTS 0 . HELP_INDEX 0 . HELP_CONTEXT ,
, ( HelpContext). HELP_CONTEXTPOPUP , , , .
TApplication , (
C++Builder),
Application.
MessageBox, ,
(
Windows). . . . 16, . 16.7.2.3.
TApplication ,
. Application . C++Builder 5
ApplicationEvents, . Application , ,
ApplicationEvents.
ApplicationEvents. Application
. , - , Activate,
ApplicationEvents. , ApplicationEvents ,
CancelDispatch.
ApplicationEvents .
ApplicationEvents
Handled. false. , ApplicationEvents, Handled =
true. Handled = false, ApplicationEvents ( ). , ,
. , CancelDispatch.
ApplicationEvents .

284

4
ApplicationEvents.
OnHint:
void
fastcall TForml::ApplicationEventslHint(TObject *Sender)
(
StatusBarl->SimpleText = Application->Hint;
>

StatusBarl (. . 3.9.6)
Hint , . ShowHint .
OnShowHint:
void

fastcall TForml::ApplicationEventslShowHint(
AnsiString SHintStr, bool SCanShow,
THintlnfo SHintlnfo)

if (HintInfo.HintControl->ClassNameIs("TEdit"))
if (Canvas->TextWidth(Editl->Text) > Editl->ciientwidth)

Hintstr = Editl->Text;
ApplicationEventsl->CancelDispatch();
]

1
, , Text Width , . , , . ,
,
, , (. . 3.2.3). , OnShowHint
, ShowHint true.
Hint
, , :
else CanShow = false;

OnHelp:
bool

fastcall TForml::ApplicationEventslHelp(
WORD Command, int Data, bool SCallHelp)

(
if((Command -= HELP_CONTEXT) 66 (Data < 10))

Application->HelpCommand(HELPjCONTEXTPOPUP, Data) ;
CallHelp = false;
}
return true;

t
, 10, , WinHelp.
( ) , .
OnHelp , F1 , HelpContext ,
, HelpContext. -

285


.
OnShortCut:
void

fastcall TForral::ApplicationEventslShortCut(
TWMKey SMsg, bool SHandled)

(
if (Msg.CharCode == 'Q')
if (Application->MessageBox(
" ?",
" ",
MB_YESNOCANCEL+MB_ICONQUESTION) == IDYES)
Application->Terminate() ;
)

, "Q" (
), Application>MessageBox . , Application >Terrainate.

4.7 Screen ,

C++Builder Screen
() TScreen, Windows
, .
, , Screen, Height Width . , , ,
Position , . ,
, , ,
. , , , , OnCreate :
Width - Screen->Width / 2;
Height = Screen->Height / 2;

.
, PixelsPerlnch, . ,
.
Screen Forms[int Index], , ----
, FormCount, ;
. , ,
""
, >:_
. :
for (int i = 0; i < Screen->FormCount; i++)
(
if (Screen->Forras[i]->Height > Screen->Height)
Screen->Forms[i]->Height - Screen->Height - 100;
if (Screen->Forms[i]->Width > Screen->Width)

286

4
Screen~>Forms[i]->Width = Screen->Width - 100;
}

, ,
100 .
, , ,
. . 5.2.
, , (. .
9.13). DataModules[int Index]
, DataModuleCount .
.
Screen Fonts ().
TStrings , ( ). , ,
, .
,
,
. , TComboBox
OnCreate :
ComboBoxl->Iteras = Screen->Fonts;
ComboBoxl->ItemIndex = 0;

, , , , RichEditl, OnClick OnChange
:
RichEditl->SelAttributes->Narae =
ComboBoxl->Items->Strings[CoraboBoxl->IteraIndex);
RichEditl->SetFocus();

, ParentFont true, :
Font->Narae = ComboBoxl->Items->Strings[ComboBoxl->ItemIndex] ;

Cursor Screen .
crDefault,
Cursor. Cursor Screen
crDefault,
, Screen.
,
- . :
Screen->Cursor = crHourGlass;
try
f

//
}
catch
{

(...)

Screen->Cursor = crDefault; //
throw;
)
Screen->Cursor crDefault;

287


.
-
crDefault , ,
:
TCursor Save_Cursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
try
(
//
}

catch (...)
(
Screen->Cursor - Save_Cursor;
throw;
)
Screen->Cursor = Save_Cursor;
Cursors[I], . .
C++Builder (Image Editor). 6.1.2, . 6.
LoadCursor. .
, , NEWCURSOR. , . :
const crMyCursor = 1;

-32768 32767.
,
, 0 21.
OnCreate , Cursors:
Screen->Cursors [crMyCursor]-LoadCursor (HInstance,

"XEX; . ? : : . - "

, '--' * --- =
,
.
.-

Screen->Cursor = crMyCursor;


Screen->Cursor = crDefault;

,
, Panell
Panell->Cursor = (TCursor)crMyCursor;
. 6.1.6, . 6.
Screen ActiveForm. - . ,
, ActiveForm , , .
, OnActiveFormChange.

288

ActiveControl .
OnActiveControlChange.
C++Builder 4, , .
,
. , , Screen>Monitors[I], I
. 0 . Screen>Monitors[I] TMonitor,
.
TMonitor Height Width
. , Left .
.
,
. Left
. TMonitor MonitorNum , Screen>Monitors[I].
, ,
DefaultMonitor. :
dmDesktop

dmPrimary

Screen->
Monitors

dmMainForm

dmActiveForm



5.1
Windows
5.1.1

(Graphical User Interface GUI)
,
, ,
, . ,
, , . Windows.
C++Builder
, , ..
. .
,
, Windows.
Windows
,
. , ,
, ,
, , .
_ _ . _ _ _ , . _ , _ .
Windows
(, , ), . , .

Microsoft
Windows, ,
,
. Windows, Microsoft.
Windows, . - , ,
, Windows.
,
Windows, , 10 C-H-Builder

290

.
. , .
, Windows,
:
. MainMenu ActionManager ActionMainMenuBar (. . 5.1.6, 3.8, 4.5).
,
. (. . 3.9.4). , PageScroller
(. . 3.9.4), ,
,
ControlBar (. . 3.9.5). , , ActionManager ActionToolBar (. . 4.5).
( PopupMenu . . 3.8),

.
(. . 5.1.8).
(. . 3.7.2), (. . 3.8.1).
, (. . 5.1.9).
( StatusBar . . 3.9.6), .
, F1
- (. . 5.1.9).
,
(. . 2.3.5).
, , (. . 5.7.2, 5.7.3 4.5).
, Windows
Windows ( , ,
. ,
.).
.
. , , .

. C++Builder
.

291

5.1.2
- . .
: (SDI)
(MDI).
SDI.

, Windows, . ,
Windows, SDI ,
, ,
.
, MDI .
Microsoft Word. MDI () ( ). ,
, (,
). . ,
.
, MDI, . , , , .
MDI,
(, ). MDI, , , *,
, .. MDI ,
( Word Excel).
- . , , Microsoft
MDI ( , Windows ).
MDI . 5.5.4.

5.1.3
, . , . , , (unit), , , - , , .
Windows .
, C++Builder Windows
. , ,
,
.
.
BorderStyle ,
.
:

292

bsSizeable

Windows ,
,
- . BorderStyle
.

bsDialog

. .

bsSingle

, , ,
.

bsToolWindow

, bsSingle, .

bsSizeToolWin

, bsSizeable, .

bsNone

. ,
, .

Borderlcons , . :
bySistemMenu

, .

byMinimize

, .

byMaximize

, .

byHelp

,
BorderStyle.
. 5.1 BorderStyle Borderlcons.
bsDialog ( Form3 Form4 . 5.1),
( Form4)
, - . bsNone , . . Form3,
Form6 Form8 , . :
Form6 ( bsSizeToolWin) , . Form3 Form8 . , Form6 Form8
:
.

_ _ . _ _

. , ,
. 5.2, . , -
: , , ..


BorderStye
l =bsDialog
Bod
i erlcans = {bySsitemMenuJ

BordeS
bsSzi
t ly!e =
Borderi
conim {bySk

bsSsieToorWn
i
= {tyStstemManii,

BccderSMe =$$&1 ooWin

293

<t E S i s i ' - f . 1 " .


Joidei5Kile s bsDiebg
iofderlcorts U

';

BdSl>ite bsToolWmdow
Botdetlcons {biuisteniMenu.

bjMwmBel

. 5.1. BorderStyle Borderlcons


'
BorderStyle *= bsSingle
(Barderlcons.byMaximize = false]. , , .


BorderStyle = bsDialog. BorderStyle = bsSingle,
( Borderlcons.byMoximize = false). -'
, - , ,
.

, , BorderStyle = bsNone. , -
.

WindowState ,
.
:
wsNormal

( WindowState )

wsMinimized

wsMaximized

WindowState wsNormal , , , Position,


:

294

poDesigned


, .
, .

poScreenCenter

. , . (. . 4.7),
,
, DefaultMonitor.

poDcsktopCentcr

. ,
. (.
. 4.7).

poDefault

Windows,
. .

poDefaultPosOnly

Windows. . .

poDefaultSizeOnly

Windows, . .

poMainFormCenter

C++Builder 5. . , .
(. . 4.7). . ,
poScreenCenter.

poOwnerFormCenter

C++Builder 6. ,
Owner. ,
. Owner , poMainFormCenter.


Position
poScreenCenter poDefoultPosOnly. ,
, poDesigned, .

Position
Windows , PixelsPerlnch Scaled. , false. , Scaled true.


( Position).

295

AutoScroll ,
, .
AutoScroll true, .
, .
Icon . C++Builder.
Icon,
(Picture Editor) (. . 3.33 . 3.7.2). Load (), ( .ico). C++Builder , lmages\lcons.
Icon , . , . , Windows . C++Builder.

. , . Project | Options
Application (. 5.2).
(Title), . Load Icon , , .
. 5.2
Application

Pasca! | Lhker \ Advanced L*er j Dueco


'e
i s/CoreWa
inasl j
Vet.onlnu 1 Packages j asm j CQRBA ] CodeGuard j
Foims
Application j Compfe ] Advanced Compibr \ C*-> \
Application settings
Jills [
Help III |

Default

OK

Cancel

Help

FormStyle,
:
fsNormal

. FormStyle
.

fsMDIForm

MDI, .. , .

296

fsMDIChild
fsStayOnTop

MDI.
, Windows.

MDI . 5.5.4. fsMDIForm fsMDIChild .


FormStyle = fsStayOnTop , , .

...--..~*~._,_._-~-

FormStyle = fsStayOnTop
- .

,
, . ,
- , ,
, - . .
, AutoCheck = true,
,

if (MStayOnTop->Checked)
Forml->FormStyle = fsStayOnTop;
else Forml->FormStyle = fsNormal;
, , ,
MStayOnTop. , .
.
AutoCheck C++Builder 6.

MStayOnTop->Checked -

! MStayOnTop->Checked;

5.1.4
.
. , , , .
, . , ,
, . - . .

. , , ,
. .
, , - (

297

Microsoft). , , .
. , ,
. Microsoft
- , .
, .
Microsoft .
, . .
, - .
, , ++ilder. Color (), ( , ). , , .
: clBlack ,
clGreen .., clWindow
, clMenuText ..
,
. 17, . Color.
,
. ,
. : (,
, ), ( , , , ). , . - ,
16 . 256 (, , 16 ) ,
,
16 . (, , ), .
, , , . , Windows.
, C++Builder , Windows. ,
.
, ,
Windows, .

.
, , . , ,
. dBlack , clWhite cIRed .

298

ParentColor. true,
. , ,
, , , ,
. .

5.1.5
C++Builder Font,
. ,
ParentFont. true,
Font ,
. ParentFont ParentColor
.
C++Builder MS
Sans Serif 8. Charset
DEFAULT_CHARSET. ,
. , Windows .
. ,
-
, ..
. , ,
, . - ,
, , . , , , . .
: System MS Sans Serif,
. , , . ,
Windows .
- . , , , :
if

(Screen->Fonts->IndexOf("Arial")

== -1)

, ,
( Arial) . CD ROM
.

.
. , FontDialog (. . 3, . 3.10.5). .ini,
(. . 5.7.2 5.7.3).
, ,
. 17, . Font.

299

5.1.6
,
. : ,
, , , ,
- .
C++Builder MainMenu ,
PopupMenu .
Standard. , C++Builder 6 , , ActionManager ActionMainMenuBar. . 3.8 4.5.
, Windows.
.
: , , , .
. , ,
, ,
Clipboard .. , Windows,
.
.
. 3.5 . 3.2.4, . 3. ,
. . ,
, ,
MDI .. (. . 3.5),
.
, , . C++Builder
, , ,
.
. . 5.3
, , MDI ? .
, , ,
, ...
.

.
.
, - , ,
- Microsoft Windows. . , , . . ,
. .

300
)

. 5.3

Ctrt+N

Qj$r ,..

+0

* '

,;Ctrl+Z,

:$>':-'. ' VCtrJ+X

! ..,

Ctr!+G.:

^1 '

, ; " : ;ctr!+v,:'

-; ...
=

:OJJ+F. .

$t ;;..

.,.
,..

QKHO |
Hoeoe
^

G ...
5

XI

1 I
/ 2 2
3 3

, , , ,
- .
, (,
. 5.3 ) , . -f+Builder ,
. , .
, , -
, , , .
, ( Alt ). ,
. , ,
-
, .
, , . . ,
, Qrl-X, Ctrl-C Ctrl-V . (. . 5.3 5.3 ).
, ,
.
, - ,
, , , . . . 3.8.1.
. , , . , -

301

, . . false Enabled Visible . ,


, ,
, , .
. , ,
. , ,
, .
, , .
.
,
, . , , ,
, ( . 3.8.1 , Save As Template
). , Insert From Template
MainMenu. , ,
Del.
. 3.8.1, 4.3
4.5. ,
, , .
: , , , .
. 8.2, . 8.
, .
, , .
, . . 3.8.2 , PopupMenu. , .

5.1.7
, ,
. , , , .
, .
, . 3.9. , ,
, .

302

, ,
. ,
, ,
: . , . .
, ; , .
, .
,
. ..., , , .
, . 3.9.3. ,
. C+4-Builder, Tools | Environment Options .
,
. ,
-
. , , , ,
. C+4-Builder 5
Frame (. . 3.9.7) , (. . 2.6), .

C+4-Builder .
. 2.6. , , , . , , -
.
,
. C+4-Builder
. -
, .., , .

, ,
. ,
.

5.1.8
. , , -

303

Tab. ,
, . , ,
- , . ,
Tab , , Tab,
, , .
ActiveControl, , ,
. , .
TabOrder .
, .
TabOrder, 0, 1 ..
TabOrder, , ,
( ActiveControl). , , , -. , , .
, .
TabOrder
. TabOrder - , ,
, TabOrder , . TabOrder, , ,
.
- , TabOrder
TabOrder , . C++Builder
Edit | Tab Order, .
TabOrder , TabStop true . ,
TabOrder ,
. TabStop false ,

Tab ( , , ).

SetFocus. , -
Edit2, :
Edit2->SetFocus() ;

, ,
- ,
. , , Enter . ,
OnKeyDown (. . 5.3.2). ,
Editl Edit2,
OnKeyDown Editl :

304

'
void

fastcall TForml::EditlKeyDown(TObject *Sender,


WORD SKey, TShiftState Shift)

{
if (Key == VK_RETURN) Edit2->SetFocus();
}

, ,
, Enter. Enter, Edit2 SetFocus.
, (,
, ). , . FindNextControl, ,
. , , , . :
TWinControl*

f a s t c a l l FindNextControl(
TWinControl* CurControl,
bool GoForward, bool CheckTabStop,
bool CheckParent);

CurControl
.
GoForward . true,
, CurControl.
GoForward false, .
CheckTabStop CheckParent .
CheckTabStop true, ,
TabStop true. CheckTabStop false
TabStop . CheckParent true,
, Parent
, .. . CheckParent false, , .
, Enter, OnKeyDown , :
if

(Key == VK_RETURN)FindNextControl(
(TWinControl *)Sender, t r u e ,

true,

false)->SetFocus();

.
OnClick:
FindNextControl(
(TWinControl *)Sender, true, true, false)->SetFocus();

Sender, , . TObject. FindNextControl TWinControl,


TObject TWinControl (TWinControl *)Sender (. Sender . 1, . 1.9.6.2).

305

5.1.9 -
& ,
, .
:
, , ,
- . , , ,
.
, .

,
.
- , F1.
,
Windows .hip, .

Hint ;
, "|\ ,
, ; . , ,
, Hint :
|

, Hint
'|'.
,
, :
1. Hint ,
.
2. ShowHint ( ) true
true ParentShowHint ( ShowHint ) true ShowHint , .

, true false ,
.
ShowHint, true, ,
( Enabled = false).
Hint, true
ShowHint true ParentShowHint, ShowHint = true*
Hint .
, ShowHint
Application true ( ).
Application>ShowHint false, ShowHint .
Hint - -

306

GctShortHint GetLongHint, , ( ,
). ,
OnMouseMove, .
void f a s t c a l l TForml::ButtonlMouseMove(TObject *Sender,
TShiftState Shift, i n t X, int Y)
{
TControl *Send = (TControl *)Sender;
Panell->Caption = GetShortHint(Send->Hint);
Panel2->Caption = GetLongHint(Send->Hint);
)

Panell , 12
Hint , ,
OnMouseMove ButtonlMouseMove. ShowHint.
. ,
Buttonl Panell , , , . Hint | , true ShowHint,

Panell->Caption = GetLongHint(Buttonl->Hint) ;

,
Hint, ,

Panell->Caption = GetShortHint(Buttonl->Hint) ;


Panell->Caption = Buttonl->Hint;

, - , OnShowHint. - , ,
. ,
C++Builder 5, ApplicationEvents, (. . 4.6).
OnShowHint , . :
void

f a s t c a l l TForral::ApplicationEventslShowHint(
AnsiString SHintStr, bool sCanShow,
THintlnfo SHintlnfo)

HintStr
. . CanShow. false, . , Hint Info.
, : , ,
.. , HintControl ,
, HintStr . Hintlnfo.HintStr Hint
. .
. 3.2.3 4.6
OnShowHint ,
Edit.

307

,
Hint, - ,
OnHint. ,
, Application. C++Builder 5
ApplicationEvents.
, , Hint, Hint Application. Hint
, Hint Application .
, , ,
, (. . 3.5). ,
. - .
StatusBar Win32
(. . 3.9.6). ,
SimplePanel AutoHint StatusBar true. AutoHint . . , , . , .
, AutoHint .
ApplicationEvents
OnHint
StatusBarl->Panels->Items[I]->Iext = Application->Hint;

I .
-
, .
F1
, . , .help. , [1]. ,
- , , .
, C++Builder 6, HelpContext. , [MAP], . ++ilder 6 : HelpKeyword HelpType. , . , HelpContext HelpKeyword .
HelpType = htContext HelpContext; HelpType =
htKeyword HelpKeyword.
HelpContext ,
. , , HelpContext = 0, HelpContext, ,
.
, Project | Options
Project Options ( ) Application () -

308

Help file, ..
, :
Application->HelpFile = "< >.";

HelpFile, ,
. , - .
, ,
, , . , , , .
HelpContext - , .hpj [MAP]
HelpContext
.. [1].
, . , .

Application->HelpContext(< >);

HelpContext. ,
. , , , , .
Application,
. . 4.6.
, .
, Windows.
, , , - ,
, . , true byHelp Borderleons .
. ,
BorderStyle bsDialog.
. . .
HelpContext . .

5.2

5.2.1 Align
,
, ,
,
.

309

, , ,
Panell, -
ListBoxl, 12,
StaticTextl, Memol,
(. 5.4 ). , , ,
, ,
, (. 5.4 ).
, , ,
. 5.4 . .
)

. 5.4

1
2
3
4
5

f j

zl

6)
ParifHZ

'StaticTt>Kl1

'

Hemol
1
i.
Panell
4
5

*]
J
_rj

1
1

, , ,
, Align . alNone,
, .
alTop, alBottom, alLeft, alRight, , , , ,
-. ,
.
Align alClient, . .
C++Builder 6 alCustom ().
CiistomAlignlnsertBefore CustomAlignPosition (. Align . 17, . 17.1).
12
Align, alTop, . , , , . Panell Align, alLeft, ,
ListBoxl. Panell

310

, 12.
Memol Align, alClient, , ,
. Memol , Panell 12.
, . 5.5.
. 5.5

LH3Z53^^HRHI
Slrtln-.lKxll

.CIIIllKfi 1

2
1
3
ipK<i4
w f 11 5
L

]
_J

Align : alTop
Panel2, alLeft Panell, alClient Memol. , ,
alClient Memol, Memol , .
Align : alTop
alBottom , alLeft alRight.
. , ,
. 5.6 . , Panell
(.. Align = alLeft),
13 , Panell (..
13 Align = alBottom), a Panel2
(.. 12 Align = alClient).
. Panell alLeft,
13 alBottom, alBottom 13
, Panell.
-. Panell 14, . 5.6 . Panell alLeft, a
14 alClient. 12 13
14 : alBottom 13 (
13 14, 13
) alClient 12, .
. 5.6


Align

a)

311

5.2.2
Align
. . . 5.5
, StaticTextl,
, , ListBoxl .
, , , .
Anchors
.
, :

akLeft

akRight

akBottom

Anchors , , . . . . 5.2.4.
. .. Anchors [akLeft.akTop].
Anchors
,
1
. ListBoxl
Anchors [akLeft.akTop.akBottom], , , .
,
, . Anchors
[akLeft,akTop, akRight] StaticTextl,
. , . Anchors ListBoxl StaticTextl, . 5.7.
, . ListBoxl
, .. .
,
OnResize , StaticTextl,
StaticTextl->Repaint ;

Repaint, .
, , , , , .. , , , .

312
. 5.7

Anchors

Panel2

SlalicTeKl!
Memol

Panel!

1
2
3
4
5
6
7
8

10
11

StaticTextl.
. .
Left , . -. , .
Width Height
. BoundsRcct, , , .
, -: ClientWidth ClientHeight.
Width Height. . , ClientHeight , Height, , ,
, .
, OnResize . . :
StaticTextl->Left - Panel2->Left +
(Panel2->ClientWidth - StaticTextl->Width)

/ 2;

StaticTextl ,
12. , ,
. - .

5.2.3

. - , . , , .
Windows .
C++Builder Additional Splitter, .
. Splitter ,

313

- , ,
, , .
Splitter ( ). Splitter . .
Splitter

.
Splitter
, , .
Splitter OnMoved,
. , , ,
: - , ..
ResizeStyle Splitter
. ,
. Splitter
rsPattern. , , , .
,
. , ,
, . , ResizeStyle = rsLine. ResizeStyle = rsUpdate
, . , , , , -
. , . . ResizeStyle = rsNone,
, .
, , .
MinSize Splitter
, .
, *
, - . ,
C++Builder, C++Builder 5, MinSize . C++Builder 5 Splitter AutoSnap. true ( ),
, C++Builder. AutoSnap true, , MinSize, .
AutoSnap true.
, , . , MinSize ,
, . ,
Constraints, .

314

5.2.4


:
- .

. , .
Constraints,
.
: MaxHeight, MaxWidth, MinHeight MinWidth
. 0, .
.
- , .
. , .. . ,
MaxHeight = 500 MaxWidth = 500, , 500x500. , , . ,
. , - .

5.2.5
,
ScaleBy. :
void

fastcall ScaleBy(int M, int D) ;

D , .
, Width Height,
. Left , .
, ParentFon = true.
.
, ,
. -
Width Height, Left, .
ParentFont = true, - ParentFont = false, (, , ,
, ).
D .
, 10% , 9, a D 10 (9/10). 1/3,.
= 133 D = 100 (133/100) = 4 D = 3 (4/3).
.
Editl->ScaleBy(11, 10) ;

' '

Editl.
( Width) 10%,
.
( Height) , -


AutoSize false. .
, ParentFont false, ..
. , AutoSize =
true ParentFont = true .

P a n e l l - > S c a l e B y (11,10) ;

, .
ParentFont = false,
ParentFont. , , . ParentFont = true,
, ParentFont = false.
,
, Left.
,
, , :
for (int i = 0; i < Panell->ControlCount;
if (Panell->Controls[i]->InheritsFrom(
classid (TWinControl)))
((TWinControl *)Panell->Controls[i])->ScaleBy(11, 10);

, ScaleBy
, TWinControl.
,
TWinControl. InheritsFrom, true, , . TWinControl,

classid.
, (
TWinControl), ScaleBy, TWinControl: (TWinControl *).
.
, , .
, , . 1, . 1.9.6.2.

5.3
, . ,
.

5.3.1
5.3.1.1
C++Builder , .
:

OnClick

.
.

OnDblClick

316

OnMouseDown
OnMouseMove

. .
.
.

OnMouseUp

. .

OnStartDrag

, .
.

OnDragOver

.
.

OnDragDrop

. .

OnEndDrag

.

.
,
.

OnEnter
OnExit


,
.

OnMouse Wheel

. C++Builder 5.

OnMouseWheelUp

. , OnMouse Wheel.
C++Builder 5.
. , OnMouse Wheel.
C++Builder 5.

OnMouse WheelDown

,
. OnCIick. ,
, .. , . . , :
, , , ,
.
,
.
Enter, , Default.
Esc, , Cancel.

317

. , Caption &
'' , Alt+
OnClick .
true Checked RadioButton.
Checked CheckBox.
Click .
OnClick ,
.
, ,
, .
.

OnEnter , .
- , .
: .
. 5.1.
5.1.


OnMouseMove

OnMouseMove

OnMouseMove

OnExit
OnEnter
OnMouseDown *

OnClick
OnMouseTJp

OnMouseMove , , . , , , .
, ,
. OnMouseDown OnMouseTJp
, ,
.
. 5.1 ,
DragMode (. . 5.4) dmManual ( ), .

318

dmAutomatic ( ),
, ,
:
OnMouseDown OnStartDrag.
OnMouseMove OnDragOver , .
OnMouseUp
OnDragDrop ,
(
), OnEndDrag , .
OnExit OnEnter ,
. OnCIick.
, , . . . 5.4.
, . 5.1, , , OnExit
OnEnter. OnMouseDown, OnCIick OnMouseUp.
. . 5.2. - OnMouseDown OnMouseUp. - , ,
, , , OnDblClick, OnMouseDown OnMouseUp , ,
.
5.2.


OnMouseDown. .

OnCIick
OnMouseUp. .

OnDblClick
OnMouseDown. .
OnMouseUp. .
5.3.1.2 , ,

, (
) Sender TObject.
, .

319

, .
.
- , - . Sender
. , TObject , Sender TObject .
, Sender,
. 1, . 1.9.6.2. , ,
Sender, , , ,
- .
Sender OnMouseDown OnMouseUp , ,
,
. OnMouseDown OnMouseUp
, , :
void

f a s t c a l l TForml::EditlMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, i n t X, i n t Y)

Sender
, Button, Shift, X Y.
Button TMouseButton
. TMouseButton , :
'
enum TMouseButton

{ mbLeft,

mbRight,

mbMiddle

);

mbLeft ,
mbRight , mbMiddle . , ,
, :
if

(Button != mbLeft)

return;

, Button mbLeft, .. ,
.
Shift TShiftState , . TShiftState
, :
enum Classes
typedef

ssShift, ssAlt, ssCtrl, ssLeft, ssRight,


ssMiddle, ssDouble };
Set<Classes
1, ssShift, ssDouble> TShiftState;

Shift (ssShift), Alt


(ssAlt), Ctrl (ssCtrl), : (ssLeft), (ssRight),
(ssMiddle). Button Shift . Button , , Shift , ,
, . ,
, , , , Shift [ssLeft], [ssLeft, ssRight].
- , Shift.
Shift ,
Contains (. . 14.6 . 14). ,
,
Alt, :
if ((Button == mbLeft) &S, (Shift .Contains (ssAlt) ))

320

if (Button == mbLeft) , Shift:


if

(Shift.Contains(ssLeft)

&&

(Shift.Contains(ssAlt)))

Button Shift
OnMouseUp. , Button , . Shift
OnMouseMove, , .
, ,
X Y. .
, .
OnMouseWheel, OnMouseWheelUp OnMouseWheelDown, C+4-Builder 5. , . OnMouseWheel :
void
f a s t c a l l TForml::FormMouseWheel(TObject *Sender,
TShiftState Shift, i n t WheelDelta,
TPoint bMousePos, bool SHandled)
Sender Shift .
WheelDelta , .
. sePos TPoint (. . 17.4) . Handled , .
OnMouseWheel
Handled = false, , ,
OnMouseWheelUp OnMouseWheelDown.
:
void
f a s t c a l l TForml:: E'ormMouseWheelDown (TObject ^Sender,
TShiftState Shift, TPoint &MousePos, bool ^Handled)
OnMouseWheel WheelDelta.
,
.. . Memo,
RichEdit, IistBox, TrackBar . , , (, , ).
. , , , . ,
void
f a s t c a l l TForml::FormMouseWheelUp(TObject *Sender,
TShiftState Shift, TPoint SMousePos, bool ^Handled)
(
ScaleBy(101,100);
>
void

fastcall1 TForml::FormMouseWheelDown(TObject *Sender,


TShiftState Shift, TPoint SMousePos, bool SHandled)

(
ScaleBy(100,101);
}

321

5.3.2
5.3.2.1
C++Builder ,
. :

OnKeyDown

.
, , ,
. ,

OnKeyPress

. , ,
,
.

OnKeyUp

.
, ,
, .

, , . 5.3.1.1 OnEnter OnExit.


,
. , ,
Shift ( ),
''.
. 5.3. , . , ,
OnKeyPress. , OnKeyDown '' , Shift, , ,
.
CapsLock, Shift . , CapsLock, OnKeyDown .
5.3.
Shift-

Shift

11 C-H-Builder 6

OnKeyDown.
Shift.
OnKeyDown.
Shift, ,

.
OnKeyPress.
, Shift.

322

OnKeyUp. Shift, ,

.

Shift

OnKeyUp.
Shift.

, OnKeyPress , Shift.
- , OnKeyPress ( OnKeyDown OnKeyUp ) , , . , Alt
OnKeyPress . ! OnKeyPress ,
.
, . KeyPreview. ,
(
, ..). KeyPreview
false , . KeyPreview
true, ,
, .
OnShortCut (Application), . , OnKeyDown . ,
, C++Builder 5
AppIicationEvents. - . Windows Msg, CharCode (Msg.CharCode) . Handled.
true, OnKeyDown, OnKeyPress,
OnKeyUp . . 4.6 OnShortCut.
5.3.2.2
OnKeyDown , , :
void

fastcall

TForml::EditlKeyDown(TObject Sender,
WORD sKey, TShiftState Shift)

Sender, ,
(. . 5.3.1.2). Shift, ,
. OnKeyDown
Shift ssShift (
Shift), ssAlt ( Alt) ssCtrl ( Ctrl). .
, Key.
, , .. . , , , .

323

Key .
- API Windows. . 16,
. ,16.1.1. , . 5.4 , .
5.4.

F1

112

0x70

VK_F1

Enter

13

OxOD

VK_RETURN

Shift

16

0x10

VK_SHIFT

Ctrl

17

0x11

VK_CONTROL

Alt

18

0x12

VK_MENU

Esc

27

OxlB

VK ESCAPE

0)

48

0x30

1 !

49

0x31

n N

78

0x4E

YH H

89

0x59

Key , , .
, "Y"
"". , , "" "", . .
, Key , . 5.4. , Enter :
if(Key = = 1 3 )

...

Key , . 5.4. ,
:
,
i f ( K e y == OxOD)

. . . ;

, , , ,
. ,
:
i f ( K e y == VK_RETURN)

...

, ,
. ,
, Key. , ,
, "Y", :
i f ( K e y 'Y-' ) . . . ;

324


. '' , '' '', .
, ,
: "Y", "", "" " " . , . , - , Y () N (), ,
. ,
"Y". , , "Y" "" , (Yes ), ().

Enter. , OnKeyDown :
if (Key -== VK_RETURN)
FindNextControl((TWinControl *)Sender, t r u e , t r u e ,
false)~>SetFocus();

FindNextControl
.
FindNextControl . 5.1.8.
.
, , Alt-X.
:
i f ( ( K e y ==

'X')

&&

Shift.Contains(ssAlt) )

...

OnKeyDown.
OnKeyUp ,
.
OnKeyPress. :
void

f a s t c a l l TForml::EditlKeyPress(TObject *Sender, char SKey)

, , Key, . , , , a char . , ,
, , , , .
.
, , , "" "" (), "" "" (). OnKeyPress :
if

((Key

==

'')

I!

(Key

= = ' ' ) ) . .

, . switch (. .
13.8.1.2, . 13):
switch (Key)
{

case ' ' :


1
case ' :

break;

325

case ' ' :


case ' ' : . . . ;
break;
default: Beep () ;

,
.
, ,
Key .
Key, ,
. , , Bditl, .
,
, , :
Set <char,
'',
''> Dig;
D i g ' 0 ' << ' I 1 ' 2 ' ' 3 '
' 6 ' ' 7 ' << ' 8 ' << ' 9 ' ;
if ( ! D i g . C o n t a i n s ( K e y ) )
{ K e y = 0; B e e p () ,}

'4'

<<

' 5 '

, , , , .

.

5.4
5.4.1
Drag&Drop

(Drag&Drop), , Windows. , ,
, , .. , C++Builder.
, , , TControl, C++BuiLder. .
DragMode,
dmManual dmAutomatic. dmAutomatic ()
. , OnMouseDown,
,
. dmManual () ,
. BeginDrag. ,
OnMouseDown, . - ( ,
) BeginDrag.

326

'

, , , Alt ListBoxl. DragMode dmManual,


OnMouseDown :
void

f a s t c a l l TForml::ListBoxlMouseDown(TObject Sender,
TMouseButton Button, TShiftState Shift, i n t X, i n t Y)

if ((Button == mbLeft) SS Shift .Contains (ssAlt) )"


ListBoxl->BeginDrag(false,5);
)

Button OnMouseDown ,
, Shift ,

(. . 5.3.1.2). ,
Alt. ,
BeginDrag .
BeginDrag
false 5. , ,
,
, 5. . BeginDrag true , .
, .
,
, crNoDrop: @.
, ,
, DragCursor.
crDrag, ^ .
, DragCursor , , .
, ,
.
OnDragOver, , . , , ,
false Accept.
true, . ListBoxl , , :
void
f a s t c a l l TForml::ListBoxlDragOver(TObject *Sender,
TObject *Source, i n t X, i n t Y, TDragState State, bool sAccept)
(
if (Sender != Source)
Accept - Source->ClassNameIs("TListBox");
else Accept = false;
)

, (Sender) (Source) . , .
, else
Accept false, . , Accept true, -
( TListBox), false, -

327

. . ListBoxl ,
.
Accept, OnDragOver, , . OnDragOver, ,
.

OnDragDrtfp . , . Source
(-) X Y .
, OnDragDrop :
void

fastcall

TForml::ListBoxlDragDrop(TObject *Sender,
TObject *Source, i n t X, i n t Y)

TListBox *S = (TListBox *-) Source;


((TListBox*)Sender)->Items->Add(S->Items->Strings[S->ItemIndex]) ;
)

S
TListBox, Source,
TListBox. , Source TListBox. A
. Source TObject. Items Itemlndex. TListBox. ,
,
Source. . 1.9.6.2, . 1.
Add - S - Sender. Drag&Drop.
S.
:
void

fastcall

TForml::ListBoxlDragDrop(TObject *Sender,
TObject *Source, i n t X, i n t Y)

(
((TListBox*)Sender)->Items->Add(((TListBox *)Source)->
Items->Strings[((TListBox *)Source)->ltemlndex]);
)

EndDrag, -
. OnStartDrag, - . ,
.
, ,
, ,
ListBox .
:
, , OnDragOver OnDragOver.

328


OnDragDrop.
!
.
- , , Alt, :
DragMode, dmManual. MouseDown.
, , . . 5.8
, .
, .
,
Memo.
: , , , - (.. ) (). ,
, .
. 5.8
,
Drag&Drop

JSJJSlL
1 1 1
4 2

^ liHIT

Label 1 Memol

1 ?
2 2

2 1
3 1
4 1

dmM unuaL Aft


BeghDra^lalse]

BeginDrafl(true)

1 3
2 3
3 4
4 4

1 4
2 4
3 3
4 3

5.4.2 Drag&Doc.

C++Builder 4 Drag&Doc.
, C++BuiLder. .
, ,
.. , .

329

DockSite,
false, true, :
, .
UseDockManager. true ( ),
, ,
. UseDockManager false, .
DragKind dkDock. , , , , , Drag&Drop,
DragMode dmAutomatic. DragMode
dmManual , Drag&Doc
, Drag&Drop.
, . , Drag&Doc, .
. 6 ,
, . 5.9 ). Panell
DockSite true. .
PaneI2 DragKind dkDock DragMode dmAutomatic. . 12 .
(. 5.9 ), Panell , , ,
.
,
, . ,
,
- ( 15 16 . 5.9 ), , , ,
, .
,
.
. 5.9
Drag&Doc: ()
()

2SSism H J g : 181"

a
Panel2

Pand5

JaPsB---- - - 1.

pinel3

PaneU !

330

. DockSite true . . -
- , , ..
, . ,
.
, , -
.
DockClients,
TControl* DockClientstint Index]

, . DockCIientCount . DockClients DockCIientCount .


, . , DockSite = true.
OnGetSitelnfo, .
:
void

f a s t c a l l TForml::PanellGetSitelnfo(TObject *Sender,
TControl *DockClient, TRect slnfluenceRect,
TPoint SMousePos, bool scanDock)

DockClient , InfluenceRect ,
, MousePos CanDock
. CanDock = false, , . ,
OnGetSitelnfo Panell :
CanDock = DockClient != Panel6;
Panell , .
OnDockOver, , - -, ,
, .
OnDragOver Drag&Drop. :
void

fastcall

TForml::PanellDockOver(TObject *Sender,
TDragDockObject 'Source, i n t X, i n t Y,
TDragState State, bool SAccept)

, , ,
, , Source. ,
Accept = false.
, Panell , , :
Accept = Source->Control != Panel6;

Accept true , . ,
OnGetSitelnfo.
. Source TDragDockObject DockRect TRect, . .
, , Micro-


soft Office,
, ,
( Panell) DockSite
true, OnDockOver :
i n t = ClientOrigin.x;
i n t = ClientOrigin.;
if (Source->Control == Panel5)
(
if (Source->DockRect.Left <= x)
Source->DockRect = Rect(x,y,x+25,y+ClientHeight);
e l s e if (Source->DockRect.Right >= x+clientwidth)
Source->DockRect = Rect (x+ClientWidth-25,
y,x+ClientWidth,y+ClientHeight) ;
e l s e if (Source->DockRect.Top <= y)
Source->DockRect - Rect(x,y,x+ClientWidth,y+25);
e l s e if (Source->DockRect.Bottom >= y+ClientHeight)
Source->DockRect = Rect{x,y+ClientHeight-25,
x+ClientWidth,y+ClientHeight);
else Source->DockRect = Rect(Source->DockRect.Left,
Source->DockRect.Top,
Source->DockRect.Left+100,
Source->DockRect.Top+100);
)

X Y,
, . A ClientWidth ClientHeight .
15
,
, 25.
100.
, , ,
Panell, UseDockManager false.
, , OnDockOver, , . -
1, .
, OnGetSitelnfo
Panell->UseDockManager - DockClient != Panel5;
UseDockManager true , 15.
, - OnDockDrop.
. OnDragDrop Drag&Drop.
:
void
~

f a s t c a l l TForml::FormDragDrop(TObject ^Sender,
TObject *Source, int X,

i n t Y)

Source
, , X Y. ,
- , .
, - ,
OnUnDock.
:
void

fastcall TForral::FormUnDock(TObject ^Sender,


TControl "client, TWinControl *NewTarget, bool SAllow)

332

Client ,
, NewTarget ,
, Allow , , . ,
OnUnDock Panell :
Allow = Client != Panel2;
, , , 12, Panell,
, .
,
Drag&Doc, - , . , .
, ,
.
.
( Name) Fmain.
MainMenu
, .
, Caption Align = alTop.
PageControl Align = alClient,
, , (. 5.10 ). DockSite true. .
. 5.10

,

Drag&Doc

, File New Form.


FDoc ( Name). Visible true.
DragKind dkDock, DragMode dmAutomatic. TPageControl
Fmain.
FDoc Memo, Align = alClient,
(. 5.10 ). ( Lines).
Project | Options FDoc Auto-create forms Available forms, -

333

, ( , . . 5.5.1, . 5.13).
, Umain,
UDoc.
. , .
Umain File | Include Unit Hdr
UDoc.h,
UDoc.
LDoc TList.
,
.
TList * LDoc;
OnCreate Fmain
LDoc = new T L i s t () ;

LDoc.
OnDestroy Fmain
delete Ldoc;

.
.
:
TFDoc * New - new T F D o c ( t h i s ) ;
LDoc->Add(New);
New->Caption = " " + IntToStr(LDoc->Count) ;

New TFDoc,
FDoc.
FDoc New. LDoc.
FDoc, ...,
, LDoc.
. (. 5.11). ,
. , .
, , .
. 5.11
,
Drag&Doc,

1 | 2 | ^ 3 |
1

334

,
, , . , , ,
..
LDoc, . , . 3.10.2. , Drag&Drop, . , ,
.
,
.
Floating ( ),
, ,
-.

, :
UndockHeight

, ,
.

UndockWidth

, ,
.

TBDockHeight

,
.

LRDockWidth

,
.

. ,

UndockHeight UndockWidth.
ManualFIoat,
. :
bool

f a s t c a l l ManualFIoat(const Windows::TRect

&ScreenPos);

ScreenPos .
, (. 5.9)
, , , PaneI3. :
TRect TempRect;
TPoint P;
- Panel3->ClientToScreen(Point (0, 0));
TempRect.Left = P.x;
TempRect.Top - P.y;
P - Panel3->ClientToScreen(Point(Panel3->Undockwidth,
Panel3->UndockHeight));
TempRect.Right = P.x;
TempRect.Bottom = P.y;
Panel3->ManualFloat(TempRect) ;

335

TempReet, ,
. 13,
, .
. ClientToScreen . ManualFloat .
, ManualDock,
. :
bool.

fastcall

ManualDock(TWinControl* NewDockSite,
TControl* DropControl, TAlign ControlSide);

NewDockSite ,
. DropControl
NewDockSite, . , nil. ControlSide . ,
. , , , ControlSide = alLeft ,
.
, :
Panel4->ManualDock(Panell,NOLL,alLeft) ;

12 Panell,
, - .
, , , : ManualDock , -
.
12 , , ManualFloat.
ManualFloat OnCreate.
, ManualFloat
ManualDock. , , ,
, ,
.
DockSite = true, DragKind
dkDock DragMode dmAutomatic; OnCreate
ManualFloat ManualDock, ManualDock . , . - , .
.

5.4.3
Windows - .
- ( Left )
.
C++Builder. , - , - (, ) ..

336

,
. 5.12. . Image, - ( Image . . 6.1.1).
, . 5.12, ,
, , OnCreate :
TImage * Pict = new TImage(Forml);
Pict->AutoSize = t r u e ;
/*
...
*/
Pict->Picture->LoadFromFile("...");
Imagel->Canvas->CopyRect(Imagel->ClientRect, Pict->Canvas,
Rect(0,O,Pict->Width / 2,Pict->Height / 2 ) ) ;
Image2->Canvas->CopyRect(Image2->ClientRect, Pict->Canvas,
Rect(Pict->Width / 2,0,Pict->width,Pict->Height / 2 ) ) ;
Image3->Canvas->CopyRect(Image3->ClientRect, Pict->Canvas,
Rect(0,Pict->Height / 2,Pict->Width / 2 , P i c t - > H e i g h t ) ) ;
Image4->Canvas->CopyRect(Image4->ClientRect, Pict->Canvas, '
Rect(Pict->Width / 2,Pict->Height / 2,
Pict->Width,Pict->Height ) ) ;
delete Pict;

. . 5. Image AutoSize true.


. 5.12
,

.
.
Image, , .
, - :
i n t , 0;
bool move = f a l s e ;

move .
true false .
move . Y0 .

. Image. OnMouseDown, :
void

f a s t c a l l TForml::ImagelMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, i n t X, i n t Y)

337

i f ( B u t t o n != mbLeft) r e t u r n ;
XO = X;
0 = ;
move = t r u e ;
((TControl * ) S e n d e r ) - > B r i n g T o F r o n t ( ) ;
)

,
( Button mbLeft, ). Y0 X Y
. move true.
BringToFront , ((TControl *)Sender), .
.
, , .
OnMouseMove, :
void
{

if
{

f a s t c a l l TForml::ImagelMouseMove(TObject Sender,
TShiftState Shift, int X, int Y)
(move)

TImage * Im = (TImage *)Sender;


Im->SetBounds(Im->Left + X - XO,
Im->Top + Y - YO, Im->Width, Im~>Height);

SetBounds
(X X Y Y0 Y). , .. .
Width Height .
Left :
Im->Left += X -;
Im->Top += Y - Y0;

,
: , .
.
, , OnMonseUp.
:
move = false;

. OnMouseMove , ,
.
.
,
. ,
, (
. 5.12 ). , , .

338

, . 6, .
6.1.3. :
TRect r e c ;

move, X0
Y0. , .
, , OnMouseDown, :
void

f a s t c a l l TForml::Image2MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, i n t X, i n t )

(
i f ( B u t t o n != mbLeft) r e t u r n ;
XO - X;
YO = Y;
rec = ((TControl *)Sender)->BoundsRect;
move = true;
)


rec = ((TControl *)Sender)->BoundsRect;

. BringToFront,
, .
OnMouseMove, :
void

fastcall

TForml::Image2MouseMove(TObject Sender,
TShiftState S h i f t , i n t X, i n t Y)

(
i f ( i move) return,Canvas->DrawFocusRect(rec);
r e c . l e f t += X - XO;
r e c . r i g h t += x - XO;
rec .top' += Y - YO;
rec.bottom += Y - YO;
XO - X;
YO = Y;
Canvas->DrawFocusRect(rec);
}

DrawFocusRect.
,
()
(. . 6, . 6.1.5). , ,
DrawFocusRect . .
, OnMouseUp
:
void

f a s t c a l l TForml::Image4MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, i n t X,

i n t Y)

f
Canvas->DrawFocusRect(rec);
((TControl *)Sender)->SetBounds(
rec.Left + X - XO, rec.Top + Y - YO,
( (TControl *)Sender)->Width,
((TControl *)Sender)->Height);

339

((TControl *)Sender)->BringToFront();
move - f a l s e ;
}

, . BringToFront
. ,
.
, .
OnMouseUp - (, Alt).
:
Canvas->DrawFocusRect();
if(!
Shift.Contains(ssAlt))
(
((TControl *)Sender)->SetBounds(
rec.Left + X - XO, .rec.Top + - YO,
((TControl )Sender)->width,
((TControl f)Sender)->Height) ;
((TControl *)Sender)->BringToFront() ;
i
move = f a l s e ;

, Alt, . , - : , . ,
. , - , . .
Drag&Doek ManualFloat ManualDock, . 5.4.2. , DockSite true ( Image) DragKind dkDock
DragMode dmAutomatic. .
, . , , ManualFloat ManualDock,
ManualDock . OnCreate, , :
Image3->ManualFloat(Rect(Forml->Left+Image3->Left,
Forml->Top+Image3->Top,
Forml->Left+Image3->Left+Image3->Width,
Forml->Top+Image3->Top+Image3->Height));
Image3->ManualDock(Forml,NOLL,alLeft) ;

Image3
.
. .
,
.
(. 5.12 ).
. ,
OnEndDock

340

( (TControl *)Sender)->BringToFront();

.
, , . ,
. OnMouseMove , , :
c o n s t infe SC_DRAGMOVE = 0xF012;
ReleaseCapture();
((TControl *)Sender)->Perform(WM_SYSCOMMAND, SC_DRAGMOVE, ' 0 ) ;

Perform Sender Windows, .


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

5.5
5.5.1
, .
, , .
- . File | New Form
, . 2.4.

. . -,
.
-, . -, , ,
, ,
( ).
, ( ,
), . , .
.
(, ), .
. MDI , , .

, , , Project | Options
. (Project Options) Forms, . 5.13.


. 5.13
Forms

341

Pascd j Linker ) l dvanccd Lmke | Duc:aiai7Cor>di:m3te


Vmmnlria
1 u | CORBA j CotfeEyerf
Appkation j Compte \ Advanwd Complet, j C*+
, Mam form
1

IF

uto-er e formsForml
AboutBoK

i
*1

K1
.,.._,]

Form2

J
1
id

r Default

j QIC ]

Cance1

Help

Main forms . ,
, . ,
Form2 ,
(Auto-create forms) , , (Available forms).
C++Builder
CreateForm. , View | Project Source . , . 5.13,
:
Application->Initialize() ;
Application->CreateForm( classid(TForral) , &Forml);
Application->CreateForm(
classid(TAboutBox), &AboutBox);
Application->Run();

, , .
, ,
CreateForm , . ,
Forml Form2, :
Application->CreateForm( classid(TForm2), &Form2);

Form2 , Visible true,


. , , Forml
Form2. Unit2.h, Forml
include "Unit2.h"

, File | Include Unit


Hdr . .

342
:

OnCreate

OnShow


()

OnActivate

OnEnter

, -

OnResize

OnPaint

OnCreate. - , ..
. .
Show ShowModal. . ,

, . . 5.6.2.
Show ShowModal
. , , , , Visible .
Show ShowModal onShow.
, . onShow -
. onCreate , onCreate ,
onShow , .
- , .
Hide . onffide.
, CreateForm, Show,
ShowModal, Hide , , #include. ,
Unitl Unit2, Unit!
#lnclude "Unit2.h".
Unit2 - , Unitl,
Unit2 #include "Unitl.h".
Close. , . , . , , , -, -

343

, . ,
,
, ,
.
, Close.
onCloseQuery.
CanClose, , . CanClose true, . , , CanClose false. ,
.
, RichEditl, Modified ,
.
onCloseQuery :
void
if

f a s t c a l l TForml::FormCloseQuery(TObject ' S e n d e r , bool &CanClose)


(RichEditl->Modified)

i n t r e s = Application->MessageBox(
" . \n\n"
" ?\\"
"( - )",
" ",
MB_YESNOCANCEL + MB_ICONQOESTION);
switch (res)
{

case IDYES:

MSaveClick(Sender) ;
break;
c a s e IDCANCEL: CanClose = f a l s e ;

Application>MessageBox
(. . 16, . 16.7.2.3) ,
. 6.14. ,
MSaveClick.
, switch .
CanClose true .
Esc, CanClose false .
:
, ..
. 5.14

,
?
( - pdjui )

""' *" I

344

onCloseQuery true CanClose,


OnClose. Action, :
caNone

He . .

caHide

( , MDI)
.
, .
, .

caMinimize


. ,
.

caFree


. ,
, . ,
CreateForm.

Action . ,
MDI caNone caMinimize.
OnClose Action, caFree,
OnDestroy.
, .
C++Bullder 4 OldCreateOrder,
OnCreate OnDestroy. false ( ), OnCreate , , , OnDestroy
, - . OldCreateOrder =
true, C++Builder 3 , OnCreate TCustomForm, a
OnDestroy TCustomForm.

5.5.2
.

, .
, . , .
, ShowModal. Show,
.
ModalResult. . ShowModal ModalResult .
- ModalResult
, .

345

ModalResult , ShowModal. , , ,
, , , , .
C++Builder ,
, :

ModalResult

mrNone

mrOk
idOK

CanmrCancel
idCancel cel, Close,

mrAbort
idAbort

Abort

mrRetry
idRetry

Retry

mrlgnore
Ignore
idlgnore

mrYes
idYes

Yes

mrNo
idNo

No

mrAll

mrNoToAll

No

10

mrYesToAll

Yes

ModalResult ( 0 2)
.
ModalResult .
ModalResult .
. ,
TButton TBitBtn ModalResult, mrNone.
, ,
-
. BitBtn Kind, bkCustom, ModalResult,
.
.

346

5.5.3

-,
. , . , , .
. ,
- - .
- .
- , , , . , .
- . .
1. C+4-Builder .
(
-
).
FMain.
2. (File | New | Form).
-. FLog. Be BorderStyle bsNone (. . 5.1.3),
. - ( Image Picture ),
.. Label
- . - , ,
. Position ScreenCenter, .
3.

, . , ( , , , Esc ,
, ).
, KeyDown ,
Close(). onMouseDown.
. , Image ., ,
onMouseDown ,
, KeyPreview true, .

. , - , , 5 .
4.

Timer System.
, (. . 3.7.8).
Interval .
"5000. onTimer,
. Close().

347

-
. ? . - ,
.
.
, - . .
5.

OnClose :
Action - caFree;

, .
- . , Visible false. ,
ShowModal. Visible
false.
ShowModal.
,
-.
6. , UMain, - UFLog. UMain #include "UFLog.h" UMain File
Include Unit Hdr UFLog.
,
. ,
(Unitl Unit2), (
),
.
UMain OnShow.
7. UMain OnShow,
:
FLog->ShowModal();

OnShow , . . FLog , UMain , .


.
, , .
.
, , - ,
.
, , .
. ,
, -,
. , .
.
8.

. FPSW UPSW. -

348

9.

5
, . BorderStyle bsDialog, Position
poScreenCenter. Caption Enter . .
Edit,
. Text. PasswordChar " * " . OnKeyDown :
if

( K e y = = VK_RETURN)

Close ();

(
. 5.3.2.2). Enter, , , .
OnClose. , ,
Enter, , , . , ,
. , , . : . ( ) .
10. OnClose FPSW
if

(Editl->Text "1") ModalResult = 6;

. ' 1 ' .
, ModalResult
6 ( , 0 2).
, ModalResult = 2 (mrCancel),
.
,
ModalResult .
ModalResult 6, 2.
. UMain , . .
11. UMain, , , UPSW, OnShow FLog>ShowModal() :
if

(FPSW->ShowModal() != 6)
{
ShowMessage(" "};
Close () ;
)
else
{
ShowMessage (" ' " + FPSW->EPSW->Text + " " ' ) ;
d e l e t e FPSW;
}

ModalResult . FPSW>ShowModal().
6, . ,
, Close.
. ShowMessage
, ,

349

, .
. delete (. . 13, . 13.9). , . , . , .
. ,
, .
. ,
ModalKesult, ShowModal.
. OnClose FPSW :
if (Editl->Text != "1"} Application->Terminate();

Application>Terminate(). FPSW, ShowModal, .


:
FPSW->ShowModal() ;
r
ShowMessage(" " + FPSW->EPSW->Text+" ' ") ;
d e l e t e FPSW;

, .
,

5.5.4
( MDI)
MDI Word.
MDI () (
). | .
, . .
, , , , . .
.
, .
, MDI, . 5.1.2.
MDI
. FormStyle
fsMDIForm, fsMDIChild. , ( . 5.5.1 , ).

350

,, ,
. :
__ * =
new __ (Application) ;
if (! J r e t u r n ;
,
*

new
.
- . , - ( Caption ), . , .
, , UMain , | , UDoc FDoc, TFDoc (
,
, ,
C++Builder ,
).
, UDoc (. . 5.5.1
5.5.3). ,
| , :
TFDoc *TF = new TFDoc(Application) ;
if ( ! TF) r e t u r n ;

TF->Show() ;

, . .
MDIChildCount .
,
TF:
TF->Caption = " " + IntToStr(MDIChildCount);

MDIChildren[int i] i- (
, 0).
.
. , Forml () , :
for (int i = MDIChildCount-1; i >= 0; i)
MDIChildren[i]->Close();

. , . , . Cascade (
) . Tile . TileMode. tbVertical,
, TileMode tbHorizontal,
. Arrangelcons .

351

. , . , ,
. ,
. AutoMerge TMainMenu MDI :
. ,
,
Grouplndex , AutoMerge true
(. . 3, . 3.8.1).

5.5.5

MDI. , , -
(. 5.15).
MDI, . 5.15.
~~~-.~.-.
, ... ...,
. ,
.

-.-

- .

~--

,
(. 5.15 ). , C++Builder .


, (.
. 5.15 ). . 3, . 3.8.1 .

RichEdit, , . .
.
1. C++Builder .
2. FDoc.
3. RichEditl TRichEdit. Align
alClient,
. , RichEditl ( Lines).
4. TOpenDialog TSaveDialog
(. . 3.10.2). DefaultExt rtf, a
Filter "*.rtf;*.txt"
"*.*".

352

. 5.15
MDI:

(),
(),
()

->..

'
3

|)|. ',
*




i
*>
3

5.
6.

MainMenu.
( Name MFile) (Name =
) (Name = MSave).
.
:
if

(OpenDialogl->Execute)
RichEditl->Clear{) ;
RichEditl->Lines->LoadFromFile(OpenDialogl->FileName) ;'

MSave :
if

(SaveDialogl->Execute)
RichEditl->Lines->SaveToFile(SaveDialogl->FileName);

, UDoc.
( ) .
.
.
8.
FormStyle fsMDIChild.
9. (File New | Form). FMDI.
UMDI (File | Save As).
10. FormStyle fsMDIForm.
WindowState wsMaximized,
. (
File | Include Unit Hdr) #include, TJMDI.h TJMDI. .
7.

353

11. Project Options Forms


FDoc
. , , UMDI , .
12. TJMDI MainMenu. ( Name = MWind) (Name = MNew),
(Name = MCascade), (Name = ), (Name = MVert), (Name = MIcons). WindowMenu MWind.
, .
-^
, GroupIndex, , .
,
. ,
. , Grouplndex 0.
,
,
Grouplndex, , 0, .
13. Grouplndex 1.
14. OnCIick (MNew).
, :
void
{

f a s t c a l l TFMDI: .-MNewClick (TObject Sender)

TFDoc* TF = new TFDoc(Application);


if (!TF) return;

TF->Caption = " " + IntToStr(MDIChildCount);


TF->Show();
)
15. OnCIick
. :
Cascade () ;
:
TileMode = tbHorizontal;
Tile () ;
:
TileMode = tbvertical;
Tile {) ;
:
Arrangelcons

();

Ha . (. . 5.15). , , . , ,
Grouplndex FormStyle fsNormal.
, MDI.
12 C++Builder

354

5.6
C++Builder .
.
. 11, . 11.2.

5.6.1 Print
C++Builder Print,
. . , ,
: .
Form2,
Form2->Print();

PrintScale
. PrintScale:
poNone

. .

poProportional


, .

poPrintToFit

,
, .
.

5.6.2 ,
C++Builder , . , RichEdit Print, , .
, , Windows . ,
RichEditl->Print("Printing

of

RichEditl");

RichEditl, Printing of RichEditl.


.
.
RichEdit, .
RichEdit RTF.
. :
RichEditl->Lines->LoadFromFile("Test.txt");
RichEditl->Print(" Test.txt");

RichEditl->Lines->L'oadFromFile ("Test, rtf") ;


RichEditl->Print(" T e s t . r t f " ) ;

Chart, (.
. 3.6.4), Print, .
PrintPortrait, ()

355

, PrintLandscape, () . , PrintRect,
procedure PrintRect (Const R : TRect);
R , .
Chartfx (. . 3.6.5) ( . 3.29), .

5.6.3 Windows
ShellExecute

Windows
ShellExecute. . .
7.2.5. - .
ShellExecute,
include "ShellApi.h"
ShellApi.h, ShellExecnte Windows API. ShellExecute
Windows, , , . , Windows , .txt Notepad,
.doc Word.
ShellExecute(Handle, " p r i n t " , "Test.txt",NULL,NULL,SW_HIDE);
test.txt Notepad,
ShellExecute (Handle, " p r i n t " , "Test.doc",NULL,NULL,SW_HIDE) , test.doc Word.
, , SaveToFile, .
Windows Word Excel. C++Builder ( 5) ,
Windows, .
. 7, . 7.9.

5.6.4 Printer
C++Builder TPrinter, , ,
Canvas. . 6.1.3
. ,
.
TPrinter Printers.

#include <Printers.hpp>
TPrinter.

356
,

Canvas

Canvas , . Canvas ,
() Brush (), . . 6.1.3.

TextOut

, .

Draw

, .

BeginDoc

EndDoc

. EndDoc.

PageHeight

PageWidth

NewPage

PageNumber

, , . Imagel. :
TPrinter *Prntr - Printer ();
Prntr->Canvas->Font->Size = 12;
Prntr->BeginDoc ();
Prntr->Canvas->TextOut (10,10," P r i n t e r " ) ;
Prntr->Canvas->Draw(
(Prntr->PageWidth - Imagel->Picture->Bitmap->Width)/2,
40, Imagel->Picture->Bitmap);
Prntr->EndDoc() ;
Printer,
TPrinter.
Prntr.
.
BeginDoc .
TextOut, (10,
10), Printer. Draw
.
. 40.
EndDoc .
Printer
. Printer .
QuickReport, . 11.2.

357

5.7
5.7.1

, . , , Windows ,
. C++Builder 5 .
, , . ,
. .dfm
.res , . , , ,
resburcestring.

. , .
, , ListBox, , MainMenu. StatusBar AutoHint true. ShowHint
true.
Hint .
- ( Caption),
, . - ListBox,
. Hint. true
ShowHint . - . , . 5.16.
5.16

()
()

-JH.23

Selected line i
'this it a ttitngi liit
- ,
OnClick :
if (ListBoxl->IteraIndex >= 0)
Label2->Caption = " '" +
ListBoxl->Items->Strings[ListBoxl->ItemIndex] + " ' " ;
else Label2->Caption - " ";
Label2 , List Box 1.
. , , . , , - . , -
(
OnClick).

358

. , . , , . , , . Windows, ,
.
C++Builder 5 .dfm, ., . ,
, , . . ,
, .
.
ListBox, , - .
LislBox2, Visible = false
( Items) ' .
,
, :
define SSel L i s t B o x 2 - > I t e m s - > S t r i n g s [ 0 ]
define SNoSel L i s t B o x 2 - > I t e m s - > S t r i n g s [ 1 ]

OnClick :
if(ListBoxl->ItemIndex >= 0)
Label2->Caption = SSel +
ListBoxl->Items->Strings[ListBoxl->ItemIndex] + " ' " ;
else Label2->Caption = SNoSel;
. ,
, .. .dfm.
, , .
, , , . . , , , Pascal,
resourcestring .res.
.
, Project | Build All . ,
.
, Project | Build All. .

.
, File | New | Other New Resource DLL wizard DLL . (
).
, , , , , Next . , -

359

- . , . 5.17.
, . ,
. - , , . . , . , .. . , .
. 5.17

Select one of more languages for which to made resource DLLs, Toediian
extension, amply dick on it
.FATestsMnlomahPiojecti.bpF

Language

Locate ID

() fttOOOOl DOS
(&. 0x00002409
| 3
0x00001409
0x00000409
()
|)
( ,.

( .
(]

0x00003409
0x00001 COS
0x00002009

Extension . j$
ENC
I
ENB

ENU
ENT
ENP
ENS
ENJ

Zt

, , . 5.18.
Add File - , , . C++Builder .dfm ,. - : , , , .ini (. . 5.7.2), .
,
ListBox - , . .,
, , . . 5.18. , .
C++Builder .
.
. 5.18

You can add mtsceLlaneous lues lojrcur proiect. These aie Files that the IDE does
not know about, but you need to do youi translations I e.lni. Source code, binary
or other DFMs and BCs files that the IDE does not know about.
Project

FATestj\lrtemarojecl1.bpt
Fie
F VTestsMnternatSPrcjecti.fes

jf'"TSd"file""'.']|

: Tjipe
<unKnown>

Bemove File

360

.res,
, resourcestring, . 5.18
.
Add File, All files (*.*)
, , , .res.
DLL
Finish, , .,
,
, . ..
, . (. 5.19), .
. Environment
, .
. , C++Builder 6
: C++Builder,
External Translation Manager (ETM), C++Builder.
, . C++Builder ,
, .
Files , .
.
Notepad () , , .
. 5.19

Etvtrwsrrent | Fies Wort


I *Q ** "Q -
1*(
, glFor
D
D

Resource Scripis
) PlqeclLDR

d
- \^ Resource Scripts
*] Proiicfl.DR

jSWuT.,. ^^..^.^"() [-f*]


f Untiamfaled
| Untranslated WSSansSenl
3 Translated Choice
flrarHatsd lntemationalizetti
iTranslatad %Edit
I Tramlated
f Translated ListlThisi
| Translated imeV
I Trandated Ime 2'
iTranstatsd ims'J
- Translated UFile1
I
ml Formi Caption JF \. 4itiernat\ENU\linit1 dfr

Workspace (. . 5.19).
. (Forms) (Resource Script) . , , Unit!. (.
. 5.19) , .
Id ( . 5.19 )
.
, , , .
. , , , -

361

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

Projectl_DRC, , resourcestring,
' .
ListBox2,
Unit 1.
Project 1_DRC , Unit 1.
. , . ,
, ,
( . 5.19).
C++Builder 6
, ( C++Builder ). :
Show original form

, . ,
.

Show translated form

. , , , - - . , , ,
Left, Right, Width, Height, . 5.19.

Refresh translated form

Keep forms on top

.

.

, ,
.
Actions . 5.19 ..
- .
Repository Add
Strings to Repository Get Strings from Repository. .
, . (. . 5.20)
, . 5.19.
, . .

362

. 5.20

D
Hew
1

flpen..

AI

} i
Savers . nd . ; Impot

Save

''
8'
'

Export

Et

Help

'11*[1)
1
j ()
tEdf
Wile1
.'Choice'
'Intetnatbndizalion'

| J

Get Strings from Repository , ,


, . , Multiple Find Action .
(. 5.21) +-KBuilder 6
. 5.19 Tools | Translation Tools Options .
Multiple Find Action Skip, . Use first, . Display selection,
.
. 5.21
C++Builder

?52-i Color j Font | FormDesisnerl


* TtwisfaSon Repository
Filename: |$(ETMdefault ips

Resource DLL Weald , J7 (Uiiomalic (epostoii" query


I JS" Agtumafcatty compie pfq'ects
W ShowIranslationManageraftwRDW
Translation Manager ' " ""

r Multiple Find Actiun


' t Skip
, 1 Use frst
1

i ^ Qttpby eeleefon

f? Aulornafcali' isfn^s
MsceHaieous
p" ^ save files
; grfftrnal Editor - " J !

Help


Resource DLL Wizard. :
Automatic repository query

Automatically compile projects , , .


Show Translation Manager
after RDW

363

Automatically quate strings , . Automatically save files



.
Translation Repository Filename, .rps
.
,
.
External Editor , Files .
Preferences .
Colors , Fonts
.
.
, . , ( View Project Manager),
. 5.22. Projectl.exe, , Projectl.enu Projectl.rus, . Forml
, , . Projectl_DRC.rc
. .
. .
. S.22

- , u?
X
fj.
~*^ New Remove
; Path ,
Files
|CJ) Proiecfl.res FVFestsSn
l temat
_ti
Proper! epp F:\Tes tsMnternat
- jj UniH epp
F:\Tests\lnternat
+ i] Uniti.epp F:\Tests\lriternat
F:\Tests\lnternat
2 ures pas
F:\Tests\lnteinat
'- 5 PiopcttENU
F:\Tests\lntemat\ENU
K) Projecd.epp F:\Tests\lnternat\ENU
+ 3 Form
RUestsMnterna^ENU
= S3 PioiecttRUS
F:\Tests\lnternatSRUS
^] Proi
ecttcpp F:\Tests\lnternat^RUS

+ 3 ' '
F:\Tests\lnteinat\RUS
3
jPioiecfl.exe

. Project1.exe.
, Activate, C++Builder
Run. . , (. 5.16 ).
Project Languages.
Add ( ), Remove ( ), Set Active
( ) Update Resource DLLs ( DLL ).

364

'*^^""^*''^^^***^^^**'^^ ^^w^^a^asasa****^* ^^.

Project | Languages, Add, ,


(
Projectl.exe) .

Add DLL ,
. Remove ,
. ,
. ,
. DLL .
Update Resource DLLs DLL .
- . , - Project | Build All .
Set Active . , , <>. , , Windows. (
. 5.17, Set Active). , , , , .
, (. 5.16 ), .
,
.
C++Builder . .
,
Projectl.exe Projectl.enu . C++Builder. (Projectl.exe) Windows, , . -. Windows . , .
. , . ,
C++Builder . , -.
!
. .
, , , , -
.
-----..---.-----~--^
, , ( Projectl.enu).

5.7.2 :

. ,

365

CD ROM . , .
, .., .
,
, .
, Windows 3.x
.ini. , Windows 95 NT Microsoft , . (Registry)
,
Windows Windows. , Windows 3.x
.ini, Windows 95 NT .
, , , .
, . .
:
.
, , . , ,
, .
. :
Hkey_Local_Machine

,
.
Hkey_Current_Config .
Hkey_Dyn_Data
Hkey_Classes_Root

, plug-and-play.
OLE, Drag&Drop,
Windows 95.

:
Hkey_Users

, .

Hkey_Current_User

, .

SYSTEM.DAT Windows. Windows Regedit.exe


(. 5.23). , -

C++Builder, .
, - , SYSTEM.DAT, Windows, - . .
Windows.

366
. 5.23

Regedit.exe

<
jg
_J HKY_CLAS5ES_ROOT
V 1
+
1_J HKEY_CURRENT_U5ER

- wl HKEV_LOCAL_^ACH
* _J 5AM
J SECURT
IY

^]( ) !
]

1
, REG SZ ( )
REG_5Z TRegistry
REG^SZ F i \Tests\RsgINI\PReolstry, exe
RE5_SZ MS Sens Serif

J SOFTWARE
- JflProjects

+ l l ActiveSt^e
^1

.1 TWftR6(APro[KtS^l
^IEVso

'4

C++Builder TRegistry,
registry. TRegistry ,
#include

"registry.hpp";

TRegistry
, RootKey. RootKey =
HKEY_CURRENT_USER. TRegistry
, RootKey.
CurrentKey. .
CurrentPath ( ) , .
:
bool

f a s t c a l l (const AnsiString Key,

bool CanCreate);

Key, .
Key . Key
, , RootKey.
CanCreate , Key,
. KEY_ALL_ACCESS. .
: WriteInteger, WriteFloat, WriteBool, WriteString .
. :
void
void

f a s t c a l l Writelnteger(const AnsiString Name, int Value);


fastcall WriteString(const AnsiString Name,
const AnsiString Value);

Value Name. : Readlnteger, ReadFloat, ReadBool, ReadString . :


int
fastcall Readlnteger(const AnsiString Name);
AnsiString
fastcall ReadString(const AnsiString Name);

, :
, .
.
Button FontDialog. ( BInst
Install) . , , , . ( BUnlnst Unlnstall) . ( !),
. ( BFont Font)

367

, ,
, .
.
#include "registry.hpp";
TRegistry *Reg = new TRegistry;
i /

void
faatcall TForml::FormDestroy(TObject *Sender)
{
7
// Reg
delete Reg;
)
//
void
fastcall TForml::FormCreate(TObject *Sender)
{
// Reg
Reg->RootKey = HKEY_LOCAL_MACHINE;
if {Reg->KeyExists ("WSoftwareWA ProjectaWPl" ) ) .
<
/* , */
Reg->OpenKey ("\\Sof t w a r e W A ProjectsWPl", true) ;
Font->Name = Reg->ReadString("") ;

void
fastcall TForml::BInatClick(TObject *Sender)
{
//
Reg->OpenKey ("WSoftwareWA Projects", true) ;
Reg->WriteString(""," ");
Reg->OpenKey ("WSoftwareWA ProjectsWPl", true) ;
Reg->WriteString("","TRegiatry");
/*3 */
Reg->WriteString("",ParamStr(0));
//
Reg->WriteString("",Forml->Font->Name);

void
fastcall TForml::BUnlnatClick(TObject *Sender)
{
// PI
Reg->DeleteKey ("WSoftwareWA ProjectsWPl") ;

void
fastcall TForml::BFontClick(TObject *Sender)
(
FontDialogl->Font->Assign (Font) ,//
if(FontDialogl->Execute())
(
Font->Asaign(FontDialogl->Font);
if (Reg->OpenKey ("WSoftwareWA ProjectsWPl", false) )
/* 1 */
Reg->WriteString("",Forml->Font->Name);

368

registry Reg TRegistry.


TForml::FormDestroy.
TForml::FormCreate
Reg HKEY_LOCAL_MACHINE.
KeyExists , \Software\A jects\Pl. , ,
. , KeyExists
false, - , , .
, "\" :
\\Software\\A Projects\\Pl.
KeyExists true,
\Software\A Projects\Pl ReadString
, , .
TForml::BInstClick,
. :
Projects PI Software ( ).
1
A Projects .
, , . 1 (
) .
TRegistry. ,
.
, ParamStr(O). , .
.
TForml::BUnInstClick
( 1) . ,
,
.
TForml::BFontClick , , . false.
, ( 1
), .
.
Install. Regedit.exe .
( . 5.23).
Unlnstall. Regedit.exe | . , 1 . Install, Font
- . Regedit.exe
, .
. , ,
. , , .
, Regedit.exe A Projects,
1.

-_

369

5.7.3 .ini
. 5.7.2 ,
. 32- Windows. ,
Windows 3.x,
.ini.
32- Microsoft .ini.
, 32- , ,
. Microsoft .
.ini , . , , . , [Desktop]. , , , , :
<><>
ODBC.INI:
[ODBC 32 b i t Data S o u r c e s ]
dBASE F i l e s = M i c r o s o f t dBase D r i v e r ( * . d b f ) (32 b i t ) '
E x c e l F i l e s = M i c r o s o f t E x c e l D r i v e r ( * . x l s ) (32 b i t )
FoxPro F i l e s = M i c r o s o f t FoxPro D r i v e r ( * . d b f ) (32 b i t )
T e x t F i l e s = M i c r o s o f t T e x t D r i v e r ( * . t x t ; * . c s v ) (32 b i t )
[dBASE F i l e s ]
Driver32=C:\WINDOWS\SYSTEM\odbcj t 3 2 . d l l
.ini, , Windows,
GetWindowsDirectory.
C++Builder .ini TIniFile. inifiles, uses ( ).
TIniFile .ini, . .
: WriteString, WriteInteger, WriteFloat, WriteBool . . . :
void
fastcall WriteString(const AnsiString Section,
const AnsiString Ident,
const AnsiString Value);
void
fastcall Writelnteger(const AnsiString Section,
const AnsiString Ident,
int Value);
Section , Ident , Value . , .
: ReadString, Readlnteger, ReadFloat,
ReadBool . :
AnsiString
fastcall ReadString(const AnsiString Section,
const AnsiString Ident,
const AnsiString Default);
int
fastcall Readlnteger(const AnsiString Section,
const AnsiString Ident,
int Default);

370

Ident Section. Default


, , .
ValueExists,
. DeleteKey
.
SectionExists. EraseSection . ,
C++Builder.
, , .
, .
5.7.2. Button FontDialog. ( BInst Install) . , ,
, .ini Windows.
( BUnlnst Unlnstall) . ,
Windows .ini. ( BFont
Font) , ,
.ini, .
.
#include "inifiles.hpp";
include <stdio.h>
TIniFile *lni;
String sFile;
//
void
fastcall TForml::FormCreate(TObject *Sender)
{
char APchar[255);
// Windows
GetWindowsDirectory(APchar,255);
sFile = (String)APchar+"\\My.ini";
if(FileExista("My.ini"))
<
// Ini
Ini = new TIniFile (sFile);
//
Font->Name - Ini->ReadString("", "",
"MS Sans Serif");

void
faatcall TForml::FormDeatroy(TObject *Sender)
{
.
if (Ini == NULL) return;
//
Ini->UpdateFile ();
//
delete Ini;
.
)
//

___

___

void
fastcall TForml::BInstClick(TObject *Sender)
(
FILE *F;
// . ini


if

(I

371

FileExists (sFile))

// . i n i
if ((F = f o p e n ( s F i l e . c _ s t r ( ) ,

"w+")) == NULL)

ShowMessage(" ");
return;
}
fclose(F); //
}
// Ini
' Ini = new TIniFile (sFile);
/* Files, main
*/
Ini->WriteString("Files","main",PararaStr(0));
/* ,
*/
Ini->WriteString("","",Font->Narae);
}
/ / _ ' _
______________ ___
__
void
fastcall TForml:rBUnlnstClick(TObject *Sender)
(
FILE *F;
// .ini,
if (FileExists(sFile))
DeleteFile (sFile);
)
/ /

_ _ _

void
fastcall TForml::BFontClick(TObject 'Sender)
!
//
FontDialogl->Font->Assign(Font) ;
if (FontDialogl->Execute())
{
//
Font->Assign(FontDialogl->Font);
if((Ini != NOLL) && Ini->ValueExists("",""))
// "" ""
Ini->WriteString ("","",Font->Name);

inifiles.hpp, TIniFile, -stdio.h, . Ini TIniFile sFile,


. TForml>FormCreate (My.ini)
Windows. GetWindowsDirectory. FileExists , , ..
. , Ini,
,
. , .
TForml >BInstCHck, . FileExists , Windows My.ini. , (
) fopen w.
Ini.
Files . main . ParamStr(O)

372

(. . 16, . 16.7.4). , ,
:
[Files]
main=D:\TESTS\REGINI\PINI.EXE
[]
IHpHJ>T=MS Sans S e r i f

TForml->BUnInstClick
. .ini,
( ) Files .
TForml>FormDestroy,
, UpdateFile Ini
, Free .
TForml>BFontClick
, ,
.ini.
.
Install. My.ini Windows. Windows
. , C++Builder.
Unlnsfall .
.
Install, Font - . . , , . ,
, .


6.1
6.1.1
6.1.1,1 Image
- . , . , . Image, Additionol , DBImage,
Dafo Controls.
. Image. , Picture.
Image, Picture Editor
(. 6.1), Picture -
( Load), . Load, .
Load Picture, . 6.2.
. Images.
. files\Common Files\Borland Shared.
. 6.1 6.2 ...\lmages\Splash\16Cofor\earth.bmp.
(. 6.2)
, , . , , .
Image . . , , .
. 6.1
Picture Editor

374
. 6.2

J I6C0I
M
fl * *
(
11 *.^
^athenabrnp
22
chp
l.bmp

"Jconstruc.bmp ZZKS |
ZZK6 (
22


oi 1?:
30.01.200217:30
30 0! 200217 30
10 01 2002 17 30
30.01 .ZODZ 17.30
30.01.200217,30

," ipeg," birp* *," wmfl

Image, , .
. , , Image .
Image.
AutoSize true, Image
.
AutoSize false,
, ,
.
Stretch , . AutoSize false,
Image Stretch true. ,
, Image , . Stretch true - , . Stretch
, (. . 6.1.1.3).
Center, true, Image, .
Transparent (). Transparent true, Image . . Image .
- , . , ,
, , (
...\program files\comimon files\borland shared\images\buftons\orrowlr.bmp).
Image , , Transparent true. , .
, .
C++Builder Image Editor, .
, Transparent ( . . 6.1.1.3).

375

6.1.1.2
,
. , . PietureDialog, Dialogs
(. 6.2),
, .

:
if (OpenPictureDialogl->Execute{) )
Imagel->Picture->LoadFromFile(OpenPictureDialogl->FileName) ;

Picture Imagel ,
. .

Imagel.

,
. , . Imagel
AutoSize true, :
if (OpenPictureDialogl->Execute () )
Imagel->Picture->LoadFromFile(OpenPictureDialogl->FileName);
Forml->ClientHeight = Imagel->Height + 10;
Imagel->Top = Forml->ClientRect.Top
+ (Forml->ClientHeight - Imagel->Height) / 2;
Forml->ClientWidth = Imagel->Width + 10;
Imagel->Left = Forml->ClientRect.Left
+ (Forml->ClientWidth - Imagel->Width) / 2;


Imagel, AutoSize.
, (. 6.3), .
. 6.3

6.1.1.3
, , . C++Builder ,
. ;

376


. ( .bmp) . ,
, .
( .ico) .
,
, , .
,
. , ,
, .
(Metafiles) , , . ,
. , , , .
C++Builder 6 :

JPEG Image File

jpg. jpeg

(Bitmaps)

.bmp

.ico

Enhanced Metafiles

.emf

Metafiles

.wmf

6.1.1.4 TPicture, TBitmap,


Tlcon TMetafile
. , , ,
C++Builder TBitmap, Tlcon TMetafile.

TGraphic. , ,
TBitmap, Tlcon TMetafile .
TPicture, .
Graphic, , ,
. , , TGraphic. TPicture>Graphic, ,
TPicture->Bitmap, TPicture->Icon TPicture->Metafile.

:
void
void

fastcall LoadFromFile(const System::AnsiString Filename);


fastcall SaveToFile{const System::AnsiString Filename);

TBitmap, Tlcon TMetafile . TPicture


.

:
void

fastcall Assign(TPersistent*

Source);

377

TBitmap, TIcon TMetafile : , , . . TPicture , . TPicture


, , .
. TBitmap,
, . ,
, :
// Bitmap
G r a p h i c s : : T B i t m a p * B i t m a p = new G r a p h i c s : : T B i t m a p ( ) ;
void
f a s t c a l l TForml:;FormDestroy(TObject *Sender)
// Bitmap
(
Bitmap->Free () ;
}
//
void
fastcall TForml::MOpenClick(TObject *Sender)
// Bitmap Imagel
{
if (OpenPictureDialogl->Execute())
(
Bitmap->LoadFromFile(OpenPictureDialogl->FileName);
Imagel->Picture->Assign(Bitmap);
)
)
1I

void ___fastcall TForml;:MSaveClick(TObject *Sender)


// Imagel Bitmap
{
Bl1tmap->Assign (Imagel~>Picture) ;
} '
/ / _ _

....

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


// Imagel Bitmap
(
Imagel->Picture->Assign(Bitmap);
}

Bitmap TBitmap . Bitmap,


.
. , , OnDestroy ( FormDestroy) Free:
Bitmap->Free () ;

MOpenClick Bitmap LoadFromFile


.
Imagel->Picture->Assign(Bitmap);

Bitmap Picture
Imagel. .
:
Forml->Imagel->Picture->Bitmap->Assign(Bitmap) ;

378

Bitmap Imagel
( ),
( MSaveClick):
Bitmap->Assign(Imagel->Picture);
Imagel ,
- , ( MRestoreClick):
Imagel->Picture->Assign(Bitmap);
, , Assign .
,
void
f a s t c a l l LoadFromResourceName(int-Instance,
const System: : AnsiString ResNarne) ;

void
f a s t c a l l LoadFromResourcelD(int Instance, i n t ResID);
ResName , a ResID . ,
Bitmapl->LoadFromResourceName(HInstance,"MYBITMAP");
Bitmapl "MYBITMAP".

. 6.1.2.4.

Clipboard,
C++Builder.

6.1.2 Image Editor


6.1.2.1
C++Builder Image Editor, Tools | Image Editor. . 6.4 . . , ,
, . '
, .
)
. 6.4
E-e
l yt ttw _

()

fi

()

i;:

379

File, Open
, New
. New, ,
, :
Resource File (.res)

Component Resource File (.dcr)

Bitmap File (.bmp)

Icon File (.ico)

Cursor File (.cur)

, , . , Bitmap File, (. 6.4 ),


(Size) (Width) (Height),
: 2, 16 256. , 16 .

, . 6.4 . . View
2 ( Zoom In), ( Zoom
Out) ( Actual Size).
, :

, , ..
, , ..

, ,
.
, , , ,
, .

, ,
, ,
. ,
.

, , , ,
. , .

. . ,
.
.
Text .

380

6
,
.
, , . , ,
, , .


, , ,
, , .
, , , , , , , , .
(. 6.4 )
. .
, , ;
, , .
, , . (, , ), - . , - .bmp ( File | Open ) - ,
, .
.bmp. Transparent Image,
. 6.1.1.1.
. , , .
6.1.2.2
,
. . 8.2. , .
.bmp 24 24. , , , . , , , .
C++Builder, ,
, , , . , .
8 ,
. Edit, "",
. ,
24 24. ( Small Fonts).
false AutoSize. .

381


Alf+Print Screen,
.
(Tools | Image Editor), File | New | Bitmap File (.bmp) (. 6.4 ) 24x24. . Edit | Paste, . , . File | Save As .
(. . 8.2, . 8.1, ).

. ,
, ,
.
6.1.2.3
. ,
SpeedButton BitBtn, , Gliph. 16x16. . . ,
Enabled false. . ( SpeedButton) .
4 . (File | New | Bitmap File (.bmp))
(. 6.4 ) 64 16. 4 , (. 6.5 ), , , .
. 6.5
) Image editor
gfe 1st* **

() (6)

Bitmap Whdot Help

*! "

*1

"--- r,l.q|,xl

';

1
X:035 V:017

382

,
, .. ,
. , , , , , .
, . (. 6.5 ) :
SpeedButton, BitBtn Button. Gliph SpeedButton BitBtn . Caption BitBtn - , BitBtn. ,
NumGliphs 4.
Margin Spacing ,
. SpeedButton Grouplndex 1,
AllowAllUp true. Button :
BitBtn2->Enabled = ! BitBtn2->Enabled;
SpeedButton2->Enabled = ! SpeedButton2->Enabled;
. ,
. . .
SpeedButton ' .
.
, , Windows . ,
(. . 4.4) . - , Windows,
. , ,
Print Screen.
, , 6.1.2.2. (Tools [ Image Editor), File | New
Bitmap File (.bmp) (. 6.4 ) 16x16.
. Edit | Paste
( Ctrl-V),
. , . . 6.4 . File | Save As .
ImageList (. . 4.2).
6.1.2.4

. , , -
. .res
(.), (.ico), (.cur),
. .dcr (dynamic component resource )
, .res.

. , ";. - , , LoadCursor Cursors Screen (-

383

. 4.7). . ( ),
C++Builder (. . 8.3).
, .
File | Open, .res, - . , (. 6.6 ).
Icon, MAINICON, .
Resource | New ( ),
: Bitmap, Cursor Icon. , , .
Resource | New | Cursor
. , LoadCursor.

, .

Cursor (. . 6.6 ) : Set Hot Cpot
, Test . ,
X Y, (. . 5.3.1.2). Set Hot Cpot
(. . 6.6 ), . , ..
, . , . 6.6
, , .
. 6.6

()
()

384

Cursor | Test. , .
, ,
. ,
,
.
, File | Save.
, . . 6.7.
File | New | Component Resource File (,dcr). ,
,
Resource | New | Bitmap
24x24.
.
. 6.7

Fib Resource Wndow

~ Co1ntents
i- Btimap

jTEDITLETNUM I

tr

, .
C++Builder
. . .dcr
, , , , . ,
. 6.7 , , . 8.3.
TEditLetNum, ,
, EditLetNum.

C++Builder .

, . 6.1.2.2.

6.1.3
6.1.3.1
C++Builder Canvas (, ),
, . , Image, PaintBox, Bitmap . , C++Builder.
, C++Builder , .

385

X Y. ,
C++Builder, . X
, Y
.
, , , . . , . ,. TColor. , 4T(^LC++Builder
TColor. ( clBlne ),
,
Windows (, clBtnFace
). . . 17,
. Color.
. , . 4- ,
,
. , $OOFFOOOO , $OOOOFFOO , $OOOOOOFF .
$00000000 , $OOFFFFFF .
. 17.
6.1.3.2
.
. Pixels. Canvas->Pixels[int X][int Y],
. , Canvas>Pixels[10][20] ,
10- 20- .
: , ,
. , Canvas>Pixels[10][20] =
clBlack .
F(X) Image 1, Ymax Ymin Xmin . :
float X,Y;
//
i n t PX,PY;
/ . /
f o r ( = 0; <= I m a g e l - > W i d t h ; PX++)
(
//X - ,
X = Xmin + * (Xmax - Xmin) / I m a g e l - > W i d t h ;
Y = F(X) ;
//PY - , Y
PY = Imagel->Height - (Y - Ymin)*Imagel->Height/(Ymax-Ymin);
//
Imagel->Canvas->Pixels[PX][PY] = clBlack;
)

X Y,
, PY, , X Y. Image 1. X. Y. -

386

PY.
(, PY) .
, . sin(X), Xmin=0, = 4 (2 ), Ymin=-l, Ymax=l.
, Image , OnClick , , :
define Pi 3.14159
float X,Y;
// i'3
'
i n t PX,PY;
//
for (PX - 0; PX <- Imagel->Width; PX++)
//X - ,
X - * 4 * Pi / lmagel->Width;
Y = sin(X) ;
//PY - , Y
PY = Imagel->Height - (Y+l) * Imagel->Height / 2;
//
Imagel->Canvas->Pixels[PX][PY] = clBlack;
)
, ( ) . . 6.8 .
.
. 6.8

LineTo

6.1.3.3
. ,
. Color , . Width ( ).
. 1.
Style . :
psSolid

psDash

psDot

psDashDot

- .

387


psDashDotDot

, .

psClear

.
, Width > 1 , Windows.

psInsideFrame

. 6.9.
. 6.9

psSolid
psDash
piDot
psDathDot
psDashDotDot
psClear
psIneideFrame

Width = 1. .
psInsideFrame , .
Windows.
PenPos.
. , .. PenPos, MoveTo(X,Y). (X,Y) , . , LineTo(X,Y) (X,Y).
LineTo .
.
, Image , . 6.8.
Image ,
, .
,
Size.


Image2->Canvas->MoveTo(0,Image2->Height / 2) ;


.
Image2->Canvas->LineTo(PX,PY);

, .
, :
fdefine Pi 3.14159
f l o a t X,Y;
//
i n t PX,PY;
//
Image2->Canvas->MoveTo(0,Image2->Height / 2) ;
f o r (PX = 0; PX <= Imagel->Width; PX++)
{

//

X - ,
, PX
X = PX * 4 * Pi / Imagel->Width;
Y = sin(X);
// PY - , Y

388
PY = Imagel->Height - (Y+l) * Iraagel->Height / 2;
//
Imagel->Canvas->Pixels[PX][PY] = dBlack;
//
Image2->Canvas->LineTo(PX,PY);

,
, ,
,
.
. , . 6.8. ,
. . . , , .
Image .
, ,
. ,
Image, . , , , .
, Y, :
Y = 2 sin(X) ;
, . 6.10.
, . , - .
. 6.10

,

pHRIJIIIlh 1N1 11.1

, . , :
Arc

Chord

,
.

Ellipse

Pie

Polygon

- .

389

Polyline

- .

Rectangle

RoundRect

. 6.11.
. 6.11
,
(

\ L

Arc

Choid

Polygon

Po^n
ile

^
;
Ep
ilse.

Pe
i

Rectange
l

[ )
RoundRect

, ,
. 6.11. , . . 18.
Imagel->Canvas->Font->Style fsBold;
Imagel->Canvas->Arc(10,10,90,90,90,50,10,50);
Imagel->Canv.as->TextOut (40, 60, "Arc") ;
Imagel->Canvas->Chord(110,10,190,90,190,50,110,50);
Imagel->Canvas->IextOut(135,60,"Chord");
Imagel->Canvas->Ellipse(210,10,290,50);
Imagel->Canvas->TextOut(230,60,"Ellipse");
Imagel->Canvas->Pie(310,10,3 90,90,390,30,310,30),
Imagel->Canvas->TextOut(340,60,"Pie");
TPoint p o i n t s [ 5 ] ;
points[0] = Point(30,150),
points[1] = Point(40,130);
points[2] = Point(50,140);
points[3] = Point(60,130);
points[4] = Point(70,150);
Imagel->Canvas->Polygon(points,4);
Imagel->Canvas->IextOut(30,17 0,"Polygon") ;
p o i n t s [ 0 ] . x += 100;
p o i n t s [ 1 ] . x += 100;
p o i n t s [ 2 ] . x += 100;
p o i n t s [ 3 ] . x += 100;
p o i n t s [ 4 ] . x += 100;
I m a g e l - > C a n v a s - > P o l y l i n e ( p o i n t s , 4) ;
Imagel->Canvas->TextOut(130,17 0 , " P o l y l i n e " ) ;
Imagel->Canvas->Rectangle(230,120, 280, 160) ;
Imagel->Canvas->TextOut(23 0,17 0 , " R e c t a n g l e " ) ;
Imagel->Canvas->RoundRect (330, 120,,380, 160,20,20) ;
Imagel->Canvas->TextOut(325,170,"RoundRect") ;
.
. , , , .

TextOut, :
void
fastcall TextOut(int X, int Y,
const System::AnsiString Text);

390

, .
Font ,
. ,
.
6.1.3.4 Brush
Brush . . Brush , . Color . Style ().
. . 17.
Bitmap, TBitmap . 8x8. Bitmap, ,
Style.
Bitmap ,
, , ,
:
Graphics::TBitmap 'BrushBmp = new Graphics::TBitmap;
try
(
BrushBmp->LoadFromFile("MyBitmap.bmp");
Forml->Canvas->Brush->Bitmap = BrushBmp;
Forml->Canvas->FillRect(Rect(0,0,Forml->Width,Forml->Height));
)
finally
<

Forml->Canvas->Brush->Bitmap = NULL;
d e l e t e BrushBmp;

BrushBmp TBitmap MyBitmap.bmp. Forml>


Canvas>Brush->Bitmap . .
FillRect , . OnResize,
. ( -
) Bitmap NULL,
Style. BrushBmp ,
.
FillRect,
void

fastcall FillRect(const Windows::TRect SRect);

, Rect: TRect. Rect(Xl,Yl,X2,Y2), Rect


, (XI, Y1) (2, Y2).
FillRect , , . ,
Imagel->Canvas->FillRect(Rect(0,0,

Imagel->Width,Imagel->Height));

Imagel.

391

.
. . Chord, Ellipse, Pie, Polygon .
, .
FloodFill, .
:
void

f a s t c a l l F l o o d F i l l ( i n t X, i n t , TColOr Color,
TFillStyle F i l l S t y l e ) ;

X Y , .
Color FillStyle. Color
, , FillStyle , . FillStyle : fsSurface
fsBorder. FillStyle = fsSurface, , Color, . FillStyle = fsBorder,
, , Color, a
Color .

, ( FillStyle = fsSurface) ( FillStyle = fsBorder). . 6.1.4
FloodFill.
, . FrameRect.
, .
FrameRect:
void
fastcall FrameRect(const Windows::TRect SRect);
Rect . 1 . .
FrameRect Rectangle ,
( Rectangle ) ( Rectangle ).

6.1.4


,
.
1. .
2. TImage (. 6.12), , , 20 20. .
Imagel Image2.
3. TImage
, , , ,
. . Image3.
4. TImage
. .
, , 10
. Image4.

392
. 6.12

mm

:
() ,
()

<

dM i

5.

% 1 1 1

TSpeedButton
. . SBBrush. Grouplndex 1 AllowAllUp true.
(. . 3.7.3). Glyph ( ..\lmages\Buttons\brush.bmp).

TSpeedButton
SBBrush. . SBColor. , ,
Grouplndex 1 ( ,
) AllowAllUp true.
Glyph (, ,.\lmages\ Buttons\one2one.bmp).
7.
OpenPictureDialog.
8. MainMenu.
. . . Undo.
. .
6.

393

9. :
Graphics::TBitraap *BitMap = new Graphics::TBitmap;

BitMap TBitmap. , .
10. OnCreate :
//
Imagel->Canvas->Brush->Color = clBlack;
Image2->Canvas->Brush->Color = clWhite;
//
Imagel->Canvas->FillRect(Rect(0,0,Imagel->width,
Iraagel->Height));
Image2->Canvas->FillRect(Rect(0,0,Image2->Width,
Image2->Height));
//
i n t HW = Image4->Width / 10;
//
f o r ( i n t i = 1; i <=10; i++)
(
switch (i)
{
case 1:Image4->Canvas->Brush->Color = clBlack;
break;
case 2:Image4->Canvas->Brush->Color = clAqua;
break;
case 3:Image4->Canvas->Brush->Color = clBlue;
break;
case 4:Image4->Canvas->Brush->Color = clFuchsia;
break;
case 5:Image4->Canvas->Brush->Color = clGreen;
break;
case 6:Image4->Canvas->Brush->Color = clLime;
break;
case 7:Image4->Canvas->Brush->Color = clMaroon;
break;
8:Iraage4->Canvas->Brush->Color = clRed;
break;
case 9:Image4->Canvas->Brush->Color = clYellow;
break;
case 10:Image4->Canvas->Brush->Color = clWhite;
)
Image4->Canvas~>Rectangle((i-1)*HW,0,i*HW,
Image4->Height);

// -
Image3->Canvas->MoveTo(0,0);
Image3->Canvas->LlneTo (Image3->Width,Image3->Height);
Image3->Canvas->MoveTo (0,Image3->Height);
Image3->Canvas->LineTo(Image3->Width,0);
BitMap->Assign(Image3->Picture);

, . (Imagel) (Image2) :
. FillRect.
:
Rectangle. Image3 (. 6.12 ). , . , , . BitMap
Assign.

394

'

Hi OnDestroy
BitMap->Free() ;

.
12. :
if

(OpenPictureDialogl->Execute) (
Image3->Picture->LoadFromFile(
OpenPictureDialogl->FileName);
BitMap->Assign(lraage3->Picture);

Image3 ,
, Bit Map.
13. :
Image3->Picture->Assign(BitMap);

, BitMap.
14. OnClick SBBrush SBCoIor
if ( ( (TSpeedButton *)Sender)->Down)
BitMap->Assign(Image3->Picture) ;

BitMap
.
15. OnMouseDown Image3 Image4
:
if((Sender == Iraage4) II SBColor->Down)
//
(
if(Button -- rabLeft)
{
//
Imagel->Canvas->Brush->Color =
((TImage *)Sender)->Canvas->Pixels[X][Y];
Imagel->Canvas->FillRect(Rect(0,0,Imagel->Width,
Imagel->Height));
}
else
{
//
Image2->Canvas->Brush->Color =
((TImage *)Sender)->Canvas->Pixels[X][Y];
Image2->Canvas->FillRect(Rect(0,0,Image2->Width,
Image2->Height));
}
,

else if (SBBrush->Down)
//
{

if (Button==mbLeft)
Image3->Canvas->Brush->Color =
Imagel->Canvas->Brush->Color;
else Iraage3->Canvas->Brush->Color =
Image2->Canvas->Brush->Color;
Image3->Canvas->FloodFill(X, Y,
Iraage3->Canvas->Pixels[X][Y], fsSurface) ;
}

, , .
Image4 SBColor -

395

, . , .
Image3 SBBrush , .

FloodFill , , , .
. , , , , .
, . .
. ,
(. 6.12 ). , .
| ,
, .
| - ( . 6.12 ...\lmages\Splash\16Color\earth.bmp).
. , , - ( . 6.12 ) ..
, : . ,
. 6.1.5. , , ,
, , .

6.1.5
6.1.5.1
, .
Mode (). Mode
. 18. Mode = pmCopy. ,
, Color. , Color,
. pmNot . . "", , " 1 " .
, . , , 0110011, 1111000.
, pmNotXor

396

0110100. . , , .
pmNotXor 1111000
, 0110100. pmNotXor 0110011, .. .
, - , , . pmNotXor,
,
.
, , . .
6.1.5.2

Assign. . CopyRect, . :
void

fastcall

CopyRect(const Windows::TRect
TCanvas* Canvas,
const Windows::TRect

SDest,
SSource);

Dest , . Canvas , . : TImage,


TBitmap . , . Source , Dest.
, TRect.
. 6.1.3.4 Rect .
. ,
, . CopyMode ( ) ,
. . 17
15 .
CopyMode cmSrcCopy. ,
: Dest . cmWhiteness cmBlackness, : .
, Dest. cmSrdnvert, , XOR. ,
,
. cmSrcAnd. ,
, , .
cmSrcPaint , .

397

.
Imagel->Canvas->CopyMode = cmSrcCopy;
Imagel->Canvas->CopyRect(Rect(0,0,200,200),Image2->Canvas,
Rect(0,0,200,200));
Image2
Imagel. ,
Imagel (0, 0)
(200, 200), .

Imagel->Canvas->CopyMode = c m S r c I n v e r t ;
Imagel->Canvas->CopyRect(Rect(0,0,200,200),Image2->Canvas,
R e c t ( 0 , 0 , 2 0 0 , 200) ) ;
I m a g e l - > C a n v a s - > C o p y R e c t ( R e c t (0, 0 , 2 0 0 , 200) , ' l m a g e 2 - > C a n v a s ,
Rect(0,0,200,200) ) ;

Image2
Imagel cmSrcInvert. CopyRect Imagel
Image2 , CopyRect
Imagel .

Imagel->Canvas->CopyMode = cmWhiteness;
Imagel->Canvas->CopyRect(Rect(0,0,200,200),Image2->Canvas,
Rect (0,0,200,200) ) ;
Imagel, . Image2
.
, , , .
,
. ,
. .
, . , .
BrushCopy . , C++Builder,
.
CopyMode Draw. :
void
fastcall Draw(int X, int Y, TGraphic* Graphic);
Draw , , Graphic,
,
X Y. , . TBitmap, , CopyMode.
,
Imagel->Canvas->Draw(10,10,Bitmapl);
Imagel Bitmapl (10, 10).

398

DrawFocusRect.
, ,
XOR. DrawFocusRect :
void

fastcall

DrawFocusRect(const Windows::TRect

SRect);

Rect . XOR, Rect .

6.1.6

, .
(.
6.1.4) . , .
. 6.13. ,
. , - '
, , . , , .
. 6.13

, .
, . .
:
. ,
.
SBBrush. ,
, .
,
.

399

SBColor. , , , , .
SBPen. .
SBRect. . . Ctrl, , ,

.
Clipboard .
() SBErase. .
SBRectang.
.
SBFillRec.
.
SBLine. .
| .
| .
,
| .
Clipboard | | .

Clipboard | .
.
DrawFocusRect. OnMouseDown
Image3, :
//
= X;
Y0 = Y;
//
R.Top - X;
R. Bottom = X;
R.Left = Y;
R.Right = Y;
//
Image3->Canvas->DrawFocusRect(R);
RBegin = t r u e ;

X Y Y0,
R
TRect ( ) DrawFocusRect. RBegin.
OnMouseMove Image3, RBegin, :

400

6
//
Image3->Canvas->DrawFocusRect(R) ;
// , R
if (0 < X) ( R.Left - ; R.Right
e l s e { R.Left - X; R.Right = XO;
if (YO < Y} ( R.Top = 0; R.Bottom
e l s e ( R.Top = Y; R.Bottom = YO;

= X; }
}
= Y; )
}

//
Image3->Canvas->DrawFocusRect(R) ;
(,
DrawFocusRect XOR). R (, Y0) (X, Y). , , DrawFocusRect, R.Left
R.Right, a R.Top R.Bottom.
(, Y0) (X, Y) , .
.
, , . .
, :
//
Image3->Canvas->DrawFocusRect(R);
//
RDrag = t r u e ;
//
= X;
YO = Y;
//
R0 = R;

//
BitMap->Assign(lmage3->Picture);
//
Image3->Canvas->Brush->Color = Image2->Canvas->Brush->Color;
. RDrag. R0 TRect. Assign
Bitmap. ,

. , Image2.
OnMouseMove Image3, RDrag,
:
//
Iraage3->Canvas->C0pyRect(R,BitMap->Canvas,R);
// Ctrl - R0
if (! Shift.Contains(ssCtrl))

401

Image3->Canvas->FillRect(R0) ;
//
R.Left = R.Left + X
R.Right = R.Right +
R.Top = R.Top + Y R.Bottom = R.Bottom


- ;
X - ;
YO;
+ Y - YO;

//
= X;
YO = Y;
//
Image3->Canvas->CopyRect(R,BitMap->Canvas,RO);
//
Image3->Canvas->DrawFocugRect(R);
(.. ), CopyRect BitMap. , Ctrl,
( ) FillRect. .
, .
, .
.
OnMouseDown
OnMouseMove . ,
, .. OnMouseUp, .
:
Image3->Canvas->Brush->Color = Image2->Canvas->Brush->Color;
Image3->Canvas->Pen->Color = Imagel->Canvas->Brush->Color;
Image3->Canvas->Rectangle(R.Left,R.Top,R.Right,R.Bottom);
Rectangle.
:
Image3->Canvas->Brush->Color = Imagel->Canvas->Brush->Color;
Image3->Canvas->FrameRect. (R) ;
, ,
, FrameRect .
. OnMouseDown :
= X;
YO = Y;
XI = X;
Yl = Y;
Image3->Canvas->Pen->Mode = pmNotXor;
Image3->Canvas~>Pen->Color = Imagel->Canvas->Brush->Color;
: (X0.Y0)
(XI, Y1). . pmNotXor,
.

402

6
OnMouseMove :
//
Image3->Canvas->MoveTo(X0,Y0);
Image3->Canvas->LineTo(XI,Yl);
//
Image3->Canvas->MoveTo(X0,Y0);
Image3->Canvas->LineTo(X,Y);
//
XI - X;
Yl = Y;

MoveTo LineTo
, . .
, . , :
Image3->Canvas->LineTo(XO,Y0);
Image3->CanvaS->LineTo(X,Y);

, ( , X I , Y1).
. .
- : LineTo ,
, . , pmNotXor , , (X0.Y0) , , , . ,
, .
OnMouseUp , , :
//
Image3->Canvas->MoveTo(XO,Y0);
Image3->Canvas->LineTo(Xl,Yl);
// }
Image3->Canvas->Pen->Mode = pmCopy;
Image3->Canvas->MoveTo(XO,Y0);
image3->Canvas->LineTo(X,Y);

,
. , , OnMouseMove:
Image3->Canvas->Pixels[X][Y] = Imagel->Canvas->Brush->Color;

.
. , OnMouseMove
. , ,
. , , LineTo, OnMouseMove
Image3->Canvas->LineTo(X,Y);

403

, . 6.13,
. FillRect, . , . 6.1.4. SavePictureDialog
if

(SavePictureDialogl->Execute())

BitMap~>Assign(Image3->Plcture);
BitMap->SaveToFile(SavePictureDialogl->FileName);
}

Bitmap,
SaveToFile .

void
f a s t c a l l TForml::MCopyClick(TObject
(
//
Image3->Canvas->DrawFocusRect(R);

*Sender)

//
Graphics: :TBitmap *BMCopy = new Graphics:iTBitmap;
BMCopy->Width = R.Right - R.Left;
BMCopy->Height = R.Bottom - R.Top;
try
(
//
BMCopy->Canvas->CopyRect(Rect(0,0,->Width,
BMCopy->Height),Image3->Canvas,R);
//
Image3->Canvas->DrawFocusRect(R) ;
// Clipboard
Clipboard()->Assign();
if (Sender == MCut)
(
//
Image3->Canvas->Brush->Color = clWhite;
Image3->Canvas->FillRect(R) ;
}
}
finally
(
//
BMCopy->Free();


, R.
TBitmap, . Clipboard. '
finally
: .
Clipboard,
TClipboard, Windows.
, Clipboard:
voidf a s t c a l l TForml:iMPasteClick(TObject *Sender)
(
Graphics::TBitmap *BMCopy = new Graphics::TBitmap;

404


try
{
try
BMCopy->LoadFromClipboardFormat(CF_BITMAP,
Clipboard()->GetAsHandle(CF_BITMAP),0);
Image3->Canvas->CopyRect(Rect(0,0,BMCopy->Width,
BMCopy->Height), BMCopy->Canvas,
Rect(0,0,BMCopy->Width,
BMCopy->Height));
finally
BMCopy->Free();
catch (EInvalidGraphicS)
(
ShowMessage(" ");

Clipboard LoadFromClipboardFormat. ElnvalidGraphic, Clipboard


.

, . , , , , , .. ,
. . 6.1.2.4 4.7. . 6.14 , . Examples\Apps\
Doodle\extrares.res, C++Builder.
, .
: extrares.res
, .
. 6.14

405

,
(. . 4.7). :
//
const int c r F i l l = 1;
const int crPlus = 2;
const int crDraw = 3;
const int crErase = 4;

OnCreate :
//
S c r e e n - > C u r s o r s [ c r F i l l ] = LoadCursor(HInstance, "FILL");
Screen->Cursors[crPlus] = LoadCursor(HInstance, "PLUS");
Screen->Cursors[crDraw] = LoadCursor(HInstance, "DRAW");
Screen->Cursors[crErase] = LoadCursor(HInstance, "ERASE");

OnClick
, ImageS :
if((Sender == SBPen)||(Sender == SBLine))
Image3->Cursor = crDraw;
else if(Sender == SBBrush)
Image3->Cursor = crFill;
else if(Sender == SBErase)
Image3->Cursor = crErase;
else if(Sender == SBColor)
Image3->Cursor = crDefault;
else Image3->Cursor = crPlus;

6.1.7 OnPaint
Image.
Image. , , .
, TImage, . , PaintBox, . PaintBox
, .
PaintBox . , .
, OpenPictureDialog,
:
void
fastcall TForml::ButtonlClick(TObject *Sender)
(
if (OpenPictureDialogl->Execute()}
{
Graphics::TBitmap *Bitmap = new Graphics::TBitmap;
try
(
Bitmap->LoadFromFile(OpenPictureDialogl->FileName);
Canvas->Draw(0,0,Bitmap);
}
finally
(
Bitmap->Free () ;

406

(
Canvas>Draw , ,
Forml>Canvas>Draw). ,
- . 6.15 . ,
, C++Builder , , . ,
C++Builder, , , .
, , ,
C++Builder , , ,
. 6.15 .
. 6.15

()
()

, - , , , . Image , TImage
, . .
,
, -
.
, OnPaint. ( ) .
. Bitmap
, .. :
Graphics::TBitmap *Bitmap;


if (OpenPictureDialogl->Execute() )
{

Bitmap = new G r a p h i c s : : T B i t m a p ;
Bitmap->LoadFromFile(OpenPictureDialogl->FileName);
Canvas->Draw(0,0,Bitmap);
}

Bitmap>Free(), ,
OnDestroy.
Bitmap
OnPaint :
if

(Bitmap

! = NULL)

Canvas->Draw(0,0,Bitmap);

407

if , Bitmap,
Bitmap .
, , .
, ,
, . . ,
. ClipRect TRect, OnPaint , . :
if

(Bitmap !- NULL)
Canvas->CopyRect(Canvas->ClipRect,Bitmap->Canvas,Canvas->ClipRect) ;

ClipRect, .

6.2
6.2.1
6.2.1.1
, , .
,
.
.wav.
, . , ; .
- (MIDI). .midi
. ,
. , .
MIDI , .
MIDI ,
.bmp. ,
, , .
MIDI . . AVI
MPEG. , .
, ? , , . . .
,
30 .
, .

408

(
), .
-, ,
72 . .
,
. ,
: ,
, ,
?
. , , , ,
.
.
CD-ROM.
6.2.1.2 , MessageBeep
PlaySound
, ,
. , Windows,
( Windows ). ,
.
, , :
() ;

, Windows , .
Windows API MessageBeep:
bool MessageBeep(int uType);

uType [sounds] , , Windows. .


uType :

MB ICONASTERISK

SystemAsterisk

MB_ICONEXCLAMATION

SystemExclamation

MB ICONHAND

SystemHand

MB_ICONQUESTION

SystemQuestion

MB_OK

SystemDefault

MessageBeep . .
, , .
, .

409

.
.

:
MessageBeep(MB_OK);

Windows, . , . MessageBeep .
PlaySound, Windows,
. API Windows, mmsystem.
#include <mmsystem.cpp>, ++ilder .
PlaySound :
bool PlaySound(char * pszSound, HINST hmod, i n t fdwSound);

pszSound
. hmod , . ,
hmod 0.
fdwSound ,
. . 16, . 16.7.3.
, :
SND_ASYNC

PlaySound .
,
PlaySound pszSound, 0.

SND_LOOP

, PlaySound pszSound, 0. SND_ASYNC .

SND_NOSTOP

,
, , , PlaySound
false, .
, PlaySound
,
.

SND_NOWAIT

, .

SND_PURGE

,
. pszSound 0,
. pszSound 0,
, .

SND_SYNC

. PlaySound .

'

410

, pszSound, . PlaySound : , Windows, Windows, , PATH, , .


, PlaySound
. ,
, false.
PlaySound.

PlaySound(":\\Windows\\Media\\3ByK Microsoft.wav",0,SND_ASYNC);
Microsoft,
Windows. .
PlaySound,
OpenDialog :
if (Openbialogl->Execute ())
PlaySound(OpenDialogl->FileName.c_str(),0,SND_ASYNC);
, - , .
. PlaySound ,
. ,
PlaySoundC'SystemStart", O,SND_ASYNC) ;
Windows, ,
.

PlaySound("C: \\Windows\\Media\\3By"K Microsoft.wav", 0,


SND_ASYNC I SND_LOOP);
Microsoft,
, . ( ), - ,
PlaySound(0,0,

SND_PURGE);

OnCloseQuery, Windows . , OnCloseQuery


, , .

PlaySound("C:\\WindowsN\MediaN\3ByK Microsoft.wav",0,SND_SYNC);
. .. PlaySound ,
. .
, . , , ,
, .
,
PlaySound. SND_NOSTOP, :

411

PlaySound(":\\Windows\\Media\\3ByK M i c r o s o f t . w a v " , ,
SND_SYNC I SND_NOSTOP)

, ,
, PlaySound false.
, .. .
. C++Builder
MediaPlayer -
-. . 6.2.4.

6,2.2

. ,
, .
, , ,
- . . , , C++Builder . .
, . , - -
,
. , Windows .
. , - , :
, .
. Image,
Button Timer. . Image, (. 6.16).
. 6.16

'""""""""Hiinlff

. , Interval
, , 500 ( , 0,5 ). Enabled false. .
. .

void

f a s t c a l l Draw();

412

, . :
short
short
short
short
short
short
short
short
short

int
int
int
int
int
int
int
int
int

num = 0;
H=20;
Xpos = 2 * H;
Ypos = 120;
Hmen = 30;
Rhead = 10;
Rhead2 = Rhead
revers = 1;
L = H * 1.41;

//
//
//
//
//
2; //
//
//


""




void
fastcall TForml::Draw()
{
short int Yhead;
//
switch (num)
case 0:
Yhead = Ypos-H-Hmen;
Imagel->Canvas->MoveTo(Xpos-H,Ypos);
lmagel->Canvas->LineTo(Xpos,Ypos-H);
//
Imagel->Canvas->LineTo (Xpos+H,Ypos);
//
Imagel->Canvas->MoveTo(Xpos,Ypos-H);
Imagel->Canvas->LineTo(Xpos,Yhead);
//
Imagel->Canvas->MoveTo(Xpos+revers*H, Yhead-H) ;
Iraagel->Canvas->LineTo(Xpos,Yhead+4);
//
Imagel->Canvas->Ellipse (Xpos+revers*H-Rhead2,Yhead-H-Rhead2,
Xpos+revers*H+Rhead2,Yhead-H+Rhead2);
Imagel->Canvas->LineTo(Xpos+revers*H,Yhead+H); //
Imagel->Canvas->Ellipse (Xpos+revers*H-Rhead2,Yhead+H-Rhead2,
Xpos+revers*H+Rhead2,Yhead+H+Rhead2);
Imagel->Canvas->Ellipse(Xpos-Rhead,Yhead, Xpos+Rhead,
Yhead-2*Rhead);
Imagel->Canvas->Rectangle(Xpos-Rhead,Yhead-2*Rhead-l,
Xpos+Rhead,Yhead-2*Rhead-4);
//
break;
case 1:
Yhead
Ypos-L-Hmen;
Imagel >Canvas->MoveTo(Xpos,Ypos);
Imagel >Canvas->LineTo(Xpos,Yhead);
Imagel >Canvas->MoveTo(Xpos,Yhead+4);
Imagel >Canvas->LineTo (Xpos+revers*L,Yhead+4);
Imagel >Canvas->Ellipse(Xpos + revers*L-Rhead2, Yhead+4-Rhead2,
Xpos+revers*L+Rhead2,Yhead+4+Rhead2);
Imagel->Canvas->Ellipse(Xpos-Rhead,Yhead,Xpos+Rhead,
Yhead-2*Rhead);
Imagel->Canvas->Rectangle(Xpos-H / 2,Yhead-2*Rhead-l,
Xpos+H / 2,Yhead-2*Rhead-4);
//
void
fastcall TForml::TimerlTimer(TObject *Sender)
{
Draw () ;
if ((Xpos >= Imagel->Picture->Width-H)||(Xpos <= H))
revers = -revers;
Xpos = Xpos + revers * H;
num = 1 - num;
Draw ();


void
fastcall TForml::BRunClick(TObject *Sender)
(
Timerl->Enabled = ! Timerl->Enabled;
)
//
void
fastcall TForml::FormCreate(TObject *Sender)
{
Imagel->Canvas->MoveTo (0,Ypos + 3);
Imagel->Canvas->Pen->Width = 4;
Imagel->Canvas->LineTo(Imagel->ClientWidth,Ypos+3); //
Imagel->Canvas->Pen->Width = 1;
Imagel->Canvas->Pen->Mode = pmNotXor;
Draw();
)

FormCreate, OnCreate . , , . pmNotXor. Draw,


.
BRunClick OnClick . , .
TimerlTimer OnTimer .
, . Draw.
, ,
. , . Xpos.
- Imagel , ,
revers, .
revers = 1, ; revers = - 1 , . Xpos revers * , ..
. num,
: 0 1. Draw, .
, Draw,
. , .
num , Xpos revers.
.
. .
.
, .
. , .
. . - . , FormCreate
, :
Imagel->Canvas->Brush->Color = 0;
Imagel->Canvas->Rectangle(90,0,200,100);
Imagel->Canvas->Brush->Color = clWhite;

. , . 6.17. . -,

414

, .
. ,
OpenPictureDialog
FormCreate
if

(OpenPictureDialogl->Execute ())
Imagel->Picture->LoadFroraFile(openPictureDialogl->FileName) ;


- , , , . 6.1-6.3. ,
.
. 6.17

?
- , ,
. - , , , pmNotXor .
.
File | Save Project As. File | Save As. , .
TBitmap:
Graphics::TBitmap *BitMap;

- ' , , . FormCreate :
void

f a s t c a l l TForral::FormCreate(TObject *Sender)

BitMap = new Graphics::TBitmap;


BitMap->Width = 2 * (L + Rhead);
BitMap->Height - L + Hraen + 2 * Rhead + 6;
Imagel->Canves->MoveTo(0,Ypos+3);
Imagel->Canvas->Pen->Width =' 4;
Imagel->Canvas->LineTo(Imagel->ClientWidth,Ypos+3); //
Imagel->Canvas->Pen->Width = 2;
BitMap->Canvas->CopyReet(Rect(0,0,BitMap->Width,BitMap->Height),
Imagel->Canvas,Rect(Xpos-L-Rhead,Ypos-(L+Hmen+2*Rhead+5),
Xpos+L+Rhead,Ypos+1));
Draw();
}

BitMap
.
, Draw BitMap CopyRect , .

415

Draw . , ,
pmNotXor. .
Bitmap,
OnDestroy ,
BitMap->Free ( ) ;

TimerITimer :
void
f a s t c a l l TForml::TimerlTimer(TObject *Sender)
(
Imagel->Canvas->Draw(Xpos-L-Rhead,
Ypos-L-Hmen-2*Rhead-5,BitMap);
if ( (Xpos >= Imagel->Picture->Width - H) | (Xpos <= H))
revers = -ravers;
Xpos = Xpos + r e v e r s * H;
num = 1 - num;
BitMap->Canvas->CopyRect(Rect(0,0,BitMap->Width,
BitMap->Height),Imagel->Canvas,
Rect(Xpos-L-Rhead,
Ypos-(L+Hmen+2*Rhead+5) ,
Xpos4L+Rhead,Ypos+1)) ;
Draw() ;
}

, , ,
Draw, , Imagel>Canvas->Draw, ,
.
BitMap>Canvas>CopyRect, Draw .
. . , . , .
, , .
, ,
.
.

. . , , , . , , , Bitmap, . , , Draw CopyRect.
.
, , .
, , ,
. . 6.16 6.17, , .
, .
, .

.
, , . , ,
.

416

, .
. ,
. .
.
. , . .
#deflne Pi 3.1415926535897932385
short int cadr = 0;
//
short int H=30;
//
short int Xpos = 3 * H;
//
short int Ypos - 120;
// ""
short int Hmen = 30;
//
short int Rhead = 10;
//
short int revers = 1;
II
short int L = H * 1.41;
//
short int Ncadr= 16;
//
void
fastcall TForml::Draw()
(
float Angl = Pi/4*(l+(2.*cadr)/(Ncadr-l)) ;
short int Yb = Ypos-H*sin(Angl);
short int Yt = Yb-Hmen;
short int X = Xpos-revers*H*cos(Angl);
lmagel->Canvas->MoveTo(X-(Xpos-X),Ypos);
Imagel->Canvas->LineTo(X,Yb);
//
if (cadr != Ncadr / 2-1)
Imagel->Canvas->LineTo (Xpos,Ypos);
//
Imagel->Canvas->MoveTo(X,Yb);
Imagel->Canvas->LineTo(X,Yt);
//
short int XI = X - revers * (Yb-Ypos);
Imagel->Canvas->MoveTo(XI,Yt+5-(Xpos-X));
Imagel->Canvas->Ellipse(Xl-Rhead / 2,
Yt+5-(Xpos-X)-Rhead / 2, .
Xl+Rhead / 2,
Yt+5-(Xpos-X)+Rhead / 2 ) ;
Imagel->Canvas->LineTo(X, Yt + 5) ;
//
if (cadr != Ncadr / 2-1)
{
Imagel->Canvas->Ellipse(Xl-Rhead / 2,
Yt+5+(Xpos-X)-Rhead / 2,
Xl+Rhead / 2,
Yt+5+(Xpos-X)+Rhead / 2 ) ;
Imagel->Canvas->LineTo(XI,Yt+5+(Xpos-X));
//
)
Imagel->Canvas->Ellipse(X-Rhead,Yt-2*Rhead,X+Rhead,Yt);
Iraagel->Canvas->Rectangle(X-Rhead,Yt-2*Rhead-4,
X+Rhead,Yt-2*Rhead-l);
//
}
/ /

_^

void
fastcall TForml::BRunClick(TObject Sender)
(
Timerl->Enabled = ! Timerl->Enabled;
}
//
:____
__
__
-_
void
f a s t c a l l TForml::TimerlTimer(TObject *Sender)
(
Draw();

417

cadr = (cadr+1) % Ncadr;


if (cadr == 0)
if ((Xpos < Imagel->Picture->Width-revers*3*H) &&
(Xpos>-revers*3*H))
Xpos 4= revers*H*l.41;
else revers - -revers;
Draw();
)

//
void
fastcall TForml::FormCreate(TObject *Sender)
(
Imagel->Canvas->MoveTo(0, Ypos+3) ;
Imagel->Canvas->Pen->Width = 4;
Imagel->Canvas->LineTo(Imagel->ClientWidth,Ypos+3); //
Imagel->Canvas->Pen->width - 1;
Imagel->Canvas->Pen->Mode = pmNotXor;
Timerl->lnterval = 600 / Ncadr;
Draw();
)

sin cos.

include <math.h>

*.
FormCreate , ,
, ( Interval) 600 Ncadr, . , 600 . , , , Ncadr, 16.
BRunClick , .
TimerlTimer, Draw, , - . Draw
cadr
cadr = (cadr+1) % Ncadr;

' , cadr + 1
Ncadr, cadr 0, 1, 2, ..., Ncadr - 1,
0, 1, ... . cadr = 0. , , (
revers).
Draw. Angl, :
f l o a t Angl = P i / 4 * ( l + ( 2 . * c a d r ) / ( N c a d r - 1 ) ) ;

, 2 2. * cadr . ,

(2. * cadr)/(Ncadr 1) . 2, - 2 * cadr , Ncadr 1,
0 .
, ,
. ,
, cadr !=
Ncadr /2 1. , , Ncadr ,
14 C++Builder

418

. pmNotXor,
, . ,
, .
. . ,
.

6.2.3
Animate
C++Builder Windows .avi . Animate,
Win32 .
Animate
Windows ( , ..)
.avi Audio Video Interleaved. . ,
Animate AVI.
' AVI AVI, RLE run-length encoding.
TAnimate AVI ,
Shell32.dll, Windows 95 NT.
, Animate .
: FileName
CommonAVI. , ,
.
CommonAVI
Windows. TCommonAVI, :
enum TCommonAVI (aviNone, aviFindFolder, aviFindFile,
aviFindComputer, aviCopyFiles, aviCopyFile,
aviRecycleFile, aviEmptyRecycle,
aviDeleteFile );

TCommonAVI Windows , , ..
, .
CommonAVI, , aviCopyFile.
.
. Repetitions
Animate .
0 ( ),
, Stop. OnStop, , ,
.
Repetitions , . , , 3.
Active Animate true. (. 6.18), . 3 .

419


. 6.18

.

Next Frame ( ) Previous Frame ( ).
,
. ,
StartFrame , StopFrame .
Play,
:
void

fastcall Play(Word FromFrame, Word ToFrame,

int Count);

FromFrame ToFrame Count .


FromFrame = 1, . ToFrame FromFrame ,
FrameCount ( ),
. Count = 0, ,
Stop.
Play StartFrame FromFrame, StopFrame ToFrame, Repetitions Count
Active true.
Animate OnClose, OnOpen, OnStart
OnStop, , .
,
Animate. , ,
Visible Animate false. , , : , ..
, ,
. Repetitions 0, . Active false.
AutoSize false, Center true,
.
3 (. 6.19). (
BWind)
Windows. ( BStop) . ( BFile) , , .avi. ,
OpenDialog ( Filter)
*.avi|*.avi.

420

. 6.19
Animate:
Windows (a)
.avi ()

... ]

! Wirdows

Winobws

;|

S,op


. :
int i;
//
^
void
fastcall TForml::BWindClick(TObject *Sender)
(
Aninnatel->Visible = true;
i - 1;
Animatel->CominonAVI = aviFindFolder;
Animatel->Active true;
)
//
void
fastcall TForml::BStopClick(TObject *Sender)
f
Animatel->Stop ;
void

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

switch (i)
(
case 2: Animatel->CommonAVI - aviFindFile;
break;
case 3: Animatel->CommonAVI = aviFindComputer;
break;
case 4: Animatel->ComraonAVI = aviCopyFiles;
break;
case 5: Animatel->CommonAVI - aviCopyFile;
break;
case 6: Animatel->CommonAVI = aviRecycleFile;
break;
case 7: Animatel->CommonAVI = aviEmptyRecycle;
break;
case 8: Animatel->CommonAVI = aviDeleteFile;
)
if (i < 9) Animatel->Active = true;
else Animatel->Visible = false;
//
void
fastcall TForml::BFileClick(TObject *Sender)
{
if (OpenDialogl->Execute())
{
i = 9;

421

Animatel->FileName = OpenDialogl->FileName;
Animat'el->Visible - true;
Animatel->Active = true;

OnClick BWind CommonAVI, 1, Animatel


.
OnClick BStop
Stop.
OnStop Animatel 1,

Windows, . ,
.
OnClick BFile ,
.
. ...\Examples\Mfc\Generol\Cmnctrls\dillo.avi,
C++Builder ( ., 6.19 ), .

6.2.4 MediaPlayer
C++Builder MediaPlayer - - . - System
.
(Media Control Interface MCI) 32- Windows.
. -, ,
. -, .
- . 6.20.
, .
. 6.20
MediaPlayer

'- ft

( ):

Play

Pause

. - , .

Stop

Next

Prev

Step

Back

422


Record

Eject

, .

- , : Play, Pause, Stop, Next, Previous, Step, Back,


StartRecording, Eject.
, -,
DeviceType. , FileName. DeviceType dtAutoSelect. , - FileName.
MediaPlayer AutoOpen. true,
- , DeviceType, .
,
(, . 6.21 ).
, Display ,
. , ,
. DisplayRect TRect (
) , . DisplayRect Rect.
. , ,
. ,
. ,
MediaPlayerl->DsplayRect - Rect(10,10,200,200);

(10, 10),
, 200.
MediaPlayer OnClick OnNotify.
-
enura TMPBtnType (btPlay, btPause, btstop, btNext,
btPrev, btstep, btBack, btRecord,
void

btEject);

f a s t c a l l Click(TObject *Sender, TMPBtnType Button,


bool SDoDefault)

Button . DoDefault, , ( true )


, .
OnNotify ,
- Notify true. - Wait. Wait
false,
, . , Notify
true Wait false, .
Notify Wait .
OnClick
OnNotify.
Mode, ..

423

, .
, ,
MediaPlayer. .
. MediaPlayer, MainMenu OpenDialog. OpenDialog , , :
(*.wav,*.mid,*.avi)

*.wav; *.mid; *.avi

(*.wav,*.mid)

*.wav;*.mid

(*.avi)

*.avi


: .
OnClick
if (OpenDialogl->Execute())
MediaPIayerl->FileName
MediaPlayerl->Open() ;

OpenDialogl->FileName;

, . , MediaPlayer DeviceType dtAutoSelect. .


)

. 6.21
:
()
()

: .. Window. XP.wav
:
;

"< - i

-taixt
4>aun:F:VTasVMulliMediaMNTR0.AVI
:
:

424

MediaPlayer FileName,
.
AutoOpen true. , , , .
.
(, , ,
).
- - MediaPlayer, . (. 6.21).
(Labell) :. (Label2) , (Label3)
. (Label4)
Labell , .
, (. . 6.21),
.
, ,
.
#include " f i l e c t r l . h p p "
Ansi$tring ModeStr[7] =
{"He "/ "","",
"","","",""};
A n s i s t r i n g ButtonStr[9] =
{"","","",
"","","","",
"",""};
/ /

_.

void
fastcall TForml::FormCreate(TObject *Sender)
(
Label4->Caption = MinimizeName(MediaPlayerl->FileName,
Label4->Canvas,200);
Label2->Caption = ": " + ModeStr[MediaPlayerl->Mode];
MediaPlayerl->Notif = true;
(
//_
void
fastcall TForml::OpenClick(TObject *Sender)

if

(OpenDialogl->Execute0)

MediaPlayerl->FileName = OpenDialogl->FileName;
Label4->Caption = MinimizeName(MediaPlayerl->FileName/
Label4->Canvas,200);
MediaPlayerl->Open();
MediaPlayerl->Notify = t r u e ;
}
}
/

void
fastcall TForml::MediaPlayerlNotif(TObject *Sender)
{
Label2->Caption = ": "+ModeStr[MediaPlayerl->Mode];
// Notify,
//
MediaPlayerl->Notify = true;
(
//
void
fastcall TForml::MediaPlayerlClick(TObject 'Sender,
TMPBtnType Button, bool SDoDefault)
{
Label3->Caption = ": " + ButtonStr[Button];
// Notify, OnNotify
MediaPlayerl->Notify = true;

425

FileName MediaPlayerl , MediaPlayerl, .. . . FormCreate OriCreate , LabeI4 Label2 . MinimizeName, (. . 6.21) ,


( 200 ). ,

include

"filectrl.hpp"


, (OpenClick), - (MediaPlayerlClick), (MediaPlayerlNotify).
MediaPlayerl->Notif = true/

OnNotify .
(. 6.21).
, , .. .

, ,

7.1
, , ,
. , . ,
, . , , . ,
.
.
, , .
-, . .
. 7.2.
() .
, . : OLE, DDE, COM, Windows. . 7.4, 7.5, 7.7, 7.8.
(tread). , . , . .
(
), , .
Word, , , .
( ),
.
. 7.6.
. 1.4.

: . 7.8 CORBA . 7.10.

7.2
, ..
, . ,
C+4-Builder -

428

- MS-DOS Windows
, .

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

7.2.1 execlp
execlp
, .
. ,
.
execlp process.h (
#include) :
int execlp(char

*path,

char *argO,*argl,

...,

*argn,

NULL)

path , . path ,
. ,
, . ,
. . , .com . path ,
. ,
, PATH.
argO argn ,
.
argO. path. , . , , .
, , , , argl. execlp NULL .
execlp 0 ,
- 1 .
execlp.
i f ( e x e c l p ( " F l . e x e " , " F l . e x e " , NULL))
ShowMessage(" F l . e x e ");


Fl.exe. , PATH.
execlp -1 ShowMessage.
, , Fl.exe .

e x e c l p ( " n c " , " " , NULL);

, ,

429

Norton Commander ( .),


PATH.

char * prog = "command.com";


e x e c l p ( p r o g , p r o g , NULL);

DOS, command.com PATH.

execlp("Winword","Winword", " F l . d o c " , "F2.doc", NULL))

Word Fl.doc F2.doc.


execlp , 8 . . 16,
. 16.6.2, [1] [3].
execlp, ,
, .
,

. : ,
execlp .
. . , .
, execlp:
- ,
,

7.2.2 spawnlp
spawnlp execlp,
.
process.h stdio.h. :
int

s p a w n l p ( i n t mode,

char *path,

char *argO,

argl,

...,

argn,

NULL)

spawnlp execlp mode,


, . , , ( . . 16,
. 16.6.2):
P_WAIT

, .

P_NOWAIT

.
16- Windows DOS.

P_DETACH

P_NOWAIT,
,
.
.
, execlp.

PJJVERLAY

430

7
.
if(spawnlp(P_WAIT,"arj","arj","e doc.arj a l . t x t " ,
11
ShowMessage(" arj );
else
{
Memol->Clear();
Memol->Lines->LoadFromFile("al.txt");
DeleteFile("al.txt");
)

NULL))

arj, doc.arj al.txt. , arj , Memol .


, , . , :
if(spawnlp(P_WAIT,"arj","arj","e","doc.arj","al.txt",

NULL))

, ,
execlp, . spawnlp ,
P_WAIT, , .
,
. , arj,
DOS. DOS,
DOS, , . , , .
, , arj.bat :
@echo off
a r j . e x e e doc %1
exit

exit DOS.
, :
if(spawnlp(P_WAIT,"arj.bat","arj.bat","al.txt",

NULL))

arj.bat , .

,
DOS. , .
spawnlp. ,
.
. .
POverlay. , , , OMenage. . ,
.
:

, ,

431

include <vcl.h>
pragma h d r s t o p
include < p r o c e s s . h >
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, i n t )
(
spawnlp(P_WAIT,lpCmdLine,lpCmdLine,
NULL);
spawnlp(P_OVERLAY,"POverlay.exe","POverlay.exe",
NULL);
return 0;
)

spawnlp
, lpCmdLine.
spawnlp
POverlay.exe.
, POverlay
Editl.
:
if(spawnlp(P_OVERLA.,"OMenage.exe","OMenage.exe",Editl->Text,
ShowMessage(" " + E d i t l - > T e x t + " ;"+
" OMenage.exe");

NULL))

POverlay ( 10 ) OMenage.exe,
. OMenage.exe ,
POverlay. , POverlay, OMenage.exe.
: POverlay Editl . .
POverlay :
include <vcl.h>
pragma hdrstop
USERESC POverlay. res") ;
USEFORM("UOverlayl.cpp", Forml);
include "UOverlayl.h" //
/

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)


{
try
f
Application->Initialize();
Application->CreateForm( classid (TForml) , .SForml) ;
Forml->Editl->Text - lpCmdLine; // Editl
Application->Run();
}

catch

(Exception -exception)

Application->ShowException(^exception) ;
)

'

'

return 0;

, C++Builder, ( ): ,
UOverlayl.h, Forml, , Editl , .

WinMain lpCmdLine .

432

POverlay ,
OMenage :
spawnlp(P_OVERLAY,"POVERLAY.exe","POVERLAY.exe",lpCmdLine,

NULL);

, , , OMenage. POverlay , Editl.


spawnlp , 8 . . 16, . 16.6.2.
,
, , .

7.2.3 WinExec
WinExec, , .
Windows : Windows, MS-DOS, PIF .. WinExec :
int WinExec.(const char *CmdLine, unsigned int CmdShow);
CmdLine , , , . , Windows :
1.
2.
3.
4.
5.

, .
.
Windows, GetSystemDirectory.
Windows, GetWindowsDirectory.
PATH.

CmdShow Windows. . . 16, .


16.6.3.2. SW_RESTORE, .
, .
Windows, PIF .. .
WinExec , 31. :

ERROR_BAD_FORMAT

11

. (,
Win32 .).

ERROR_FILE_NOT_FOUND

ERROR_PATH_NOT_FOUND 3

, ,

433

WinExec Windows. Win32, Win32


CreateProcess, . 7.2.4.
WinExec.

WinExec("file.exe",SW_RESTORE);

file.exe.
WinExec("nc",SW_RESTORE);

Norton Commander.
WinExec("COMMAND.COM",SW_RESTORE) ;

MS-DOS.

i n t i - WinExec(Editl->Text.c_str(),SW_RESTORE);
i f ( i < 32)
ShowMessage(" "+ I n t T o S t r ( i ) ) ;
,
Editl.
(char *), AnsiString, .c_str().
, .
OpenDialog,

*.exe;*.com;*.pif;*.dat
*_*

Button ( ), .
OnClick :
if (OpenDialogl->Execute())
(
i n t i = WinExec(OpenDialogl->FileName.c_str(),SW_RESTORE);
switch (i)
(
case 0:ShowMessage("He ");
break;
case ERROR_BAD_FORMAT:
ShowMessage(" " +
OpenDialogl->FileNarae);
break;
case ERROR_PATH_NOT_FOUND:
ShowMessage("He " +
ExtractFilePath(OpenDialogl->FileName));
break;
case ERROR_FILE_NOT_FOUND:
ShowMessage("He " +
OpenDialogl->FileName);

Windows MS-DOS.

434

7.2.4 CreateProcess
, WinExec, API Windows CreateProcess, 32- . C++Builder . :
bool

f a s t c a l l CreateProcess(
const char * IpApplicationName,
char * lpCommandLine,
_SECURITY_ATTRIBUTES * lpProcessAttributes,
_SECURITY_ATTRIBUTES * lpThreadAttributes,
bool blnheritHandles,
unsigned long dwCreationFlags,
void * lpEnvironment,
const char * lpCurrentfiirectory,
STARTUPINFO * lpStartupInfo,
PROCESS_INFORMATION * lpProcessInforraation

(). IpApplicationName
lpCommandLine. , IpApplicationName
NULL,
, lpCommandLine. : 32- Windows,
MS-DOS, OS/2 .. Windows -
MS-DOS, IpApplicationName NULL,
lpCommandLine. , ,
, IpApplicationName = NULL
lpCommandLine.
,
.. ,
. . ,
, WinExec.

.
. ,
C++Builder [3].
lpProcessAttributes, lpThreadAttributes, lpEnvironment, blnheritHandles
. ,
NULL, false. lpCurrentDirectory , . -, .
NULL, .
dwCreationFlags , . (, CREATE_NEW_CONSOLE ), :
HIGH_PRIORITY_CL AS S

, .

IDLE_PRIORITY_CL AS S


. .
.

, ,
NORMAL PRIORITY CLASS

435

REALTIME PRIORITY CLASS , ,


.
lpStartupInfo TStartupInfo, . cb .
, .
lpProcessInformation TProcessInformation,

. :
hProcess

.
, .

hThread

() . , .

dwProcessId

. .

dwThreadld

. .

CreateProcess ,
(true). 0 (false). , GetLastError.
CreateProcess ,
.
, , WaitPorlnputldle.
:
DWORD

fastoall

W a i t F o r l n p u t l d l e ( I N HANDLE h P r o c e s s ,
IN DWORD d w M i l l i s e c o n d s ) ;

hProcess , ,
hProcess lpProcessInformation. dwMilliseconds .
, , .
:
0

WAITJTIMEOUT

OxFFFFFFFF

.
GetLastError.

. , ,
- , .
WaitForSingleObject:

436

7
DWORD

fastcall

HaitForSingleObject(IN HANDLE hHandle,


IN DWORD dwMilliseconds);

hHandle , ,
hProcess lpProcessInformation. dwMilliseconds .
,
,
WAIT OBJECT .
WAIT TIMEOUT ,
, .. .
,
() CloseHandle.
, .
ExitProcess.
CreateProcess
, :
STARTUPINFO S t a r t l n f o = ( s i z e o f ( T S t a r t u p I n f ) );
PROCESS__INFORMATION P r o c l n f o ;
LPCTSTR s;
Startlnfo.cb = sizeof(Startlnfo);
S t a r t l n f o . d w F l a g s = STARTF_USESHOWWINDOW;
Startlnfo.wShowWindow = SW_SHOWNORMAL;
i f ( ! CreateProcess(NULL, " a r j a a l l * . * " ,
NULL, NULL, f a l s e ,
CREATE_NEW_CONSOLE I
HIGH_PRIORITY__CLASS,
NULL, NULL, i S t a r t l n f o , i P r o d n f o ) )
ShowMessage(" " + I n t T o S t r ( G e t L a s t E r r o r ( ) ) ) ;
else
(
if (WaitForSingleObject(Proclnfo.hProcess, 10000) == ,WAIT_TIMEOUT)
ShowMessage("3a 10 . ");
CloseHandle(Proclnfo.hProcess);

7.2.5
ShellExecute
ShellExecute ,
.
. , , .doc,
Word. , , file.doc Word file.doc. ShellExecute ' .
,
.
ShellExecute

include "ShellAPI.h"

, ,

437

ShellAPI, .
C++Builder .
ShellExecute API Windows
:
void ShellExecute(HWnd Wnd, const char * Operation,
const char *FileName, const char *Parameters,
const char *Directory, unsigned int ShowCmd);

Wnd , . Handle.
Operation , . open
() print (). 32- Windows
: explore () Windows
. Operation NULL, open.
FileName , .
Parameters , , FileName
. FileName , , NULL.
Directory , .
ShowCmd . , . 16,
. 16.6.3.2. , WinExec,
SW_RESTORE,
. ,
. Windows, PIF .. .
ShellExecute. file.doc, .. Word (
.doc), . :
ShellExecute(Handle,NULL,"file.doc",NULL,NULL,SW_RESTORE) ;

, , , Operation:
ShellExecute(Handle,"print","file.doc",NULL,NULL,SW_RESTORE);

.
Word, .doc, file.doc, Word
, file.doc Word.
Windows :
S h e l l E x e c u t e ( H a n d l e , " o p e n " , " C a l c " , N U L L , N U L L , SW_RESTORE) ;

c:\Program Files\Borland:
ShellExecute(Handle,"open","c:\\Program Files\\Borland",
NULL,NULL,SW_RESTORE);


ShellExecute (Handle, " e x p l o r e " , " c : \\Program F i l e s W B o r l a n d " ,
NULL,NULL,SW_RESTORE) ;

c:\Program Files\Borland.

438

ShellExecute .
, , GetLastError:
DWORD GetLastError(VOID)
, ShellExecute .
.
, , SetLastError:
VOID SetLastError(DWORD dwErrCode)
dwErrCode .
.
ShellExecute ,
, . , - ,
, - .
FindExecutable, , . , , SkellAPI.
FindExecutable :
void FindExecutable (const char *FileName,
const char *Directory, char *Buffer);
., ,
FileName. Directory
.
. Buffer
, , FileName.
FindExecutable ,
32. , .
, .
FindExecutable.
char APchar[254];
FindExecutable("Doc.doc",NULL,APchar);
, APchar ,
Doc.doc, :
C:\\PROGRAM FILESWMICROSOFT OFFICE\\OFFICE\\WINWORD.EXE
, Doc.doc .
FindExecutable GetLastError.
32, . , , :
i n t i = GetLastError();
if (i <= 32)
ShowMessage(" , "+IntToStr ( i ) ) ;

, ,

439

7.3
7.3.1
7.2 . . API Windows , . . .
FindWindow, :
HWND FindWindow (const char *lpClassName,
const char *lpWindowName);

lpClassName ,
. lpWindowName , ( Caption ,
). NULL, , .
, , . NULL.
, .
, , , . , ,
HWND = FindWindow("TForml"," 2") ;

, TForm.1, Caption 2.
, , ,
, , . , , Windows , - .
, , ,
, ..?
- C++Builder WinSight 32 ( ...\Program Files\Borland\CBuilder6\Bin\ws32.exe). ,
WinSight 32, Spy | Find Window
, Windows. ,
,
.
, ,
"{ }"
. , ,
WinSight 32 ,
SciCalc. ,
:
HWND = F i n d W i n d o w ( " S c i C a l c " , " " ) ;

GetNextWindow API Windows. :


HWND GetNextwindow(hWnd hWnd, u n s i g n e d i n t wCmd);

Z-. hWnd , . wCmd . wCmd = GW_HWNDNEXT,

440

, . wCmd = GW_HWNDPREV,
, .
Z- , .
, .
, .
( wCmd), 0.
GetNextWindow
. API
Windows GetWindowText. , , . :
i n t GetWindowText(HWND hWnd,

char * l p S t r i n g ,

i n t nMaxCount);

hWnd . IpString ,
. nMaxCount . ,
.
,
, . , .
, : .
:
HWND H =Handle;
char Pch[128];
do
(
H = GetNextWindow (H, GW_HWNDNEXT) ;
GetWindowText(H,Poh, 128) ;
if(CompareText(Pch, "") )
break;
) while (H != NULL);
if (H != NULL)


Handle . , Z-, . CompareText, , Pch, .
, CompareText . , C++ , if
:
if( ! CompareText(Pch, ""))

, . ,
, .
NULL, . - ,
, .

, ,

441

7.3.2 API Windows

API Windows, .
Close Window
. :
bool CloseWindow(HWND hWnd)

hWnd .
. . , , ,
CloseWindow (FindWindow("SciCalc","") ) ;

FindWindow.
CloseWindow , .
DestroyWindow, .
Enable Window .
:
b o o l EnableWindow(HWND hWnd, b o o l b E n a b l e ) ;

hWnd , . : true , false .


, , ,
.
EnableWindow .
, , / - ,
, .
API Windows .
, , ..
...\program
files\Common Files\Borland Shared\MShelp\95guide.hlp ...\program files\Common Files\
Borland Shared\MShelp\mapi.h!p.

7.4 Windows
7.4.1 C++Builder
API Windows, . Windows. , ,
Windows.
Windows , , (messages). : , ,
Windows, , , , , , .

442

, , C++Builder , . Windows. ,
C++Builder ,
.
Windows TMessage,
. Msg , . Messages.kpp C++Builder ,
, - .
wParam (word parameter word) lParam (long parameter long)
Result. , C++Builder
int.
Word: WParamLo, WParamHi, LParamLo, LParamHi, ResultLo, ResultHi.
Hi
, Lo .
API Windows C++Builder . , ,
XPos YPos,
lParamLo lParamHi.
Windows . . WM_CLOSE, , .
. , . , .


.
, WM_ACTIVATE.
, . , ,
.
:
WM_ACTIVATE
f A c t i v e = LOWORD(wParam);
fMinimized = (BOOL) HIWORD(wParam);
hwndPrevious = (HWND) l P a r a m ;

.
fActive , .
:
WA_ACTIVE

(, SetActiveWindow ).

WA_CLICKACTIVE

WA_INACTIVE

fMinimized , , . .
hwndPrevious , , , , ,
, .

, ,

443

, , .
, .

7.4.2
API Windows , .
7.4.2.1 SendMessage, PostMessage Perform
SendMessage , . PostMessage, .
SendMessage:
I n t SendMessage(HWnd hwnd, unsigned i n t Msg,
WPARAM wParam, LPARAM lParam);
hWnd , .
HWND_BROADCAST,
, , .
Msg . wParam
lParam . ,
, .
PostMessage :
bool PostMessage(HWND hWnd, unsigned i n t Msg,
WPARAM wParam, LPARAM IParara) ;'
SendMessage, . , PostMessage
, .
hWnd Msg SendMessage. hWnd = NULL, (
) .
PostMessage .
GetLastError,
, . Perform, :
Perform(unsigned i n t Msg, WPARAM wParam, LPARAM lParam);
, ,
, C++Builder.
7.4.2.3
, . , Forml Form2,
, UlMessl U2Messl , PMessl. Forml
Form2.
include "U2Messl.h"
Visible Form2 false.
Forml , Show Form2
Close Form2.
Form2->Show();

444

7
SendMessage(Form2->Handle,WM_CLOSE,0,0);

WM_CLOSE (
SendMessage) Form2. SendMessage
, Handle. WM_CLOSE ; wParam IParam .
:
Forra2->Perforra(WM_CLOSE,0,0);

.
. ,
Show Form2 ' Form2,
Close Form2 . Forml .
, ,
Form2 Windows,
Hide. . ,
Caption Pmess2 (
) PMess2, UlMess2. , , , (. . 2.3.3). .
.
Forml
PMessl. PMessl Forml ,
Exec Pmess2 Close Pmess2.

WinExec("Pmess2.exe",SW_RESTORE);

, , PMess2 . . Close
Pmess2
SendMessage(FindWindow("TForml"," Pmess2"),
WM_CLOSE,0,0);

FindWindow
, , SendMessage WM_CLOSE.
. , Exec Pmess2,
PMess2, . Close Pmess2
PMess2.
.
(TForml) ,
. FindWindow, , . ,
- ? ,
Windows , ,
, ,
WM_CLOSE (, , ).
. . 7.3.1.
(, SdCalc
) WinSight 32
, :

, ,

445

SendMessage(FindWindow("SciCalc",""),WM_CLOSE,0,0);

, 7.3.1,
.

7.4.3
Windows . . ,
, .
Windows :
1. () , .
2. .
3. .
, :
BEGI N_ME S SAGE_MAP
MESSAGE_HANDLER(parameterl, pararaeter2, pararaeter3")
END_MESSAGE_MAP

BEGIN_MESSAGE_MAP ,
END_MESSAGE_MAP ,
MESSAGE_HANDLER .
MESSAGE_HANDLER ,
, -.
Windows . , WM_CLOSE. , . , TWMCIose.
,
,
Result, . - , WM_ On.
, OnCIose.
PMcss2
Form2 PMessl WM_CLOSE, Forml. Forml
PMess2 Form2 PMessl Label 1,
, , . (
Form2; Forml Form2 Forml):
//' U2Messl.h
c l a s s TForm2 ; public TForm
(
published:
// IDE-managed Components
TLabel *Labell;
private:
// User declarations
void
fastcall OnCIose(TWMCloseS Message);
public:
// User declarations

446

7
fastcall TForra2(TComponent* Owner);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_CLOSE, TWMClose, OnClOse)
END_MESSAGE_MAP(TComponent)
);
//
// U2Messl.cpp
void __fastcall TForm2::OnClose(TWMCloseS a)
<
Label2->Caption = "! !";
if (MessageDlgPos (" . ?11,
mtConf irraation, TMsgDlgBu'ttons () rabYes<< rabNo << mbCancel,
0,BoundsRect.Left,BoundsRect.Bottom) =- mrYes)
Close () ;
else Label2->Caption = "He !";
a.Result = 0;
)

U2Messl.h public ,
WM_CLOSE. OnCIose TWMClose.
private . , message .
OnCIose WM_CLOSE ,
, . MessageDlgPos,
, . Close. a.Result = ,
WM_CLOSE.
PMessl.
, Show Form2 Form2 Exec Pmessx PMess2, , Form2
PMess2 , ,
: Close Form2 Close Pmess2, . .
.
, .
Close Pmess2 , , ,
, Forml
Close Pmess2. . , , Close
Pmess2. , , .
, WM_CLOSE .
, , . (. 7.4.1) WM_ACTIVATE.
. , , fActive. WA_INACTIVE , . , .
(Forml Form2 PMessl,
Forml PMess2) WM_ACTIVATE. , , -

447

, ,

Label2, .
( Form2):
// U2Messl,h
class TForm2 : public TForm

published:
// IDE-managed Components
TLabel *Labell;
TLabel *Label2;
private: // User declarations
void
f a s t c a l l OnClose(TWMCloseS Message);
void
f a s t c a l l OnActivate(TWMActivateS Message);
public:
/ / User declarations
f a s t c a l l TForm2(TComponent* Owner);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_CLOSE, TWMClose, OnClose)
MESSAGE_HANDLER(WM_ACTIVATE, TWMActivate, OnActivate)
END_MESSAGE__MAP (TComponent)
J;
/ /

__

_ _ _

// U2Messl. cpp
void
fastcall TForm2::OnActivate(TWMActivates a)
f
if (a.Active == WA_INACTIVE)
Label2->Caption = " !";
else Label2->Caption = "! !";
a.Result = 0;

OnActivate , .
Active , .
.
PMessl.
(. 7.1),
, .
. 7.1
,

He !

! !

? jaxpaiTb. 7

, , , .
C++Builder 5, , ClassExplorer
(. 2.7.2). , , OnActivate. ,
View | ClassExplorer. ClassExplorer
New Method . , . 7.2.

448

. 7.2

MethadNa-ne JGrActvale
Add Class j

i;ijmenls jTWMAclivpleS a
. Mftfhod type

. . .
f un2bon Coiusruccf f He&iuctai
Funoicn3esulC jid
Visibility
FVfc
Directives
absdaci
1

* "'""

'"" ~" * *
'.

i
]r] j

" lnolenrenta:jor.details
~
~ '"
CalW-enled
Inline
' ti ;
Fie: F.\Tessl\MESSAGES\U1MESS1 CPP
|

3 I

Published
"*

C3r,sl Q|

Rsse. ffl j

- "~

iUal|a
^!!?
!7 Message Hands piTACTivAT=

"
! Pte

QK j Cancel |

Ji

Appa
j !

, Message Hondler.
WM_ACTIVATE. Method
Nome OnActivate.
Add to Closs , ,
. Arguments ,
TWMActivate& . , Function. Function Result,

void. Visibility : public, private, protected
published. Directives . .
, . 7.2 ,
Apply .
, ,
. :
void
f a s t c a l l TForml::OnActivate(TWMActivateS a)
(
//TODO: Add your source code here
)

-Do
List (. . 2.3.4).
To-Do List,
.

7.4.4
, API Windows.
, .

WM_USER, - .

, ,

449

,
#define WM^MyMessl WM_USER
#define WM_MyMess2 WM_USER + 1
WM_MyMessl WM_MyMess2 Windows. , :
MES5AGE_HANDLER(WM_MyMessl,- TMessage, OnMyMessl)
TMessage.
:
struct TMessage
I
unsigned i n t Msg;
long WParam;
long LParam;
long Result;
);
.
WParam
Lparam .
PMessl
Forml CSpinEdit , . PMess2, ,
CSpinEdit.
, UlMessl.h
, , WM_MyPost:
#define WM_MyPost WMJJSER

SendMessage(FindWindow("TForral"," Pmess2"),
WM_MyPost,O,CSpinEditl->Value);
! . :
, SendMessage WM_MyPost
WM_USER. , .
PMess2.
, :
// UlMess2. h
define WM_MyPost WM_USER
//
class TForral : public TForm

private: // User declarations


void
f a s t c a l l OnMyPost(TMessages Message);
public:
// User declarations
f a s t c a l l TForral(TComponent* Owner);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_MyPost, TMessage, OnMyPost)
END_MESSAGE_MAP(TComponent)

// UlMess2. cpp
void

fastcall TForml::OnMyPost(TMessageS a)

15 C++Builder 6

Label2->Caption " " + IntToStr(a.LParam) ;


)

TMessage Windows.
, . ,
. switch .

7.5 DDE
7.5.1
(Dynamical Data Exchange DDE) , Windows,
, . , , ,
, . (topic). , , (items). (macros). : , ,
, , , DDE. Windows C++Builder, , System:
DdeCIientConv, DdeCIientltem, DdeServerConv DdeServerltem.
, .
, ,
DdeCIientConv. DdeServerConv
, , . DdeCIientltem DdeServerltem .
DDE :



()


.

7.5.2
DdeServerConv,
-. Name.
. . DdeServerConv
, DdeCIientConv,
- .

, ,

451

DdeCIientConv DdeService DdeTopic , . -,


DdeServerConv, . , SetLink. :
bool SetLink(const System::AnsiString Service,
const System::AnsiString Topic);

Service Topic
DdeService DdeTopic. .

ConnectMode, ^
ddeManual ddeAutomatic . SetLink DdeService
DdeTopic, . SetLink
DdeService DdeTopic
, .
OpenLink, .
, . , , ServiceAppIication. ,
OpenLink false.
CIoseLink.
DdeService DdeTopic.
, (
) .
' DdeService DdeTopic, ConnectMode = ddeAutomatic. , . , , , ServiceApplication (). ConnectMode ddeAutomatic.
.
,
.
, .
, ( ), . , .. SetLink OpenLink.
, .. , , , ,
SetLink. , DdeService DdeTopic ,
- SetLink. To , CIoseLink
. SetLink.

452

ConnectMode ddeManual, DdeService DdeTopic, OpenLink. DdeService DdeTopic


, ,
, SetLink,
. ConnectMode = ddeAutomatic, . ConnectMode = ddeManual, SetLink OpenLink.


.
ConnectMode

DdeService DdeTopic

ddeAutomatic

,
,

SetLink

OpenLink

,
,

SetLink
OpenLink

ddeManual

.
( BExchange),
- . DdeClientConv ( DdeClientConvl) .
.
DdeClientConvl DdeService DdeTopic, ConnectMode ddeAutomatic.
OnCIick BExchange .
- ,
, DdeService DdeTopic,
ConnectMode, ddeManual. , , OnCreate
if (! DdeClientConvl->OpenLink())
ShowMessage(" '" +
DdeClientConvl->DdeService +
"' '" + DdeClientConvl->DdeTopic + " ' " ) ;

. OnCIick BExchange
DdeClientConvl->SetLink (sServer, sTopic) ,if ( ! DdeClientConvl->OpenLink())
ShowMessage(" '" +
DdeClientConvl->DdeService +
"' '" + DdedientConvl->DdeTopic + "' ") ;
< >
, sServer sTopic
. , OpenLink. ,

I, , ,

453

. BExchange , OpenLink false , ,


. , .
, :
DdeClientConvl->OpenLink();
< >


SetLink OpenLink , DdeClientConv. , DdeService DdeTopic.
. ,
Clipboard. -, C++Builder,
CopyToClipboard DdeServerltem (
).
, ,
PasteLink DdeClientConv. :
if ( ! DdeClientConvl->PasteLink())
\
ShowMessage(
" , . " ) ;

, PasteLink DdeService DdeTopic


. ,
SetLink OpenLink, .

7.5.3
7.5.3.1 -
. , , ,
DdeServerltein.
Lines , , ServerConv DdeServerConv, .. ,
. ServerConv , ,
(Caption) -.
Text DdeServerltem
Lines. Text , Lines,
.
DdeServerltem CopyToClipboard.
Clipboard , : .
, , , , :
1. DdeServerConv Name
Topicl. .

'

454
2.

DdeServerltem Name
Itemsl, ServerConv Topicl.
.. Strings -
, :
1 Topicl Server
2 Topicl Server

, .
3. Edit Editl
Text DdeServerltem>Strings.
, , .
OnChange Editl
Itemsl->Text =. Editl->Text;

4.

5.

Itemsl.
1 2, DdeServerConv DdeServerltem Topic2 Items2.
. ,
Itemsl, Topicl Topic2.
*

Button,

Itemsl~>CopyToClipboard();

Clipboard.
. , . 7.3.
6. , Server. ,
, , .
7. Server 1. ,
,
. Itemsl
Items2 Server Serverl. .
. 7.3
- DDE

7.5.3.2 -
-.
- . 7.4. , , ,
.
, .
1. DdeClientConv
ConnectMode ddeManual,
.
2. DdeClientltem DdeConv DdeClientConvl.

455

, ,
. 7.4
- DDE

(Server

1 Topid Server
2 Topid Server

IcrpoKa 1 Topici Server

3.

ComboBox. , , CBServer. Items


: Server Serverl. ComboBox,
, CBTopics. Items :
Topici Topic2. OnOeate , ComboBox 0.

4.

Memo Edit. Memo


Edit (Editl) . Edit - , , 1.
.
5. Button, 7.4 , Clipboard, PokeData .
6. SpeedButton, SBLink
. . AllowAllUp true, Grouplndex 1.
.
.
7.5.3.3
RequestData DdeClientConv. :
char * RequestData(const System::AnsiString Item);

Item - , DdeServerltem ,
. RequestData
.

:
char I n f o [ 2 5 6 ] ;
if (( ! DdeClientConvl->SetLink(CBServer->Text,
CBTopics~>Text))
| | ! DdeClientConvl->OpenLink())
ShowMessage(" '" + CBServer->Text +
" ' ' " + CBTopics->Text + " ' " ) ;
else

456

Info = DdeClentConvl->RequestData("Items" +
IntToStr(CBTopics->ItemIndex+l));
Memol->SetTextBuf(Info);
DdeClientConvl->CloseLink();
)

SetLink OpenLink , CBServer ,


CBTopics. , Info char Itemsl Items2
. SetTextBuf Memol. CloseLink
.
, - DdeClientltem. . ,
. . Ddeltem DdeClientlteml Itemsl - . OnChange CBTopics
DdeClientIteml~>DdeItem = "Items" + IntToStr (CBTopics->ItemIndex+l)';

DdeClientltem
. Ddeltem
Itemsl Items2 .
OnChange DdeClientlteml
Editl->Text = DdeClientIteml->Text;

RequestData DdeCHentConv
DdeClientltem, Editl.
.
:
Memol, OnChange DdeClientltem.
OnChange DdeClientltem, :
DdeClientConvl->RequestData("Items"

+ IntToStr(CBTopics->ItemIndex+l));

Info Memol.
-,
.
( ) Server Serverl, . Windows NT/2000/XP, , ++ilder, . Windows 98 ,
C++Builder, , , Windows .
, . , .
, RequestData. Clipboard.
, Clipboard, PasteLink DdeCHentConv..
Clipboard
DdeClientConvl->PasteLink();

, ,

457

,
. Clipboard
Clipboard , ,
, .
7.5.3.4
1 . , , . . , , DDEItem DdeClientltem
DdeServerltem ,
. , , DdeClientltem .
-,
SBLink :
if (SBLink->Down)
(
i f ( ( ! DdeClientCanvl->SetLink(CBServer->Text, CBTopics->Text))
II ! DdeClientCanvl->OpenLink())
ShowMessage(" '" + CBServer->Text
+ " ' ' " + CBTopics->Text + " ' " ) ; }
,/
else
{
DdeClientConvl->CloseLink();
Editl->Text = " " ;
)

SBLink , , ,
. SBLink.
, ,
, .
, . . -, ,
. , -. , . - .
7.5.3.5
.
. PokeData,
PokeDataLihes, ExecuteMacro ExecuteMacroLmes DdeClientConv.
PokeData PokeDataLines , DdeClientltem . , DdeClientConv . :'
bool PokeData(const System::AnsiString Item, char *Data);
bool PokeDataLines(const System::AnsiString Item,
Classes::TStrings* Data);

Item DdeServerltem
, , Data , . ,
PokeData Data
, PokeDataLines TStrings.

458

true, .
- , , PokeData
:
if ( ! DdeClientConvl->PokeDataLines(
DdeClientIteml~>DdeItem,Memol->Lines))
1
ShowMessage (" , ' );

, ,
PakeDdta, , . DdeClientlteml>DdeItem DdeServerltem , , . DdeServerltem , Memol.
, ,
Memol PokeData. , Editl . . , (
) .
PokeData PokeDataLines
OnPokeData DdeServerltem , . , , ', . Label OnPokeData DdeServerltem

L a b e l l - > C a p t i o n - " : '" +
((TDdeServerltem *)Sender)->Text + " ' " ;

DdeServerltem, .
ExecuteMacro ExecuteMacroLines DdeClientConv.
, . . OnExecuteMacro DdeServerConv .
ExecuteMacro ExecuteMacroLines , DdeClientConv . :
bool ExecuteMacro(char * Cmd, bool WaitFlg);
bool ExecuteMacroLines(Classes::TStrings* Cmd, bool WaitFlg);

Cmd ( ExecuteMacro)
( ExecuteMacroLines), . WaitFlg ,
. WaitFlg = true, ExecuteMacro,
ExecuteMacroLines, PokeData, PokeDataLines RequestData , . , , ,
WaitStat DdeClientConv. WaitStat - true,
ExecuteMacro, ExecuteMacroLines, PokeData, PokeDataLines RequestData
, .
true .
OnExecuteMacro TDdeServerConv,
, :
void . . . ( T O b j e c t ' S e n d e r , T S t r i n g s *Msg)

Msg .

, ,

459

, .
- :
if(!DdeClientConvl->ExecuteMacro(EMacro->Text.c_str(),false))
ShowMessage(" , " ) ;

, .
OnExecuteMacro
TDdeServerConv. Labell.
OnExecuteMacro TDdeServerConv :
void

fastcall

TFServer::TopiclExecuteMacro(TObject *Sender,
TStrings *Msg)

(
if(Msg->Count == 0 )
ShowMessage(Application->ExeName + ": ");
'else
Labell->Caption = " '" + Msg->Strings[0] + " ' " ;
}

C++Builder ( ),
-
.
,/

7.6

7.6.1 TThread

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

.

TThread.
. TThread , . TThread , File | New | Other
New Thread Object.
(Class Name) , TThread.
(, ) ,
:
Unit2.h:
#ifndef Unit2H
#define Unit2H
#include

<Classes.hpp>

460

7
cla>ss T : public TThread
(
private:
/* protected
*/
protected:
void
fastcall Executed;
public:
fastcall T(bool CreateSuspended) ;
/*
*/
#endif

Unit2.cpp:
include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#pragma package(smart_init)
//
//
//

Important: Methods and properties of objects in


can only be used in a method
called using Synchronize, for example:

//

Synchronize (UpdateCaption) ;

//

where UpdateCaption

//

void

//

fastcall

VCL

/'

could look like:

Unit2::UpdateCaption ()

Forml->Caption - "Updated in a thread";

/* : VCL
, Synchronize, :
Synchronize {UpdateCaption) ;
UpdateCaption :
void

fastcall

Unit2::UpdateCaption (!

Forml->Caption = "Updated in a thread";


*/
f f

fastcall T::T(bool CreateSuspended)


: TThread(CreateSuspended)
(
)
//
void
fastcall T::Execute()
!
//
Place thread code here
//
)

, ++ilder , , .

, ,

461

C++Builder , ,
( ), TThread.
,
. Execute, , . .
TThread . , :
fastcall

TThread(bool

CreateSuspended);

CreateSuspended .
CreateSuspended false, Execute . CreateSuspended = true,
, Resume:
void

f a s t c a l l Resume(void) ;

TThread .
TThread, VCL, new. :
*SecondProcess = new T(true);
SecondProcess->Resume();

Resume . -,
, CreateSuspended = true. -,
, Suspend:
void

f a s t c a l l Suspend(void);

,
Suspend, Resume. Suspend, , Resume. ,
, Suspended.
Execute ,
- .. - VCL , ,
. Synchronize, , . :
'

typedef void
fastcall
( closure *TThreadMethod)(void);
void
f a s t c a l l Synchronize(TThreadMethod SMethod);

Method , VCL.
, VCL
. ,
VCL. Work. , , private, , Execute , , Synchronize(Work):
Unit2.h:
class T : public TThread
(
private:
void
fastcall Hork(void);
protected:

462

'
void

fastcall

Execute ;

public:
fastcall

T(bool CreateSuspended);

);

Unit2.cpp:
void
f a s t c a l l T::Execute()
(
Synchronize(Work);
void

fastcall T; :Work (void)

t
Execute. .
Execute
Terminated (). false. -
Terminate , Terminated true. , Execute
Terminate true . :
void
(
do

while

fastcall T::Execute()

(! Terminated);

Terminate . Execute
, .
API Windows TerminateThread, . ,
TerminateThread((void *)SecondProcess->Handle,0);

SecondProcess. Handle () , API Windows. TerminateThread ( 0) . Return Value .


,
FreeOnTerminate TThread:
^ p r o p e r t y bool FreeOnTerminate

FreeOnTerminate true, TThread


, . FreeOnTerminate = false delete.
, ,
- , , , . , ,
, WaitFor:
int

f a s t c a l l WaitFor(void);

, ,

463

Return Value
. , , , .
, Priority. tpldle

tpLowest

tpLower

tpNormal

tpHigher

tpHighest

tpTimeCritical

7.6.2
- TThread.
, .
, - , . , , - , , . .
.
, . 7.5.
(Labell) . (BBegin)
. (BResp) .
. 7.5

File | New | Other


New Thread Object. (Class
Name) , , , MyTime.
, , , .., , C++Builder. ,
Time, , Time().

464

,
, .
MyTime. public
:
TDateTirae TO, ;

, , . TDateTime, C++Builder
.
MyTime:
f a s t c a l l MyTime::MyTime(bool CreateSuspended)
: TThread(CreateSuspended)
{
TMax = E n c o d e T i m e ( 0 ,

0,

10,

0) ;


EncodeTime , 10 ( ).
, . () UTimel,
UTime2.
Labell
Forml , .
UTime2 UTimel.
UTime2
include

"UTimel.h"

File | Include Unit Hdr.


UTimel UTime2,
.
Labell,
VCL, , . 7.6.1, Synchronize , , . private NewCaption:
void

f a s t c a l l NewCaption{);

NewCaption :
void
f a s t c a l l MyTime::NewCaption0
{
Forml->Labell->Caption = TimeToStr{ )

(Now()-TO));


. private Result:
void

fastcall

Result();

:
void
f a s t c a l l MyTime::Result{)
(
if
(Terminated)
ShowMessage(" ");
else ShOMMessage(" ");
)

Execute :
void

f a s t c a l l MyTime::Execute()

, ,

465

- Now () ;
do
Synchronize(NewCaption);
w h i l e (! T e r m i n a t e d && ( ( d o u b l e ) ( T M a x - (Now()-T0)) >= 0) ) ;
Synchronize(Result);

,
Now(). do ... while , ( , ,
Terminated true),
( Now()
). Synchronize Result, ,
.
. :
MyTirae Thread;

Thread MyTime. BBegin ( ) :


Thread = MyTirae(false);
Thread->FreeOnTerrainate = true;

, 1
false, .
FreeOnTerminate,
.
BResp ( ) :
Thread->Terminate();

. , - , , :
UTime2.h:
class MyTime : public TThread
{
private:
void
fastcall NewCaption();
void
fastcall Result();
protected:
void
fastcall Execute ();
public:
f a s t c a l l MyTirae(bool C r e a t e S u s p e n d e d ) ;
TDateTime TO, TMax;
);

UTime2.cpp:
include "UTimel.h"
fastcall MyTirae::MyTime(bool CreateSuspended)
: TThread(CreateSuspended)
(
TMax = EncodeTirae(0, 0, 10, 0) ;
)
//
void
fastcall MyTirae::NewCaption()
{
Forml->Labell->Caption = TimeToStr(TMax - (Now()-T0));

6
.

//

__-._

_.

void
fastcall MyTime::Result()
{
if (Terminated)
ShowMessage(" "};
else ShowMessage(" ");
)
//
void
fastcall MyTime: :Executed

i
TO = Now();
do
Synchronize(NewCaption);
while (! Terminated && ((double)(TMax - (Now()-T0)) >- 0 ) ) ;
Synchronize(Result);
!

UTimel.cpp:
include
MyTime

"UTime2.h"

*Thread;

void __fastcall TForml::BBeginClick(TObject *Sender)


f
Thread = new MyTime(false);
Thread->FreeOnTerminate = true;
!
//
,
void
f a s t c a l l TForml::BRespClick(TObject *Sender)
{
Thread->Terminate();
)

, .
, ,
. , ' , . UTime2 Result :
void
f a s t c a l l MyTime::Result()
(
if (Terminated)
{
ShowMessage(" ");
ReturnValue = 0;
!
else
{
ShowMessage(" ");
ReturnValue = 1;

ReturnValue
1 .
File | New | Other
New thread Ob|ed.
TResult.
. TimeS.

, ,

467

private Result2
Res:
class TResult : public TThread
(
private:
void
fastcall TResult::Result2();
int Res;
protected:
void
fastcall Executed;
public:
fastcall TResult(bool CreateSuspended);
!;
Res Thread,
Result2, ,
:
void
fastcall TResult;:Result2()
f
i f (Res - - 0)
ShowMessage(" ");
e l s e ShowMessage(" ");
!
Execute TResult : /
void
fastcall TResult::Execute()
{

Res = Thread->WaitFor();
Synchronize(Result2);
delete Thread;
!
WaitFor
Thread Res. Result2, Synchronize, Res . Thread,
. FreeOnTerminate false ( ). . delete Thread.
TimeS
Thread, Timel, TimeS Thread, extern (. . 1.9.5.4 13.6.1):
extern MyTime "Thread;
MyTime, UTime2.h, , :
include "UTime2.h"
, Time3. Timel TimeS:
include "UTime3.h"
TResult:
TResult *Result;
BBegin:
Thread = new MyTime(false);
Result - new TResult(false);
Result->FreeOnTerminate - true;

468

Thread FreeOnTerminate (false), Result true FreeOnTerminate.


, ,
, .

7.6.3
, ,
, .
, . 7.6 . (Timerl Timer2), (Labell Label2),
, , ( BResl BRes2) , (BSuspendl BSuspend2), ( BTerml 2),
. (BSync)
. , , ComboBox (. . 7.6 , )/
. 7.6
: ()

(6)

, .
. :

, ,

469

XJnitZ.h:
class Tl : public TThread
{
private:
void
fastcall UpdateTimer();
protected:
void
fastcall Execute();
public:
f a s t c a l l Tl(bool CreateSuspended);
TTiraer * Timer;:
);

Unit2.cpp:
void

f a s t c a l l Tl: :Execute ()

do
Synchronize (UpdateTimer) ;
while (! Terminated);
void
fastcall Tl::UpdateTimer()
{
Timer->Enabled = ! Terminated;
}

_,-

Timer (. . 3.7.8).
Execute, UpdateTimer,
Enabled true, , false
. , .
. Timerl Timer2 Enabled = false. ComboBox
tpldle
tpLowest
tpLower
tpNormal
tpHigher
tpHighest
tpTimeCritical

.
Unit2.h:
include "Unit2.h"

:
i n t i l = 0, 12 = 0;
Tl Threadl, *Thread2;
bool Terml, Terra2;

il i2 ,
. Threadl Thread2 - . Terml
2 , .
:
void

fastcall

TForml::FormCreate(TObject

*Sender)

ComboBoxl->IteraIndex = 3;
ComboBox2->Itemindex = 3;
Threadl = new Tl(false);
Threadl->Timer = Timerl;
Threadl->FreeOnTerminate =
Terml = false;

//
true;

470

7
Thread2 - new Tl(true);
//
Thread2->Timer = Tlmer2;
Thread2->FreeOnTerminate = true;
Term2 = false;
!

//

void
fastcall TForml::TimerlTimer(TObject *Sender)
(
il++;
Labell->Caption = il;
Timerl->Bnabled = false;
!
z/
_
_
void

fastcall TForml::Timer2Timer(TObject Sender)

f
Label2->Caption = i2;
Timer2->Enabled = false;

void
fastcall TForml::BReslClick(TObject *Sender)
{
if(! Terml) Threadl->Resume ()
else ShowMessage(" ");
!
/ /___
,__
___ .___ _____ _____ *
void
fastcall TForml::BRes2Click(TObject Sender)
f
if(! Term2) Thread2->Resume() ;
else ShowMessage(" ");
}
void
fastcall TForml::BTermlClick(TObject *Sender)
{
Threadl->Terminate();
Terml = true;
}
//____
___ ___ _____ _
void
f a s t c a l l TForml::BTerm2click(TObject Sender)
(
Thread2->Terminate();
Term2 - true;
}
z/
,void
fastcall TForml:: BSuspendlClick (TObject Sender)
{
if(! Terml) Threadl->Suspend();
else ShowMessage(" ");

void
{

fastcall

TForml::BSuspend2Click{TObject

if(! Terra2) Thread2->Suspend;


else ShowMessage(" ");

Sender)

, ,

471

void
fastcall TForml::BSyncClick(TObject *Sender)
(
if(Terml I I Term2)
ShowMessage(" ");
else
{
if (! Threadl->Suspended) Threadl->Suspend() ;
if (! Thread2->Suspended) Thread2->Suspend() ;
Timerl->Enabled = false;
Timer2->Enabled = false;
11 - 0;
12 = 0;
Threadl->Resume();
Thread2->Resurae();

void

f a s t c a l l TForml:: CotnboBoxlChange (TObjeot

*Sender)

if(Terml)
ShowMessage(" ");
else
switch (ComboBoxl->ItemIndex)
(
case 0: Threadl->Priority = tpldle;
break;
case 1: Threadl->Priority = tpLowest;
break;
case 2: Threadl->Priority = tpLower;
break;
case 3: Threadl->Priority = tpNormal;
break;
case 4: Threadl->Priority = tpHigher;
break;
case 5: Threadl->Priority = tpHighest;
break;
case 6: Threadl->Prxority = tpTimeCritical;
break;

void
fastcall TForml::CamboBox2Change(TObject *Sender)
{
if(Term2)
ShowMessage(" ");
else
switch (ComboBox2->ItemIndex)

case 0: Thread2->Priority
break;
case 1: Thread2->Priority
break;
case 2: Thread2->Priority
break;
case 3: Thread2->Priority
break;
case 4: Thread2->Priority
break;
case 5: Thread2->Priority

= tpldle;
= tpLowest;
- tpLower;
- tpNcrmal;
- tpHigher;
" tpHighest;

472

;
break;
case 6: Thread2->Priority = tpTimeCritical;
break;

'

FormCreate
Timer , . FreeOnTerminate true,
.
OnCreate . true, , Resume ( BReslClick BRes2Click). ( BSuspendlClick BSuspend2Click)
Suspend. ( BTermlClick
2) .
( BSyncClick)
( ) ,
il i2 0 . ( TForml.ComboBoxlChange TForml.ComboBox2Chailge) .

- , Terml 2,
true BTermlClick BTerm2Click.
, . , (. . 7.6 ), . , , . ,
Suspend
Resume, .

7.7 OLE
, C++Builder
OLE ( ), . OLE 1.0
Windows 3.1 , , .
, . , Excel, Word, Excel , .
Excel
Word Excel.
. Word ( , Word
).
, Word .

, ,

473

OLE 2.O. ().


, ,
(. 7.8). . , , .
, OLE 2.0, OLE, .
, () ,
OLE. ,
, , Windows. , . , , .
OLE
, , , , . . .
/
OLE C++Builder.
System OLE
OleContainer , . .
OleContainer, MainMenu, OpenDialog SaveDialog. ImageList, ToolBar , .
, , , ,
.
, , (Align = alTop), a
(Align = alClient).
. 7.7.
. 7.7

OLE

QSMKT

MahMenui imagsLisEi SaveDialogi OpenDiabgl

MainMenu , , ,
. MNew, MOpen, MSave MClose.
Filter: OLE J *.ole |
*.*. DefaultExt
ole.

474

. Fname,
OLE:
AnsiString FName;

, , :
void
f a s t c a l l TForml: :MNewCliclc(TObject 'Sender)
<
if (01eContainerl->InsertObjectDialog())
{
FName = "";
01eContainerl->DoVerb(ovShow);

InsertObjectDialog Windows Insert Ob|ect ( ),


,
OLE OleContainerl. DoVerb
, . DoVerb . .
, .

, ,
, . , , :
void

fastcall

TForml::MCloseClick(TObject

*Sender)

01eContainerl->DestroyObject 0;
}

OLE.
, , :
void
f a s t c a l l TForml::MSaveClick(TObject *Sender)
<
if (FName == "")
if
(SaveDialogl->Execute())
FName = SaveDialogl~>FileName;
else return;
01eContainerl->SaveToFile(ChangeFileExt(FName, " . o l e " ) ) ;
}

, (SaveDialogl), . SaveToFile . .ole ChangeFileExt,


(. . 16, . 16.5.5).
, , :
void
f a s t c a l l TForml::MOpenClick(TObject ^Sender)
(
if
(OpenDialogl->Execute())
(
01eContainerl->LoadFromFile(OpenDialogl->FileName);
FName = OpenDialogl->FileName;
01eContainerl->DoVerb(ovShow); )
)

, . , ,
LoadFromFile. FNa-

475

, ,

. DoVerb , . . OLE.
, . . (Insert
Object), . 7.8. : OLE ( ), ( ).
7.8

OLE -

Id pd'"Md " I IUi "E-_Li


tX id pdMMd' 'itiu-1. 1 ' G dw i
^3MeK-wcrcFad

>
J

-**:

.r1

"1.

I
J

"
f

.
.
Word, Excel, , .. , , , Windows
. . ,
.
, . , MNewClick DoVerb.
, OLE . . ,
. , , .
MNewClick DoVerb, , , .
, . . . 7.9
Excel. - , ..
,
. , , ,
Microsoft Excel .
,
. , ,
OLE .
. 7.9, , Microsoft Excel, ,
. .

476

. 7.9

OLE -

OLE . . , . , Excel, OnCreate -


:
01eContainerl->Create0bject("Excel.sheet",false);
01eContainerl->DoVerb(ovShow);

,
CreateObject OLE. ,
01eContainerl->Create0bject("Word.Document",

false)

Word,
01eContainerl->CreateObject("PowerPoint.showt",false) ;

PowerPoint.

OLE. . 7.8 . . 7.8
(Create from File).
OLE . (. . 7.10).
- Word, Excel, ..
(Link). ,
. ( ) OLE, , .

477

, ,
. 7.10

OLE -

!

::;"
,

. ,
. , OLE. . ,
, .
OLE. , ,,.,
Excel, Excel, , Excel
.
.
, , . 7.8, (Create from
File), . 7.10 - ,
(Link). .
. ,
. , . , . , ,
OLE. , . - , , . , .
, OLE. , .
. , OLE,
- . CreateObjectFromFile: .
void CreateObjectFromFile (AnsiString FileName,

bool Iconic);

FileName . Iconic,
false, , , . , true, .
,
:
void
if

fastcall

TForml::MOpenFClick(TObject

Sender)

(OpenDialogl->Execute ())
01eContainerl->CreateObjectFromFi'le (OpenDialogl->FileName,

false) ;

478

7
FName = OpenDialogl->FileName;
01eContainerl->Repaint();


OLE , . 7.8 7.10.
CreateLinkToFile,
:
void CreateLinkToFile(const AnsiString FileName,

bool Iconic);

.
, . ,
OLE, , , . , SaveAsDocument:
01eContainerl->SaveAsDocument(FName);

CreateObjectFromFile, CreateLinkToFile SaveAsDocument , ,


.
OLE. , , . OLE
( OLE), . .
. 7.8 7.9, .

7.8
7.8.1
COM (Component Object Model )
() (). ,
,
. ,
: , , .
(
). . ,
. , , .
.
DLL. Windows
. CLSID (Class Identifier), . : (in-process ) DLL, , (local) , (remote)
. , . , ,
.

, ,

479

DLL ( ; . 8.4), . DLL, ,


. , .
, . Microsoft Word.
Word , . Word
.
, ,
.
.
.
.
, . . , , ,
, . ,
.
.
1.
1 . ,
, .
,
, , , ,
? ,
. IDL (Interface Definition Language).
. , I, GUID
(Globally Unique Identifier). GUID
. GUID . IUnknown. : Querylnterface
, AddRef Release
1 . Querylnterface IID. Release , , .
.
AddRef ,
. AddRef, , , , ,
AddRef, , .
IUnknown , , , .
. - IDispatch. ,
OLE . 7.8.3.
. ,

480

, . .
CoCreatelnstance CLSID
, IID .
, , ,
, .
, CLSID , .
IClassFactory. CoGetClassObject, CLSID IID
IClassFactory.
. CoCreatelnstance IID . ,
.
, OLE32.dll
OLEAut32.dll. API , .
, , . , , -.
BSTR (Basic STRing). , . , .

7.8.2
, 7.8.1 C++Builder.
Microsoft Active Template Library (ATL) . , C++Builder ,
.
. DLL,
. - , ,
-,
.
C++Builder , , , File | New | Other ActiveX ActiveX Library. , -
, , PMyComServ, MyComServ. C++Builder ,
.
. . , .
.
, , , . ,
. ; , ,
.

, ,

481

File | New | Other ActiveX


Automation Object . , . 7.11. CoCloss Name
MyObject . 7.11.
. 7.11

QjQass Name |M0bect


Threading Motel | Apartment

Options
"'
P GenaiateEvent support code

Threading model
:
Single

. , , .

Apartment

,
. (apartment) . .

Free

.
.

Both

, Free,
.

Neutral

,
, . , , .. . +.
Apartment.

Description . Generate Event support code .


, .
, , (. 7.12).
View | Type Library. , .

. , .
, , , ..
16 C++Builder 6

482

. 7.12

=3
*-i Add
intDiv
* Dvi
MyObejct

|T/p
Numbe.l o
l ng
Numbeu long
Res
float *

iModfe

M
[all

:
MyComServ, MyObject
IMyOb|ect. .
IMyObject Attributes . Parent Interface . IUnknown, 7.8.1.
. New
Method ( . 7.12) . .
Add . Parameters, . 7.12, ,
. Return Type . ,
HRESULT.
long .
. , Add HRESULT ,
.
Add.
, . Name (Numberl . 7.12). (long). Modifier : , , , .. [in]. .
.
New Interface ( ). . IntDiv. IUnknown,
. , ,
Div (. 7.12). HRESULT. . . ( Res) .
, float
"*", . 7.12.
Modifier. , . '7.13. 1
, .. , ;

, ,

483

. Out ,
. . , . ,
. C++Builder.
. 7.13

i W Oul

L.CID
Otf onal

' S t V a l Has Default Value

Dncd

, . . MyObject
Implements. Insertlnterface. , .
IntDiv. .
.
. Refresh Implementation ( . 7.12). . , , . ,
MyObjectlmpl.cpp.
:
STDMETHODIMP TMyObjectlmpl::Add(long Numberl, long Number2)

STDMETHODIMP TMyObjectlmpl::Div(long Numberl, long Number2, f l o a t * Res)


{
}

, . :
STDMETHODIMP TMyObjectlmpl::Add(long Numberl, long Number2}
{

r e t u r n Numberl + Number2;
}

STDMETHODIMP TMyObjectlmpl::Div(long Numberl, long Number2, f l o a t * Res)


{

*Res = (float)Numberl / Number2;


return S_OK;
}

. Add
. Div
.
, .

484

S_OK, .
, . . Run | Register ActiveX Server
C++Builder. To
. 7.12. uuid,
Windows. ( - ), Run | Unregister ActiveX Server.
, IDL
Export IDL . 7.12.
, . . Edit,
. , ( BAdd) , (BDiv) ,
. Label, .
. ,
. , . Project | Impart
Type Library. , . 7.14.
.
- , Add
. , ,
, . 7.14. Generate Component Wrappers. ,
. Create Unit . My corns erv_tlb.
, . ,
. Mycomservjtlb.cpp
GUID , . servjtlb.h
, , Add Div.
. 7.14

MSo
treDLL 1 0 Type Lb
i ray [VeaiD
i n 1 G|
MSWebDVD 1 0 Type Litcay fVesio
i n 1 0)
mmmdm 1 0 Libiaj iVeision 1.0)
MTS ZOAdmin lyx Ltbf-arv 1 1 0]
MTxAddln Tjpe Ubray |Version 1 0)
1
4JiMgr COM Addn Projecl |Ver*on 1 0)
1 ;Typ
"

. [TMyOb^ct

"3

Unitjr name ]D \Progfaw FitetSia^\C8uid'er6sirnterts\''W -j '

, ,

485

,

# i n c l u d e <MyComServ_TLB.h>

, .
Interfacel Interface2,
. :
f
#include <MyComServ_ILB.h>
class TForml : public TForm
<
published:
// IDE-managed Components
TEdit * E d i t l ;
TEdit *Edit2;
TLabel *Labell;
TButton *BAdd;
TButton *BDiv;
void
f a s t c a l l FormCreate(TObject *Sender);
void
f a s t c a l l BAddClick(TObject *Sender);
void
f a s t c a l l BDivClick(TObject Sender);
private:
/ / User declarations'
public:
// User declarations
,/
f a s t c a l l TForml(TComponent* Owner);
TCOMIMyObject I n t e r f a c e l ;
IntDivPtr Interface2;
};

Interfacel TCOMIMyObject. (smart) .


(, ) MyComServ_TLB.h. ,
. ,
, .
. , . Interface2 IntDivPtr. .
, MyComServ_TLB.h.
Ptr.
OnCreate :
Interfacel = CoMyObject::Create ;
Interface2 = Interfacel;

Create .
. Interfacel. .
, TCOMIMyObject, .
Interface2
. QueryInterface. .
, . :
void
f a s t c a l l TForml::BAddClick(TObject *Sender)
{
Labell->Caption - Interfacel.Add(StrToInt(Editl->Text),
StrToInt(Edit2->Text));

486
//
void
f a s t c a l l TForml::BDxvClick(TObject *Sender)
{
float R;
(*Interface2) .Div(StrToInt(Editl->Text) ,
StrToInt(Edit2->Text), SR) ;
Labell->Caption = R;
}

, Add Interface!.. , .
, Interface2 . ,
R, Div. R .
.
, .
, , , ,
. , , ,
, . ,
,
, , , . 7.8.3. . ,
(. [2]).

7.8.3
7.8.2
DLL. ,
.. , . , , ..
.
, - . . ,
.
, , .
, Edit
MyServer (. 7.15 ). . - .
. 7.15
()
()

)
D ?

.. [

| 0 ePrnpertySel

, ,

487

Projectl. , . ,
. .
C++Builder.
. File | New | Other ActiveX
Automation Ob[ect .
, , 7.8.2. ,
(. . 7.11), CaClass Name MyObject.

(. 7.12), , , , . 7.12. , , . IMyServer, IDispatch. ,
SetVis. .
Vis, VARIANT_BOOL ( , ) [in]. ,
( true) ( false).
Mess. . , . Property ( . 7.12).
Read | Write ( ), Read Only (
), Write Only ( ), Read | Write | Write By Ref ( , ). , Mess.
Read | Write. : ,
. Mess.
. Attributes BSTR.
, . . 7,8.1.
Parameters
Text, BSTR * BSTR,
[out, retval]. Text, BSTR,
[in]. HRESULT.
. . Refresh Implementation ( )
. 7.12. . MyServerIm.pl.cpp
get_Mess, set_Mess
SetVis. . :
STDMETHODIMP TMyServerlmpl::get_Mess(BSTR* Text)
{
try
{
*Text = WideString((Forml->Editl->Text).c_str()).c_bstr0;
}
catch(Exception Se)
{
return Error(e.Message.c_str(), IID_IMyServer);
}
return S_OK;

488

7
STDMETHODIMP TMyServerlmpl: :set_Mess (BST.R Text)
{
try
{
Forml->Editl-?Text = Text;
}
catch(Exception Se)
f
return Error(e.Message.c_str(}, IID_IMyServer);
}
return S_OK;
};
STDMETHODIMP TMyServerlmpl::SetVis(VARIANT_BOOL
{
Forml->Visible = Vis;
return S_OK;
}

Vis)

set_Mess : Editl , Text. SetVis :


Vis. get_Mess . , Editl.
AnsiString, BSTR. . c_str() - AnsiString
char *.
WideString. Unicode. , , c_b s * r () - WideString BSTR.
. , . : Windows .
.
, . 7,15 .
(BGetMess) Editl , . (BSetMess)
. (BSetVis) (CheckBoxl).
.
Variant Serv;

void

f a s t c a l l TForral::ForraCreate(TObjeot *Sender)

Serv = CreateOleObject("Project!.MyServer");
)
//__
void
fastcall TForml::BGetMessClick(TObject *Sender}
(
Editl->Text - Serv.OlePropertyGet("Mess") ;
}
//

void
fastcall TForml :': BSetMessClick (TObject Sender)

, ,

489

Serv.OlePropertySet("Mess",
Widestring ( (Editl->Text) . c_str () } .cjostr () ) ;
void
fastcall TForml::BSetVisClick(TObject *Sender)
(
Serv.OleProcedure("Setvis", CheckBoxl->Checked);
)

Serv .
Variant. FormCreate OnCreate .
CreateOleObject Serv OLE , . CreateOleObject . . ,
. , .
BGetMessClick. Editl. Mess OlePropertyGet.
. BSetMessClick Mess Editl.
OlePropertySet. , '. .
AnsiString
BSTR.
BSetVisClick SetVis . OleProcednre. . . CheckBoxl->Checked, ,
, .
. , , : ,
, , . , .
, Windows . ,
. , .
, .
, , . Windows Projectl.exe
- .
: . , , , . , . ,
, .
, . . . ,
, - . , ,

490

, ,
, . , , ,
: RPC .
.
. .
void
(
try

f a s t c a l l TForral::FormCreate(TObject Sender)

Serv=Create01eObject("Projectl.MyServer");
)
catch(Exception S)
(
ShowMessage("He 'Projectl.MyServer'");

void __fastcall TForml::BGetMessClick(TObject *Sender)


(
try
(

Editl->Text = Serv.OlePropertyGet("Mess");
}

catch(Exception &)
{

)
)

ShowMessage(" ' P r o j e c t l . M y S e r v e r ' ");

, ,
C++Builder C++. , .
- , COM (Delphi, Visual Basic ..),
, , , . , , , , C++Builder.
, . ,
, . , , , , ?
.
, Microsoft
VBA. , , , ,
. File | Open,
Type Library, , , Word.
Microsoft Office, MSWord*.olb. Program Files\ Microsoft Office.
( )
,
Word, , .
,
CreateOleObject, OlePropertyGet, OlePropertySet, OleProcedure.

, ,

491

, Microsoft Office .
Microsoft , . 7.9.
, , , - , Microsoft Office. , , Windows 98, Windows XP.

7.8.4 ActiveX
ActiveX . ActiveX ., Windows
, (Visual Basic, PowerBuilder, Delphi),
, (. . 12).
, Windows
ActiveX, , , ..
ActiveX ,
- , . ActiveX
, ,
C++Builder. , ActiveX, _ ,
Microsoft, Word, Excel .
Web.
ActiveX. ,
,
, ActiveX.
. 8.3. ActiveX
C++Builder MonthCalendar (. . 3.3.3).
, Windows ActiveX.
, , , , , Word.
, File | CloseAII.
File | New | Other ActiveX ActiveX Control.
, ActiveX: ActiveX Library , ActiveX Control. ,
. 7.16. VCL Class Name VCL
(, ), ActiveX. TMonthCalendar, ,
, ,
. , .
. 7.16
ActiveX

,:'--: : -2SJ
i VCL pass Name-

JTMonthCaiend* [ComQrlsj

Hew Active N am*JMonthCae


l ndatX
I ImptematTlafonUrxt JHonthCalendaimpli.cpp
Protect Narre

|MonthCatondurKConlrol1 cpp
I., v , ,

I
Include Stout Bo*

Udp

492

Make Control Licensed


.lie. , ActiveX
, . - ,
.. Include Version Information .
(. 2.3.5). Include About Bax
. . , - .
, . C++Builder
, , . , -
.
Run | Register ActiveX server, Windows.
, Run | Unregister ActiveX Server.
, ActiveX ,
. , . . , Word. , ,.
Visual Basic.
Word , , . Word , .
, .
.
, , Word. ,
Word 2002, Windows . , 1
Word !! VBA, ,
.
. Word | | .
( )
. Microsoft Visual Basic (. . 7.17).
Project Normal,
Insert | UserFarm.
ToolBox ( . 7.17) , . , .
TaolBox Additional
Cantrals. ActiveX.
MonthCalendarX.
ToalBax. . Property -
.
FCalendar ( Name ). TaolBox , ,
. 7.17, ( Caption),
ControlTipText , .
Visual Basic. :

, ,

493

Private Sub CommandButtonl_Click()


Selection = MonthCalendarXl.Date
End Sub
Private Sub CommandButton2_Cliok()
Selection = MonthCalendarXl.Date - Date
End Sub
Private Sub CommandButton3_Click()
End
End Sub

Project (
. 7.17 MyCalendar)
(. . 7.17):
FCalendar.Show (modeless)
( modeless). , . , Microsoft Office 97 ,
.
. 7.17
Microsoft Visual Basic

3 -m
I DontCarnJl
, ( Run Sub/UserForm . 7.17) Visual Basic.
- . Word | ,
, , , , (,
Gr!-Alt-C), . , , .
, ActiveX. Word , - Ctrl-Alt-.
(. 7.18).
Bbi
. -

494

, . , ActiveX .
. 7.18
,
ActiveX

] 1 EIBSO
t

'

'

'

'

*!..'

' > . '

'

'

20.03.2002. 30.04.2002, .
41 ,

11
18
25

S
12
19
26


C|J
6
13

27

7
14
?1
29

g
15
??
29

ffi

9
16

3
!0
17

?
31

20-0-20

Jj

ActiveX.
C++Builder ActiveX, ,
, Windows, - .
Component | Import ActiveX Control.
, . 7.19, . , , Add
. .
- ,
., Class names
, . Palette
page , . Unit dir name ,
ActiveX. Search path , .
. 7.19
ActiveX
sDltOutok View Control [Version 1 D]
j s d t Sdipl Control I D [Veition 1 0)
Microsoft Shell Conirols And AUomatiai Version 1.0)
Micrasrfl TeirmnalServieesAclive Client! G Type Library IVei
MicrasotnV Libia* fusion 1.0|
Mtootdl Windows Ccranon Contids G D Version 2 0|

'

j ;

, ,

495

Create unit . .
Install () , ,
. ,
. 8. . ,
7.19. .

7.9 -
7.9.1 - C++Builder 5
C++Builder 5, Word, Excel
, Word
Microsoft Office, C++Builder
, Office2k, Office97,
Servers. .
TOleServer.
, .-
. TOleServer . . ,
.
, , Microsoft Office, Windows Microsoft Office. C++Builder 6, , Office 2000, 97 .
, , Office2k Office97, . . Component [ Install Packages. , . 7.20. . . 8, .
8.5. , .
. 7.20


Boral nd Aciiorfiar Components
VjBoral nd ADG DB Component*
1 Boa
li reJ Base Cached CtentDatasei Component
ComppnertsS_ampje Package
*:- . i"_- * rS\BinSbc^?aKSKV6D bpl"
KNe 1

, :

| '

Hep
l

496

Design packages ,
Borland C++Builder Server Components Sample Package (. 7.20)
.
. Add . CBuilder6\Bin
bcb2kaxserver60.bpl Office 2000/XP bcb97axserver60.bpl Office 97/98.
, ( Design packages . . 7.20), .
.
,
.
, ,
include "Word_2K_SRVR.h"

include "Word_97_SRVR.h"

pragma l i n k "Word_2K_SRVR"
>

.'
pragma l i n k "Word_97_SRVR"
, . .
C++Builder 6. C++Builder 5 , - Servers. C++Builder 5
. , -
C++Builder 5 6 .
C++Builder 5 C++Builder 6 , .
, , Windows Microsoft Office.
, C++Builder 6,
, , Windows 2000/XP.
Windows 98 Microsoft Office 98 . CC3260MT.dll.
, ( CBuilder6\Bin) System.
.
,
C++Builder 6, . ,
, C++Builder 5.
Windows 98/2000/XP Office 98/2000/.
, Microsoft Office. -
, , Microsoft,
(
. - .

, ,

497

-
C++Builder. .

Office2k, Office97, Servers, , Word.
, WordApplication . .
Name Tag 4 (
- 3).
AutoConnect , . AutoCoiulect = true,
. AutoConnect = false, ,
Connect. :
WordApplicationl->Connect();

,
AutoConnect Connect. ,
- - .
AutoConnect ,
true , .. ,-
. AutoConnect = true .
ConnectKind ,
. :
ckRunningOrNew

ckNewInstan.ee

ckRunninglnstance

ckRemote

.
RemoteMachineName.

ckAttachToInterface

.
ConnectTo ( ). ckAttachToInterface
true
AutoConnect.

ConnectKind ckRunningOrNew.
( WordApplication Word ), . . , ( Word).
ConnectKind ckRunningOrNew,
. ConnectKind ckRunninglnstance, .
, , EOleSysError. ConnectKind = ckRunninglnstance, ,
, , , :

,
MOI

Applicationl->Connect ();
(EOleSysErrorS)
ication->MessageBox(
Word",
" ",
_ + MB_ICONEXCLAMATION);
ication->Terminate();
EOleSysError ,
ConnectKind = ckRemote , . RemoteMachineName
, .
, ,
:
, - , , ^onnectKind = ckRunninglnstance.

, , ) , ConnectKind =
^Instance.
, Connect= ckNewInstance RemoteMachi.
, , ckRunningOrNew.
5 ConnectKind ckAttachToInterface.
, Word Application, .
.
, ,
. , ,
, , . , ,
; , ,
- , Visible true.
- C++Builder 6 5. C++Builder 5 [:
jplicationl->Visible - true; // C++Builder 5
-+Builder 6 Visible, , ! .
set_Visible,
, false . :
>plicationl->set_Visible(true); // C++Builder 6
Disconnect.
, Word Application,
true, < , . true, , , , -

true,
Wordft
<

(
!

7.9.2
]
*

Applicat

Applici

CheckGr
!
npoi
'
Wore
"wore

Word
,
Docume

!
01


. !
!
, ^

,

if I
{

, ,

499

. AutoQuit
true, :
WordApplcationl->Disconnect();

, . ,
- , , .
Windows, - -,,, .

7.9.2 Word
, Word.
, , Word.
Visual Basic, Word
WordBasic. , Word .
, , , Word.
WordApplication,
Application ( Word),
, C++Builder. ,
Application Options , . CheckSpellingAsYouType
CheckGrammarAsYouType , , Word . Word. , :
WordApplicationl->Options->CheckSpellingAsYouType = false;
WordApplicationl->Options->CheckGrammarAsYouIype - false;

, ,
Word , .
Application ActiveDocument . Document, .
Word
Documents. ,
Word . Document, . Count
Documents. , , Word . ,
ASave, APrint APreview,
, ,
, , , Word .
:
if(WordApplicationl->Documents->Count == 0)
{
ASave->Enabled - false;
APreview->Enabled = false;
APrint->Enabled - false;
}

Document Documents Add Documents.

500

. WordApplication. : Template
NewTemplate. Template ,
. ,
(Normal). NewTemplate ,
( true), . NewTemplate = false, .. .
WordAppIication Office97 . WordApplication Office2k : DocumentType Visible .
C++Builder ( Text) OleVariant. -
, "
. EmptyParam
OleVariant, .
System.
, WordApplication Office97, , :
WordApplicationl->Documents->Add(EmptyParam,

EmptyParam);

C:\MyTemplate\
My.dot, :
TVariant Template = ":\\MyTemplate\\My.dot";
WordApplicationl->Documents->Add(&Template, EmptyParam);

, :
TVariant Template = t r u e ;
WordApplicationl->Documents->Add(EmptyParam,STemplate);

0 false
(, 1) true. ,
NewTemplate :
TVariant Template = 1;

, .
WordApplication Office97. WordApplication Office2k
Add . :
TVariant Visible = f a l s e ;
WordApplicationl->Documents->Add(
EmptyParam,EmptyParam,EmptyParam,Visible);

Word Selection,
Selection , , . InsertBefore InsertAfter, ,
Selection. , :
WordApplicationl->Selection->InsertAfter(TVariant('\n')1;
WordApplicationl->Selection->InsertAfter(
TVariant(" " + Editl->Text + " ! \ n " ) ) ;

Selection , ... !, Editl.


,
. , , .. Selection.

, ,

501

, , . Selection , : Font ParagraphFormat . , WordApplication.


WordFont WordParagraphFormat.
. , , -'
Servers . ConnectTo. , . ,
WordFontl->ConnectTo(WordApplicationl->Selection->Font);
WordParagraphFormatl->ConnectTo(
WordApplicationi->Selection->ParagraphFarmat);

WordFontl WordParagraphFormatl
. .
Font , , : Name ,
Bold , Italic , Size , StrikeThrough ,
DoubleStrikeThrough , Underline , Shadow , Emboss , Engrave ,
Hidden , Subscript , Superscript .
Underline : wdUnderlineNone
, wdUnderlineSingle wdUnderlineDouble
, wdUnderlineDash, wdUnderlineDotDash, wdUnderlineDotDotDash, wdUnderlineThick, wdUnderlineDotted, wdUnderlineWords, wdUnderlineWavy .
C++Builder 5 . ,

WordFontl->Underline = wdUnderlineSingle;
WordFontl->Bold = 1;

// C++Builder 5
11 C++Builder 5

( WordFontl ) . :
WordFontl->Bold - t r u e ;

// C++Builder 5

C++Builder 6 . C++Builder 6 :
WordFontl->set_Underline(wdUnderlineSingle); // C++Builder
WordFontl->set_Bold(l);
// C++Builder 6

ParagraphFormat WordParagraphFormat
: Alignment . wdAlignParagraphLeft , wdAlignParagraphCenter ,
wdAlignParagraphRight , wdAlignParagraphJustify .
, C++Builder 6 5. ,
11 C-h+Builder 5:
WordParagraphFormatl->Alignment

= wdAlignParagraphCenter;

// C++Builder 6:
WordParagraphFormatl->set_Alignment(wdAlignParagraphCenter);

( , WordParagraphF
matl ) .

502

InsertBefore
InsertAfter. TypeText. ,
InsertBefore InsertAfter, . TypeText Replaces election Options. true, , . ReplaceSelection = false,
. ReplaceSelection = true.TaKHM
WordApplicationl->Options->KeplaceSelection = true;
WordApplicationl->Selection->TypeText(TVariant("

"));

, . , , ReplaceSelection, true , - .
Paste, Clipboard. ,
include <Clipbrd.hpp>
Clipboard ->Assign(Imagel->Picture);
WordApplicationl->Selection->Paste();

, Imagel.
Paste , TypeText,
ReplaceSelection: Clipboard , .
Collapse ,
.. , .
Direction Collapse , .
Direction = wdCollapseStart , Direction = wdCollapseEnd . Direction = wdCollapseStart.
,
TVariant Direction - wdCollapseEnd;
WordApplicationl->Selection->Collapse(SDirection);

, .
Document , .
WordDocument. , .. , WordApplication. ,
WordFontl WordParagraphFormatl, ConnectTo. ,
WordDocumentl->ConnectTo(WordApplicationl->ActveDocument);

WordDocumentl , Word
ActiveDocument, .
, WordDocument,
Range. . Range
Range,
. . ,
TVariant = 0, b - 10;
RangePtr MyRange = WordDocumentl->Range(Sa, &b) ;

MyRange, 10 .

, ,

503

Range Selection, . Range


InsertBefore,. Insert After, TypeText, Paste, Collapse.
Range Font ParagraphFormat, Selection.
,
MyRange->Font->Bold = t r u e ;

, MyRange. MyRange , 10 .
Document Content, , . Range .
WordDocumentl->Content->Font->Bold = 1;

,
WordDocumentl->Content->InsertBefore(TVariant("000\"));

.
Word
Dialogs. Dialog, Word.
WordApplicationl->Dialogs->Itern(WdWordDialog)

WdWordDialog .
, .
wdDialogEditFind

wdDialogEditPasteSpecial

wdDialogEditReplace

wdDialogFileFind

wdDialogFileNew

wdDialogFileOpen

wdDialogFilePageS etup

wdDialogFilePrint

wdDialogFilePrintSetup

wdDialogFileSaveAs

wdDialogFileSummarylnfo

()

wdDialogFormatFont

wdDialogFormatParagraph

wdDialoglnsertDatabase

wdDialoglnsertFile

wdDialoglnsertPageNumbers

, Dialog,
Show. , .

504

TimeOut
, . TimeOut Empty, .
, :
WordApplicationI->set_Visible(true); // C++Builder 6
//
if(WordApplicationl->Dialogs->Item(
wdDialogFileOpen)->Show(EraptyParam) == -1)
// , ...
WordApplicationl->Dialogs->Item(wdDialogFileSaveAs)->Show(EmptyParam);
//
*
WordApplicationi->Dialogs->Item(wdDialogFilePrint)->Show(EmptyParam);
. , .
. ,
Word ,
. , ,
Word , , .
,
Show , , :
-2

-1

Esc

>0

: 1 , 2 ..

, , ,
. , , Esc 0,
(.. ) - 1 .
,
Show .
- . :
if(WordApplicationl->Dialogs->Item(wdDialogFileOpen)->
Show(EmptyParam) != -1)
Application->MessageBox(" ",
" ",
_ + MB_ICONEXCLAMATION);
, , Document, . SaveAs, OleVariant
. , . SaveAs - :
TVariant FileName = "My.doc";
WordDocumentl->SaveAs(SFileName);
, WordDocumentl, My.doc. Wor&Documentl .

505

, ,

Printout:
WordDocumentl->PrintOut();

PrintPreview:
WordDocumentl->PrintPreview();


Word, WordApplication, WordDocument, WordFont WordParagraphFormat.
WordLetterContent. ,
.

7.9.3 Word
, ,
. ,
- Word. , - . ,
Woffl. , Word.
, , - , Word
. . 11, . 11.3 Word .
, . 7.21. .
( BInDoc) Word , . 7.22.
Editl, Memol,
tmagel. ( RGFont) ( RGAHghn).
. Word . Word . , . . Word
Word.
. 7.21
Word

! >

" \ ' ~


, '
.

CUXIMII

(* ;
;

506

. 7.22
,

Word
!

,
,

.

, . 7.15 WordApplication, WordDocument, WordFont WordParagraphFormat. .


.
C++Builder 6 ( Office2k Offlce97) C++Builder 5.
Office2k C++Builder 6. .
:
#include "Word_2K_SRVR.h"
// Office2k
//tindude "Word_97_SRVR.h" // Office97
class TForml : public TForm
{

published:
/ / IDE-managed Components
TImage *Imagel;
private: . // User declarations
void
fastcall Connect(void);

:
#pragma link "Word_2K_SRVR"
//tpragma link "Word_97_SRVR",

// 0ffice2k
// Office97

#include <Clipbrd.hpp>
void
fastcall TForral::Connect(void)
//
if (WordApplicationl->Documents->Count

0)

Application->MessageBox(" Word
" ",
_ + MB_ICONEXCLAMATION)
Abort();
}
// WordDocumentl
WordDocumenti->ConnectTo(WordApplicationl->ActiveDocument);
//
BInDoc->Enabled = true;

, ,
BPreview->Enabled - true/
BPrint->Enabled = true;
BSave->Enabled = true;

}
/

507

void
fastcall TForml::BNewClick(TObject *Sender)
{
// Word
// C++Builder 6:
TVariant Visible = false;
WordApplicationi->Documents->Add(
EmptyParam,EmptyParam,EmptyParam,Visible};
// C++Builder 5:
// WordApplicationl->Documents->Add(EmptyParam,EmptyParam) ;
Connect () ;
}
/ J

void
fastcall TForml::BOpenClick(TObject *Sender)
(
//
WordApplicationl->set_Visible(true) ; // C++Builder 6
// WordApplicationl->visible = true;
// C++Builder 5
if (WordApplicationl->Dialogs->Item(
wdDialogFileOpen)->Show(EmptyParam) == -1)
Connect () ;
}
//
void
fastcall TForml::BPreviewClick(TObject *Sender)
{
//
Connect();
WordDocumentl->PrintPreview() ;
WordApplicationl->set_Visible(true); // C++Builder 6
// WordApplicationl->Visible = true,// C++Builder 5
)
//
^__
void
fastcall TForml::BPrintClick(TObject *Sender)
,
{
I
//
Connect () ;
WordApplicationl->set_Visible(true); // C++Builder 6
// WordApplicationl->Visible = true;
// C++Builder 5
WordApplicationl->Dialogs->Item (wdDialogFilePrint)->Show(EmptyParam);
)
//

void
fastcall TForml::BWordClick(TObject *Sender)
(
//Word
WordApplicationl->set_Visible(true); // C++Builder 6
// WordApplicationl->Visible = true;
// C++Builder 5
i
i/

_ _

void
fastcall TForml::BSaveClick(TObject Sender)
(
//
Connect () ;
WordApplicationl->Dialogs->Item(wdDialogFileSaveAs)->Show(EmptyParam);
1
//

_.

._

void
fastcall TForml::BInDocClick(TObject *Sender)
{
//

508

7
//
TVariant Direction = wdCollapseEnd;
//
TVariant snew - "\n";
Connect() ;
// Imagel
WordApplicationl->Selection->InsertAfter(snew);
Clipboard 0->Assign(Imagel->Picture);
WordApplicationl->Selection->Paste();
WordApplicationl->Selection->InsertAfter(snew);
//
WordApplicationi->Selection->Collapse(^Direction) ;
//
WordApplicationi->Selection->InsertAfter(snew) ;
WordApplicationl->Selection->InsertAfter(
TVariant(" " + Editl->Text +" !\n"));
//
WordFontl->ConnectTo(WordApplicationl->Selection->Font);
WordFontl->set_Bold(l);
// C++Builder 6
WordFontl->set_Italic(1); // C++Builder 6
// WordFontl->Bold = 1;
// C++Builder 5
// WordFontl->Italic = 1;
// C++Builder 5
WordParagraphFormatl->ConnectTo(
WordApplicationl->Selection->ParagraphFormat);
// C++Builder 6:
WordParagraphFormatl->set_Alignment(wdAlignParagraphCenter);
// C++Builder 5:
// WordParagraphFormatl->Alignment = wdAlignParagraphCenter;

//
WordApplicationl->Selection->Collapse(SDirection) ;
//
WordApplicationi->Selection->InsertAfter(snew);
WordApplicationi->Selection->InsertAfter(TVariant(Meraoi->Text));
WordApplicationl->Selection->InsertAfter(snew);
//
WordFonti->ConnectTo(WordApplicationl->Selection->Font) ;
WordParagraphFormatl->ConnectTo(
WordApplicationl->Selection->ParagraphFormat);
// C++Builder 6:
if (RGFont->ItemIndex > 1)
WordFontl->set_Bold(i) ;
else WordFontl-> set_Bold(0);
if (RGFont->ItemIndex % 2 == 1)
WordFontl->set_Italic(1)
else WordFontl->set_Italic(0);
switch (RGAlighn->ItemIndex)
(
case 0: WordParagraphFormatl->set_Alignment(wdAlignParagraphLeft);
break;
case 1: WordParagraphFormatl->set_Alignment(wdAlignParagraphRight);
break;
case 2: WordParagraphFormati->set_Alignment(wdAlignParagraphCenter);
break;
case 3: WordParagraphFormatl->set_Alignment(wdAlignParagraphJustify);
)
/* C++Builder 5:
if (RGFont->ItemIndex > 1)
WordFontl->Bold = 1;
else WordFontl->Bold = 0;
if (RGFont->ItemIndex % 2 == 1)

, ,

509

WordFontl->Italic = 1;
else WordFontl->Italic - 0;
switch (RGAlighn->ItemIndex)
{
case 0: WordParagraphFormatl->Alignment = wdAlignParagraphLeft;
break;,
case 1: WordParagraphFormatl->Alignment = wdAlignPara.graphB.ight;
break;
case 2; WordParagraphFormatl->Alignment = wdAlignParagraphCenter;
break;
case 3: WordParagraphFormatl->Alignment - wdAlignParagraphJustify;
}
*/
//
WordApplicationl->Selection->Collapse(^Direction);
//
W o r d A p p l i c a t i o n l - > S e l e c t i o n - > I n s e r t A f t e r ( T V a r i a n t ( " \\"));
//
WordFontl->ConnectTo(WordApplicationl->Selection->Font);
WordFontl->set_Bold(l);
// C++Builder 6
WordFontl->set_Italic(l); // C++Builder 6
// WordFontl->Bold = 1;
// C++Builder 5
// WordFontl->Italic = 1;
// C++Builder 5
WordParagraphFormatl->ConnectTo (
-'
WordApplicationl->Selection->ParagraphFormat);
//C++Builder 6:
WordParagraphFormatl->set_Alignment(wdAlignParagraphCenter);
// C++Builder 5:
// WordParagraphFormatl->Alignment = wdAlignParagraphCenter;
WordApplicationl->Selection->Collapse(SDirection);
}
, , . .
Connect. , . Word ,
, WordDocumentl. ,
WordDocument
BPreviewCIick .
BInDocClick, . , , Clipboard,
#include <Clipbrd.hpp> Clipbrd.hpp,
Clipboard.
BInDocClick Connect.
Connect ,
, Imagel. Collapse
Memol
, Editl.
. WordFontl WordParagraphFormatl,
. ,
Memol . , .

. (

510

) . ,
, .

7.10 CORBA
7.10.1
CORBA (Common Object Request Broker Architecture) . CORBA
OMG (Object Management Group ), . CORBA ,
, .
CORBA .
. ORB (Object Request Broker). ,
VisiBroker for C++ ORB 3.3.2. Smart Agent
, . .
Implementation Repository
. VisiBroker
.
Basic Object Adapter (BOA)
CORBA . , BOA, . BOA Implementation
Repository. , . Smart Agent
Object Activation Daemon , .
CORBA .
, CORBA, ORB. CORBA (Stub). , , ,

. , . ORB
Smart
Agent . UDP. , . .
,
(scelet). , , .
: .

7.10.2 CORBA C++Builder


CORBA C++Builder . , CORBA
, . 7.8.

, ,

511

, , CORBA,
Remote Data Module Multitier C++Builder. , . 9 12.
, . Y.8.
CORBA IDL, . 7.8.
CORBA CORBA Object Implementation Multitier C++Builder.
CORBA CORBA . IDL,
.
CORBA, , Windows,
(Start), Borland C++Builder 6 | VisiBroker.
CORBA Borland\Vbroker\Bin.
, , (, ) VisiBroker
Smart Agent. ( OSAGENT.EXE, -).
VisiBroker Smart Agent , .
.
IDL. irep.exe ( ), Borland\Vbraker\Bin.
IDL. :
Irep.exe Projectl Project].. idl


VisiBroker Smart Finder, .
CORBA . , IDL, . ,
CORBA, .


C++Builder
Windows, . C+H-Builder.

8.1 - CLX
C++Builder 6 - ,
Windows, Linux. , , . ,
Linux, C++Builder 6,
Kylix, ,

Linux. , Kylix , , ,
, C++Builder 6
Kylix . CLX VCL, .
C++Builder 6 ,
Windows, , ,
Windows, Linux. , , ,
C++Builder, , , Solaris. , Borland
, , C++Builder 6 Delphi 6.
2.3.2.2 Windows. - , CLX. file | New | CLX Application
New Items New CLX Application.
, Windows, .
, Standard VCL - CLX .
, CLX , VCL. , C++Builder . CLX . 8.1.
. 2.1, , , VCL, CLX .
, , Quick
Reports. ADO BDE, Linux.
dbExpress.

514

8.1. CLX
Standard

, . VCL.

Additional

, . VCL ++ilder 5, Timer PaintBox, VCL System, LCDNumber, VCL. . , Additional C++Builder 6,
CLX .

Common Controls , Win32


VCL, . TextViewer TextBrowser
HTML, IconView
, SpinEdit,
VCL Samples.
Dota Access

. VCL, .

Dota Controls

. VCL, .

dbExpress i

dbExpress.
VCL, .

Interbase

InterBase. VCL, .

WebServices

Web, Web SOAP.


VCL, .

InternetExpress

InternetExpress
Web .

Internet

Web.
VCL, .

WebSnap

Web,
, . VCL.

Dialogs

, . VCL, .

IndyClients

Internet Direct (Indy),


Delphi, C++Builder, Kylix.

IndyServers

Internet Direct (Indy).

IndyMisk

Internet Direct (Indy).

, - , C++Builder.
.

C++Builder

515

, , Style () Application. TAppIicationStyle, .


,
, DefaultStyle. dsWindows, dsMotif, dsMotifPlus, dsCDE,
dsQtSGI, dsPlatinum, dsSystemDefault.
, .
CLX, , ListBox, . . 8.1 .
Edit, ComboBox, CheckBox, RadioGroup, ListBox.
Button SpinEdit. CLX: LCDNumber, TextBrowser IconView.
. 8.1
CLX :
dsWindows (a). dsQtSGI (). dsPlatinum ()


'

s [1

CMUoal

LCDMuafcai

T
<*!2
$ || 1
'

-:
.' '
.

t


'

i #| *

LCDNumber, , Value.
, , , . -

516

, .
TextBrowser HTML, . , , , , ..
Text Viewer, . FileName ,
Text.
IconView .
Items,
, . ImageList, Images.
, ListBox
( Items) , :
dsWindows
dsMotif
dsMotifPlus
dsCDE
dsQtSGI
dsPlatinum
dsSystemDefault

OnClick ListBox:
switch (ListBoxl->ItemIndex)
i
case 0: Application->Style->DefaultStyle
break;
case 1: Application->Style->DefaultStyle
break;
case 2: Application->Style->DefaultStyle
break;
case 3: Application->Style->DeaultStyle
break;
case 4: Application->Style->DefaultStyle
break;
case 5: Application->Style->DefaultStyle
break;
case 6: Application->Style->DefaultStyle
)

= dsWindows;
= dsMotif;
- dsMotifPlus;
= dsCDE;
= dsQtSGI;
= dsPlatinum;
= dsSystemDefault;

,
(. . 8.1). , , ,
.
CLX Windows . CLX . , TWinControl CLX TWidgetControl. : TScrollingWinControl
TScrollingWidget.
. CLX
(, Caption) WideString,
VCL AnsiString.
AnsiString .
Linux, Windows, .

.

C++Builder

517

, , COM, ActiveX, OLE, BDE, ADO Windows Linux . Linux Messaging Application Programming Interface (MAPI), Windows. Windows Qt.
API Windows Qt Linux. Windows BSD.
CLX DataSnap, Internet Express, Web Services
(SOAP), WebSnap.
DLL Windows Linux ( .so), , (position-independent code PIC). , DLL. He
, , .
,
Delphi Windows CLX .
, - .

8.2
, . . C++Builder .
. ,
, . Edit
, ,
.. , . , Enter . , , .
Edit. OnKeyPress
S e t <char, '0 ' ,
9 > Dig;
if
( ! (Dig ' 0 ' << ' 1 ' << ' 2 ' << ' 3 ' << ' 4 ' << ' 5 '
<<; ' 6 ' << ' 7 ' < < ' 8' < < ' 9 ' ) . C o n t a i n s (Key)

Key = 0;

OnKeyDown :
if (Key =- VK_RETURN)
FindNextControl(
(TWinControl * ) S e n d e r ,

true, true, false)->SetFocus();

, . 5.3.2.2,
, , , ,
Enter .
( Text) .
,
. , ,
Component | Create Component Template ( ). Component Template Information (. 8.2)

518

( ), ,
. . 8.1
EditNum. , . (
. 8.2)
.
( Change). , ,
.bmp 24 24. . 6.1.2.2
, . . 8.2 ,
. 6.1.2.2. .
. ,
.
. 8.2

?!.
Component & [EditNum
Eatettepage
Palette loon-

{
|5"~|

Change.

Cancel


. , ,
.
, ,
OnKeyDown OnKeyPress,
, .
, . ,
. ,
OnKeyDown OnKeyPress
. , , ,
.
, .
, , , , . ,
. ,

, 2.6. , .
. ActionList , . , . Hint
, , .
ImageList

519

C++Builder

. MainMenu ToolBar
.
StatusBar
ApplicationEvents .
.
.
. , , , . 4.
, ,
, Component | Creote Component Templote
.
! ,
, . . . .
,
, - .
, . Component |
Configure Palette. Polette C++Builder (. 8.3).
( Delete) , ,
( Rename) , ( Add), .
. 8.3

Hetneltxptess
Hetnel
WebSnsp
FestNel
Decsio
i n Cube
ORepoli
Dteo
l gs
Win3.l

Samples
ActiveX
COM*
S
IndfCtei*

8.3

8.3.1
, , ,
8.2 .
, - C++Builder

520

, ,
, .. , , . .
.
: , (, ,
), (,
, )
. , , . ,
.
TEdit
TEditLetNum. , , TEdit, : EnableNum EnableLet.
bool. ,
- , . , EnableNum = true EnableLet = true, .
EnableNum = true, a EnableLet = false, ,
. EnableNum = false, a EnableLet = true, ,
. , EnableNum false EnableLet = false,
, .
Clear
Modified, ,
. OnClear.
, , , . . 6.1.2.4.
C++Builder . ,
, ,
(, ).
File | Close All. :
1. File | New | Other New Items
New Package .
(Package Manager), . 8.4.
Contains , Requires , .
. 8.4
,

Compile

Options

Remove

Fles

31.


3 My res
Q Requires

"

Path
F \Tests\MyComponenE
F \Tests\MyComponent

521

C++Builder

2.
3.

.dpk,
File | Save As Sove , .
Add (), ,
(Add Unit), (New Component) ActiveX
(Import ActiveX). . ,
, . 8.5. ( TEdit StdCtrls Ancestor type), Class Name ( TEditLetNum),
(Palette Page), . , .
( Unit file name).

. 8.5

JSJ
Componenl i import ActiveX J
ae. JTEdit [StdCtris]

Ca
l ss Na JTEriLetNur
PeieliaPage |

_^j

yrut fie name JF "u'estt\MiComponent\E ALetNum CDP~

Sedipalh (|.|>||1<||( J|BCBo|9

4.

OK , . .dcr ,
.
5. Install () . .
, , .
(File | Save).
. ,
Compile (). .
.
1. Component | New Component ,
, New Component.
2. , Install () (. 8.6) : Into
existing package ( ) into new packoge ( ). , -

522

, Into new package. : File ... will be build then installed. Continue?
( ... , . ?). , ,
. (. 8.4).
. 8.6

Into enslrie package Into new package j


1 @enms |F KTesslSMyComponenftMy bpk
i $1: |

Cancel

. - , ,
Remove.
:
1. Project | Options kages.
2. , ,
Remove.
, .

. ,
. 6.1.2.4, . 6, ,
.

8.3.2
, , .
EditLetNum.h:
ifndef EditLetNumH
define EditLetNumH
include
include
include
include
include

OysUtils .hpp>
<Controls.hpp>
Classes.hpp>
<Forms.hpp>
OtdCtrls .hpp>

class PACKAGE TEditLetNum : public TEdit


private:
protected:
public:
fastcall TEditLetNum(TComponent* Owner);
published:

C++Builder

523

/ /

, _

#endif

EditLetNum.cpp:
#include <vcl.h>
#pragma hdrstop
include "EditLetNum.h"
pragma package(smart_init)
//
//
//
//
//

ValidCtrCheck is used to assure


that the components created do not have
any pure virtual functions.
( ValidCtrCheck ,
)

static inline void ValidCtrCheck{TEditLetNum *)


new TEditLetNum(NULL);
i
fastcall TEditLetNum::TEditLetNum(TComponent* Owner) : TEdit(Owner)
//
namespace Editletnum
{
void
fastcall PACKAGE Register()
{
TComponentClass c l a s s e s [ 1 ] = {
classid(TEditLetNum)
R e g i s t e r C o m p o n e n t s ( " ", c l a s s e s , 0 ) ;

, . EditLetNum.cpp : ValidCtrCheck,
TEditLetNum Register. ValidCtrCheck , , . TEditLetNum . . Register,
, .
namespace.
namespace .
, .
, .
Register classes TComponentClass . (
TEdit2), ,
:
TComponentClass

classes[2]

classid{TEditLetNum),
c l a s s i d (TEdit2));

RegisterComponents , classes ( )
( ). .

524

EditLetNum.h. private, protected, public published. , :


private
()
protected
()
public ()
published
()

, , .
, , .
.

C++Builder,

.

(. 1.2 1) (
) , .
. . , , ,
.

8.3.3
. private .
protected ,
.
, F'. ,
private :
class

PACKAGE TEditLetNum

p u b l i c TEdit

private:

// -
bool FEnableNum;
bool FEnableLet;
bool FModified;

. :
p r o p e r t y <> <> = (read=<HMH >
write=<MMH >
<
>;

read write , ,
.
read , . , , .
Get,
.

C++Builder

525

write , . , . Set, .
write ,
.
,
.dfm.
default = >
. . , , .
, :
public:
fastcall TEditLetNum(TComponent* Owner);
//
property bool Modified = (read=FModified, default=false);
published:
// ,
property bool EnableLet = {read=FEnableLet,
write=SetEnableLet,
default=true);
property bool EnableNum - {read=FEnableNura,
write=SetEnableNum,
default-true);

Modified public,
. EnableNum EnableLet published, .
EnableNum EnableLet .
SetEnableNum SetEnableLet .
, ,
false. ,
.
Modified , .

, private ,
. , . .
EditLetNum.h:
class PACKAGE TEditLetNum : public TEdit
{
private:
// -
bool FEnableLet;
bool FEnableNum;
bool FModified;
protected:
//
void
fastcall SetEnableLet {bool AEnableLet);
void
fastcall SetEnableNum{bool AEnableNura);

526

'
public:
//
fastcall TEditLetNum(TComponent* Owner);
// .
property bool Modified = {read-FModified, default=false);
published:
// ,
property bool EnableLet = (read=FEnableLet,
write=SetEnableLet,
default=true);
property bool EnableNum = {read=FEnableNum,
write=SetEnableNum,
default=true);

EditLetNum.cpp:
static inline void ValidCtrCheck(TEditLetNum *)
(
new TEditLetNum(NULL);
fastcall TEditLetNum::TEditLetNum(TComponent* Owner)
: TEdit(Owner)
(
FEnableLet = true;
FEnableNum = true;
FModified = false;
namespace Editletnura
(
void
fastcall PACKAGE Register()
(
TComponentClass c l a s s e s [ 1 ] = { classid{TEditLetNum));
RegisterComponents{"MyComponents" , c l a s s e s , 0) ;
i
)
/ /

_ _ _ _ _ _ _

void
fastcall TEditLetNum::SetEnableNura(bool AEnableNum)
(
// FEnableNum
FEnableNum = AEnableNum;
// FEnableNum FEnableLet = false,
// FEnableLet true
if (! AEnableNum)
if (! FEnableLet) FEnableLet = true;

1
//
void
fastcall TEditLetNum::SetEnableLet(bool AEnableLet)
{
// FEnableLet
FEnableLet = AEnableLet;
// FEnableNum FEnableLet = false,
// FEnableNum true
if (! AEnableLet)
if (! FEnableNum) FEnableNum - true;

C++Builder

527

, ,
, false, . false,
true.
protected. ,
,
.
public TEditLetNum, . , .
, (
Compile . 8.4) . , - .
. ( File | Open) , - .
- (, Test).
( Project | Make All Projects). ,
.
EnableNum EnableLet.
true. false. , .
Modified ,
.

8.3.4
public,
.
TEditLetNum, . Clear,
FModified false. OnClear . TEdit Clear, , , Clear FModified.
, Clear -, C++Builder . TCustomEdit :
virtual void

fastcall Clear(void);

, Clear :
c l a s s PACKAGE TEditLetNum

p u b l i c TEdit

public:
virtual

void

void

fastcall

fastcall

Clear(void);

TEditLetNum::Clear(void)

528

8
TEdit::Clear();
FModified = false;
)

//

,
( TEdit), .
, , :
void
fastcall TEditLetNum::Clear(void)
{
Text = "";
FModified = false;
)

, : , . .
OnKeyPress. , (.. ) TEdit. , , On. To OnKeyPress
KeyPress. , , , Sender. , OnKeyPress , ,
:
{TObject Sender,

char SKey)

: char &Key.
, -, C++Builder. ,
KeyPress TWinControl :
DYNAMIC void

fastcall KeyPress(char SKey);

-. , DYNAMIC,
:
[C++ E r r o r ] E d i t L e t N u m . h ( 2 4 ) :
T E d i t L e t N u m : : K e y P r e s s ( c h a r &)'

2113 V i r t u a l f u n c t i o n ' _ f a s t c a l l
c o n f l i c t s w i t h base c l a s s 'TWinControl'

, KeyPress, TWinControl. .
,
protected
:
void
fastcall TEditLetNum::KeyPress(char SKey)
(
Set <char, '0', '9"> Dig;
Dig << '0' '1' << '2' '3' '4' '5'
<< '6' '7' << '8' '9';
if ((! FEnableNum) ss (Dig.Contains(Key)))
Key = 0;
if ((! FEnableLet) && !(Dig.Contains(Key)))
Key = 0;
if (Key != 0) FModified = true;
TEdit::KeyPress(Key);

C++Builder

529

. , true FModified. KeyPress .


( Compile . 8.4.) .
(. . 2.3.3), My.bpl Test. . 8.7. EditLetNum, Button Clear ( Clear), Label, Modified
EditLetNuml, TCheckBox. ( CBNum CBLet) .
.
. 8.7

|1

Clear

Modified - hue

OnCreate :
void
fastcall TForml::FormCreate(TObject *Sender)
{
if (EditLetNuml->Modified)
Labell->Caption = "Modified true";
else Labell->Caption = "Modified - false";

Label 1
Modified.
OnKeyUp EditLetNum :
FormCreate(Sender);

OnCreate
Modified.
OnClick CBNum :
EditLetNuml->EnableNum = CBNum->Checked;
CBLet->Checked = EditLetNuml->EnableLet;
EditLetNuml->SetFocus();

EnableNum CBNum. CBLet EnableLet.


, , , false Num, EnableLet false,
EditLetNuml EnableLet true. , CBLet.
OnClick CBLet:
EditLetNuml->EnableLet = CBLet->Checked;
CBNum->Checked = EditLetNuml->EnableNum;
EditLetNuml->SetFocus();

OnClick Clear :
EditLetNuml->Clear;
ForraCreate(Sender);

530

Clear Modified.
. EnableNum EnableLet , CBNum CBLet . (. . 2.3.3), .
EnableNum EnableLet.
- ,
- . Windows 2000/ NT . Windows 95/98 <>
. , , .
, : Cannot debug project unless a host application is defined. Use Run | Parameters...
dialog box. , Run | Parameters . , .
, . 8.8. .
Browse. Load
.
Run | Run (F9|. , , . 8.8, .
, Windows 2000/ NT . - .
. 8.8

Local |Remote]
f Hast&jplqation
|FATetts4MyComponer*\Tesi

arametet*
1

EKeaite static code on Load


load

Cancel

8.3.5
OnClear,
Clear. C++Builder
, . , TComponent ( this),
TNotifyEvent. C++Builder Click ,
TObject *Sender. OnClear.
:
private:
^TNotifyEvent FOnClear;

C++Builder

531

published:
property TNotifyEvent OnClear = (read=FOnClear, write=FOnClear);

FOnClear TNotifyEvent,
. , .
read write , .
,
. , , ,
true, .
Clear :
if

(OnClear)

OnClear ( t h i s ) ;

OnClear.
, , EditLetNuml
. ,
OnClear.
:
void

fastcall

TForml::EditLetNumlClear(TObject

*Sender)

- ,
, :
ShowMessage(" OnClear") ;

.
TNotifyEvent.
. CanClear, true,
.
false,
.
, . closure. , ,
TClear.
:
typedef void

fastcall
(
closure *TClear)
(System::TObject *Sender,

boolS CanClear);

, : Sender
CanClear, .

. , :
private:
TClear FOnClear;
property TClear OnClear = {read=FOnClear, write=FOnClear) ;

Clear ,

CanClear:
void

f a s t c a l l TEditLetNum::Clear ()

532

bool CanClear = true;


if (OnClear) OnClear(this,CanClear);
if (CanClear)
{
TEdit::Clear();
//
FModified = false;

CanClear. ^
CanCIose
. CanCIose *
OnClear.
i
.
.
BditLetNum.h:
//
typedef void
fastcall ( closure *TClear)
(System::TObject *Sender, bools CanClear);
class PACKAGE TEditLetNum : public TEdit
{
private:
// -
bool FEnableLet;
bool FEnableNum;
bool FModified;
TClear FOnClear;
protected:
//
void
fastcall SetEnableLet(bool AEnableLet);
void
fastcall SetEnableNum(bool AEnableNum);
// KeyPress
DYNAMIC void
fastcall KeyPress (char SKey);
public:
//
fastcall TEditLetNum(TComponent* Owner);
// Clear
virtual void
fastcall Clear(void);
//
property bool Modified = fread=FModified, default=false);
published:
// ,
property bool EnableLet - (read-FEnableLet, write=SetEnableLet,
default=true};
property bool EnableNum = {read=FEnableNum, write=SetEnableNum,
default=true};
property TClear OnClear = {read=FOnClear, write=FOnClear);

BditLetNum.cpp:
s t a t i c i n l i n e void ValidCtrChec^(TEditLetNum
(
new TEditLetNum(NULL);
} '
//

*)

C++Builder

533

f a s t c a l l TEditLetNum::TEditLetNum(TComponent* Owner) : TEdit (Owner)'

I"

FEnableLet = true;
FEnableNum = true;
FModified = false;
}

namespace Editletnum
{
void
fastcall PACKAGE Register!)
(
TComponentClass classes[1] = { classid(TEditLetNum));
RegisterComponents(" ", classes, 0 ) ;
}
}
//
void
fastcall TEditLetNura::SetEnableNum(bool AEnableNum)
{
// FEnableNum
FEnableNum - AEnableNum;
// FEnableNum FEnableLet = false,
// FEnableLet true
if (! AEnableNum)
if (! FEnableLet) FEnableLet = true;
}
//
void
fastcall TEditLetNum::SetEnableLet(bool AEnableLet)
{
// FEnableLet
FEnableLet = AEnableLet;
// FEnableNum FEnableLet = false,
// FEnableNum true
if (! AEnableLet)
if (! FEnableNum) FEnableNum - true;
}
//

,_

void
fastcall TEditLetNum::Clear(void)
{
bool CanClear = true;
if (OnClear) OnClear(this,CanClear);
if (CanClear)
(
TEdit::Clear();
//
FModified = false;
}
}
//
void
fastcall TEditLetNum::KeyPress(char SKey)
{
Set <char, '0', '9'> Dig;
Dig << '0' << '1' << '2' '3' << '4' << '5'
<< '6' << '7' << '8' '9';
if ((! FEnableNum) && (Dig.Contains(Key)))
Key = 0;
if ((! FEnableLet) SS !(Dig.Contains(Key)))
Key = 0;
if (Key != 0) FModified = true;
TEdit::KeyPress(Key);

534

. .
. 8.8. CheckBox ( CBClear), -.
. CanClear
OnClear.
OnClear, , CBClear, ( Checked). , , .
. OnClear . ,
,
:
void

fastcall TForrnl : : EditLetNumlClear (TObj ect *Sender,


bool SCanClear)

(
ShowMessage(" OnClear");
CanClear - CBClear->Checked;
EditLetNuml->SetFocus();
}

CanClear, , , CBClear.
. ;
EnableNum EnableLet CBNum CBLet.
, , EnableNum true, a EnableLet false, - .
CBNum ( Checked = true), CBLet ;
.
.
i

8.3.6

, ^
. C++Builder 5, , -
. ^
ClassExplorer (. . 2.7.2). . ^
, :
(. 8.3.1), , TEditLetNum2. I*
, , .
!-i
, View |
ClassExplorer. ClassExplorer . !
: New Field ( ), New)!
Property ( ), New Method ( ). Ne4
Property EnableLefcLi
. New Property ;
, . 8.9. Property
Name EnableLet.
bool. Add to Closs +i
, , . ^
Visibility : public, private, protected pull-]
lished. published.

--Builder
. 8.9

535
1!:=
>
;
|||!||||||[1
Pcopty: |EnableLet
AddloOass- |*jTEdLNum2
IPO* (bod
'. Psite

Ptsate

Piojecled

( Putished

JJ cieatefiet method
3] F create Set melhod
ai6i:|SetErv*teLel
* Imfitement Set using mrefcei
' 17 ctealJieM:|FEnSieLet
p usolhtHatdlotlheleadpec*
: 17 use IW> field toimplemenlng the Sel method

create field
(private) , .
'F'.
, , .
. use this field for the reod specifier ( create
field), .
create Get method. (private) . use this field for the read specifier
use this field for implementing the Get method . ,
, .
,
- () Reads.
. . 8.9
.
.
use this field for the read specifier.
.
, create field, use this
field for the write specifier ( . 8.9 , ), . create Set method,
(private) . , ,
use this field for the write specifier use this field for implementing the Set method
.
,
, . ,
- ()

536

Writes. , .

Reads Writes,
Implement in , , ,
. ,
.
creote Get method create Set method, Implement Get using member Implement Set using member. ,
- - .
creote Set method use
this field for implementing the Set method.
Array . Index
. Stored
. Default
default.
, . 8.9 ,
Apply .
, .
.
:
c l a s s PACKAGE TEditLetNum2 : public TEdit
{
private:

bool FEnableLet;
void
fastcall SetEnableLet(bool value);
protected:
public:
fastcall TEditLetNum2(TComponent* Owner);
published:
property bool EnableLet = ( read=FEnableLet, write=SetEnableLet,
default-true };
);

, , ,
. ,
private, protected. ,
protected .
:
void
(

f a s t c a l l TEditLetNum::SetEnableLet(bool value)

if(FEnableLet != value) {
FEnableLet = value;


. ,
.
, 8.9
use this field for implementing the Set method.
, :

C++Builder
void

537

fastcall TEditLetNum2::SetEnableLet(bool value)

//TODO: Add your source code here

, , To-Do list (. 2.4.4.1).


To-Do List,
SetEnableLet.
ClassExplorer New
Method ( ).
Clear. New Method ,
. 8.10.
. 8.10

Iliiiiilsi

Method JJwe-jOear
AddloGlBsl^TEdilLelNurfi

igurnent*: J
Comtfuctor eStmctGt

< function

| FwcfanBo* M
ff

ftibfc

Prwate

Pijlected

Pubtehed

Declivet ! abslrad )

ret
mill

i Msssage Harrier
taptomertafon dstails

|
-

He: F;\T*t!\MsComponen duUlNumZcpp


Reset |

Cancel |

Applj

Method Name Clear. Add to Class


, , . Arguments
, . Method Type : Function , Constructor ,
Destructor .
Function,
Function Result,
( void). ,
.
Constructor Destructor, Method
Nome
.
Visibility : public, private, protected
published.
Directives
. . Message Handler, , Windows, ,
Windows, . ,
Message Handler, 7.4.3.

538

Implementation details
. Call inherited . Inline inline . Implicit
Inline. ,
inline,
. Implicit Inline, . , , , , .
, . , . 8.10, :
c l a s s PACKAGE TEditLetNum2 : p u b l i c TEdit
(
public:
v i r t u a l void

fastcall Clear));

};

:
void
f a s t c a l l TEditLetNum2::Clear()
(
TEdit: : Clear () ;
}

, .
. 8.10 Call inherited.
, :
//TODO: Add your source code here

To-Do List (. 2.4.4.1). To-Do List,


.
. 8.10.
FProtect void Inline, Implicit Inline,
protected
v o i d i n l i n e F P r o t e c t (),

:
void inline TEditLetNum2::FProtect ()
(
//TODO: Add your source code here
}

.. ,
. Implicit Inline,
protected :
protected:
void FProtect()
(
//TODO: Add your source code here
)

, , .

C++Builder

539

New Property New Method


ClassExplorer. New Field .
, .
ClassExplorer , , C++Builder , .

8.4 DLL
8.4,1 DLL
DLL
. DLL
.,
. ,
, ..,
. . DLL,
. DLL ,
, . DLL ,
, , ,
.
DLL.
, DLL API Windows, , C++Builder, API Windows.
DLL Windows, , ,
. DLL . 7. DLL , , , .
DLL , .
,
. , . , ,
, , .
, . DLL,
.
DLL . , , , .. : , , .
, ,
.
DLL ,
, . ,
, Object Pascal, Visual Basic,
Access Basic . , C++Builder, , DLL, ,
.

540

8.4.2 DLL

DLL :
.
, DLL , , .
DLL. , DLL, .
(
DLL) , DLL. , , , DLL.
DLL, .. DLL.
.
, DLL , , , - , .
, DLL
(import library file).
, DLL, .lib. .lib
.
,
DLL , - . . .
, , .
, - .
, , LoadLibrary API Windows. GetProcAddress .
. FreeLibrary
. , , mydll.dll, char * MyFuiiction(char *). DLL :
// DLL
HINSTANCE dlllnstance = LoadLibrary("mydll.dll");

, , :
//
typedef char ( import * FType(char * ) ) ;
FType * MyFunc;
MyFunc = (FType * ) G e t P r o c A d d r e s s ( d l l l n s t a n c e , " _ M y F u n c t i o n " ) ;

*
I

typedef FType (
, ?
. *"':
MyFunc. )"
API Windows GetProcAddress. ^
DLL , ',
.
. FType.
i;

C++Builder

541

:
//
char * S = MyFunc("! " ) ;

DLL ,
:
// DLL
FreeLibrary(dlllnstance) ;

, . , .

8.4.3 DLL
DLL File | New | Other New Items New DLL Wizard DLL.
, . 8.11. DLL C++. Use VCL
DLL, VCL.
VCL.h , VCL. Multi Threaded () . VC++ Style DLL
DLL Microsoft Visual C++.
. 8.11
DLL

Source Type

<~

; <* '&

VC.*itjfcOLI.

OK

,
( , . 7.13) :
include <vcl.h>
include <windows.h>
pragma hdrstop
// .
// Important note about DLL memory management when your DLL
// uses the static version of the RunTime Library:
//
//
//
//
//
//
//
//
//
//

If your DLL exports any functions that pass String objects


(or structs/ classes containing nested Strings) as parameter or
function results, you will need to add the library MEMMGR.LIB to both
the DLL project and any other projects that use the DLL. You will
also need to use MEMMGR.LIB if any other projects which use the DLL
will be perfomring new or delete operations on any non-TObject-derived
classes which are exported from the DLL. Adding MEMMGR.LIB to your
project will change the DLL and its calling EXE's to use the
BORLNDMM.DLL as their memory manager. In these cases, the file
BORLNDMM.DLL should be deployed along with your DLL.

// To avoid using BORLNDMM.DLL, pass string information vsing


// "char *" or ShortString parameters.
// If your DLL uses the dynamic version of the RTL, you do not
// need to explicitly add MEMMGR.LIB as this will be done
// implicitly for you

542

8
( : DLL,
DLL
RunTime Library:
DLL - ,

String ( ,
), MEMMGR.LIB DLL,
, DLL.
MEMMGR. LIB , (new)
(delete) DLL ,
TObject. MEMMGR.LIB DLL
,
BORLNDMM.DLL - .
BORLNDMM. DLL DLL.
BORLNDMM.DLL,
"char *" ShortString.
DLL RTL,
MEMMGR.LIB,
.)
it

tpragma argsused
int WINAPI DllEntryPointfHINSTANCE hinst, unsigned long reason,
void* lpReserved)
(
return 1;
)

, .
,
(char * ) , , , AnsiString. , DLL ,
borlndmm.dll.
, DLL , char, .
:
. , : , .
:
AnsiString Code(AnsiString s, char Key)
(
for (int i = 1; i <- s.Length)); i++)
s [ i ] s [ i ] Key;
return s;
}

DLL :
char * Code(char *s, char Key)
(
for (int i = 0; ; i++)
(
if (s[i] == '\0') break;
s[i] = s[i] " Key;
)
return s;
}

, Hi
DLL.

--Builder

543

DLL
include <vcl.h>

vcl.h. , - , , ,
. DLL.
DLL DHEntryPoint, .
hinst DLL. , ,
Loadlcon, LoadCursor .
hinst .
DLL,
DLL MyDLL
Code. .
1. File | New | Other New Items
New DLL Wizord. , . 8.11. ,
.
2. .
3. :
i n c l u d e "UMyDLL.h"

4.
5.

UMyDLL.h , .
DHEntryPoint
Code.
UMyDLL MyDLL.
MyDLL.cpp :
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//
#pragma argsused
((include "UMyDLL.h"

int WINAPI DHEntryPoint (HINSTANCE hinst, unsigned long reason, void*)


(
return 1;
}
//
char * Code_Dec(char *s, char Key)
{
for (int i = 0; ; i++)
{
if
(s[i] ~
s[i] = s[i]
)
return

' \ 0 ' ) break;


Key;

s;

6.
7.

.
File | New | Other New Items
New Header File. ,
.
:
jfifndef _UMYDLL_H
d e f i n e UMYDLL H

544

8
#ifdef
DLL
# define DLL_EI
else
# define DLL_EI
#endif

declspec(dllexport)
declspec(dlliraport)

extern "C" char * DLL_EI Code_Dec(char *s, char Key);


#endif
File | Save UMyDLL.h.
.
, #ifdef.
DLL_EI . : DLL ,
DLL_EI
declspec(dllexport); DLL

, DLL_EI
declspec(dllimportb
C++Builder DLL , DLL.
. , , .
, -. .
Code_Dec,
extern "" char *
declspec(dllexport) Code_Dec(char *s, char Key);

declspec(dllexport) , , . DLL, -1
. *
DLL -,
. .
, .*
:
extern "" char *
declspec(dllimport) Code_Dec(char *s, char Key)j

declspec(dllimport) , , DLL.
DLL, , -1
DLL.
DLL.
9. Project | Options '^v^,
, Generate import library. .'1
DLL .lib, ^-,
DLL .
'
10. Project | Build MyDLL .~'|
MyDLL.dll MyDLL.lib.
DLL ?
Run (F9), : Cannot debug project unless a host application :
defined. Use Run | Parameters... dialog box. , n<>M:-i
Run | Parameters . ::> (. 8.3.4, . 8.8).
8.

OH-Builder

545

3.4.4 DLL
DLL, . 8.4.3, , DLL.
DLL . . , DLL
. .
1. View | Project Manager. , . 8.12,
MyDLL.
2. New New
Application.
, .
3. File | Sove Project As -
(, PTestDLL).
4. ,
Save Project Group As.
, , TestDLL.
. 8.12
DLL

3
New

zl

JMjCLLdl

X
Remove

Q
Activate

Path
- agt TESTDLL

-, 1 MyDLL
J MyDLLies
. 3 MjCLLbpl
UMjCIcpp
) PTestDLL rat
3 PTestDLL cpp
* ! j UTESTDLLCPP

5.

F:\Tests\DLL
F:Uests\DLL
RVTestsSDLL
F:\Tests\DLL
FATeslsSDa
F:\Tests\DLL
FATestsSDLL
RMestsVDLL
F:\Tests\DLL

(. 8.13).
, , :
Editl->Text - Code_Dec(Editl->Text.c_str , '');

, Editl, Code_Dec Editl.


. 8.13
DLL:
()
()

a) E s s E a s m t t :

jsji<j

i [

/ |

6.

6) {

! / )

#pragma hdrstop , :
# i n c l u d e "UMyDLL.h"

)
'

.lib, .
18 C++Buildf 6

546

. : ,
Activote (. . 8.12). Add. Library file {.lib) MyDLL.lib.
.
. ,
. . 8.13.
- . (. 8.13 6) , . . (. 8.13 ) () .
. New
New Application.
, .
File | Save Project As - (, PTestDLL2) , DLL.
,
. 8.14. ( BLoad)
DLL, ( BFree) , / ( Buttonl) , .
. 8.14

DLL

|
! / !]

:
class TForml : public TForm
private: // User declarations
// DLL
HINSTANCE dlllnstance;
//
typedef char ( import * FTypefchar *, char));
FType * C_D;

dlllnstance DLL.
FType Code_Dec, . C_D .
.
void
(

fastcall

TForml::BLoadClick(TObject

// DLL
dlllnstance - LoadLibrary("MyDLL.dll") ;

*Sender)

C++Builder

'

547

if (dlllnstance)
//
C_D = (FType *)GetProcAddress(dlllnstance, "_Code_Dec");
else ShowMessage("He 'MyDLL.dll'"!;

void
fastcall TForml::ButtonlClick(TObject *Sender!
{
if (C_D)
Editl->Text = C_D(Editl->Text.c_str(),'A');
else ShowMessage(
" 'Code_Dec' 'MyDLL.dll' ");
)
//
void
f a s t c a l l TForral::BFreeClick(TObject *Sender)
{
// DLL
FreeLibrary(dlllnstance);
C_D = NULL;
}

BLoadCIick Loadlibrary, . 8.4.2. , , , , Windows (SYSTEM32 Windows NT/2000/XP), Windows , , , PATH. , , DLL .
, , .
( ), dlllnstance NULL. 'MyDLL.dll'.
, GetProcAddress, . 8.4.2,
C_D .
BnttonlClick
C_D. NULL (, , , ButtonlClick ),
.
BFreeCItck FreeLibrary
DLL C_D.
, . , .

8.5
8.5.1
, . .
C++Builder , ., ..
.
, , C++Builder .

S48

C++Builder, -
C++Builder. , ,
.
,
. Borland .
(Packages) DLL, , , .. DLL , . .
.bpl (Borland package library), DLL.
:
.
C++Builder . C++Builder . ; C++Builder.
.

C++Builder. , , , .

C++Builder. C++Builder ,
- .
,
, . ,
, . , 450 25 .
. , ,
.
:
, ;
.

.
, . .
:
,
.

8.5.2
, , .
.
Project | Options
Project Options Packages . . 8.15.

C++Builder

549

8.15
Packages

Forms j Applcatcn ) Compe


li , j Advanced Compe
lir j C++
Pascal i Lhkef ! Advanced Lffiker J Diieclofies/Ccndiionals
Version Info Packages j Tan j CDRBA ] CodeGuad
i
Design
"/ ln!emertDrecHln^)forD6PiopeityarKJCompofienrEditor
/ McfosoilDuHodcViewConttd
/, NetMaslers Fastnel Toois
^ QuckRepoitComponenis
TeeChaft Components

*\

1
^j

; d:\pfogram

fietnove

Edit

RyntiTie packages
|V giJd with runtime pack ages

*d;rtLdbtttadortl;vcklb.vdx,bde[t!,vcldbx;foxpress.dsnap,cd

Default

Design packages . , . 8.15 ,


7.3 (, , ). ( Add)
( Remove ). , . . ,
, ,
. ,
Add.
Edit () , Design packages , . .
Components , .
Build with runtime packages .
,
.
Build with runtime packages .
Default .
Design packages
Runtime packages
. Design
pockages .
, C++Builder .
, ( , ).
, , . C+4-Builder
:
1. . jectl.dpr unitl.cpp.

550

2.
3.

Project | Options.
Project Options Linker
Use dynamic RTL ( ). Pockages Build with runtime packages ( ).
Compiler Release,
(. . 15.9.1, . 15).
4. Project | Build. projectl.exe .
5. , , , Windows Project | Informotion for project. ,
, 451072
(448 ). ,
.
'6. Project | Options, Project Options Linker Use dynamic RTL, Packages Build with runtime packages.
7. , Project | Build (
4).
8. projectl.exe .
25088 (24,5 ).
, :
359936 (351 ), 22528 (22 ), ..
16 . ! , , , .
, DLL
tdump.exe, C++Builder ...\bin. DOS. , DOS ,
Projectl, , :
tdump Projectl.exe > dump.txt

tdump
dump.txt. ,
, ,
Section:

Imports

Import

from vcl60.bpl
fastcall

Consts::initialization()

Imports from rtl60.bpl


fastcall

System::initialization()

Imports from BORLNDMM.DLL


(ord. =
2)
Imports

from KERNEL32.DLL
FreeLibrary

C++Builder

551

Imports from CC3260MT.DLL


operator delete(void *)

DLL, . , . ,
DLL Windows .
, , . VCL60.BPL, ,
, ,
1327104 (1296 1.26 ). , , .
,
,
.
, . ,
25 ,
20 500 . ,
N , N * 500 , VCL60
(1296 + N * 25) . , N = 4 .
, ,
,
. , . , ,
.
, , . ,
. , .


.
.
Profect | Options.
Packages Build with
runtime packages. ' (. 8.15)
Default, .

,
.

10

11

12



9.1
9.1.1
,
, . C+4-Builder
,
, , .

. , , .
, , , , ,
.
(
) , , , , , . ()
- . ,
. . 9.1
Pers, .
. , ,
. 9.2.
9.1. Pers

- -

Num

Dep

Fam

Nam

Par

Year

1950

1960

1955

1961

...

Sex

Charact

Photo

...

...

...

...


. .
,

556

. , , .. , .. ,
( -), , . , . 9.1
Num, Dep, Fam, Nam, Par, Year_b, Sex, Charact, Photo, .
. , , , (, ), ( ) ..
.
, .

.
. .

Fam, Nam Par. , , . Num , , .

. 9.1


. ,
.
- , (
). , . , , .. .
, .
(. . 9.1).
, . , . - . , .. .
. , , .
, . , .
, , , -

557

.. ,
, .
, . ,
.
Dep, , . 9.2.
, : Dep Proisv.
9.2. Dep

Dep

Proisv

'

1
[

, , ,
. , , .
, Pers , Dep
. .
, , , .
9.2.
.
- , . , Dep, Pers, Dep, . .
.
Dep
Pers, Dep
. ,
. 9.2

558

Dep ,
Pers .
. , : Paradox, dBase, Microsoft Access, FoxPro, Oracle, InterBase,
Sybase .
- . , Paradox
dBase . , . Microsoft Access
InterBase ..
. /, , Sybase Microsoft SQL, , SQL (. . 10.1).
, ,
, , .. , ,
. ,
. (alias) , .
. . , , , . , .. . ,
.
.
, , , , .. , ,
, ,
.
, , .
.
, .
- , . .
, ,
.

9.1.2
,
, , -
- , , -.
, , . ,
. , ,
, C++Builder.

559

-
/

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

, .

9.1.2.1
. , ; ,
, . .
,
, . ,
, ,
.
,
,
. , , , , ,
. .
,
.
9.1.2.2 -
- ,
. ,
. , , ,
( ,
, ).
- . ,
. ( ) ,
. , ,
, : ,
, , .
-
. .
, . , , .

560

,
.
, , ,
9.1.2.3 /

/. . . , , .
, , .
/ , , .
9.1.2.4
. ( , C++Builder)
multitier .
, .
:

, .
,
.
,
,
.
, , Oracle Sun. , ,
, , , -.
, (middleware) , , , . .
:

Borland Database Engine (BDE). .

9.1.3 C++Builder
C+4-Builder
Borland Database Engine (BDE) Borland. He . , C++Builder 5, .
C++Builder 6, , , -

561

. ,
C++Builder BDE.
BDE . , . . -H-Builder
BDE.
, . 9.3.
. 9.3

C++Builder

SQL

C++Builder, , BDE
. BDE DLL ( IDAPI01.DLL, IDAPI32.DLL). , , API
(Application Program Interface ),
ID API (Integrated Database Application Program Interface).
, .
BDE . , ,
. BDE , BDE
, . BDE , Microsoft Access, FoxPro, Paradox, dBase.
BDE ,
ODBC. ODBC (Open Database Connectivity) DLL,
BDE, Microsoft. ODBC.DLL. Microsoft ODBC
ODBC , Borland
BDE , ODBC. , ODBC , , BDE. ODBC C++Builder C++Builder - .

52__

BDE SQL ,
SQL-, , Sybase, Microsoft SQL,
Oracle, Interbase.
/ .
C++Builder 5
, BDE. Microsoft ActiveX
Data Objects (ADO). ADO , , ,
, . OLE DB.
ADO ( , ),
BDE. , ADO C++Builder , BDE. BDE. ADO . 10, . 10.4.
Interbase
C++Builder 5 InterBase Express (IBX). C++Builder 5 InterBase,
InterBase, BDE. InterBase,
BDE. . 10, . 10.5.
C++Builder 6 dbExpress. ,
SQL . dbExpress
DLL
, , , . ..
dbExpress . 10, . 10.6.

9.2
Database Desktop
9.2.1
, ,
. C++Builder ,
, . Pers
Dep, . 9.1 9.2
,
, .
. . '
BDE C++Builder Database Desktop ( DBD.EXE
16- , DBD32.EXE 32- ,
DBDLOCAL.EXE ),
, .
Database Desktop C++Builder
Tools. ,
Tools | Configure Tools (. . 15.3, . 15). Database Desktop.
, . 9.4 ( Database Desktop
- ,
).

563

Jfll^

..

. 9.4

Database Desktop

Be -*' " S^ ct 1 ' I * Bindew Ueto

Year ' Sejd


1WTraei~I
1960 Tni
laoSTi
ISM
lSMe+
1955
True,
faasa
fesn

1*1 M s
& ;
EMffltt
1930 True;
[eeft.)3a J f f i j i feIeHJ*
^a4JSl 'Mas* + ! 1930 Tri
i
1937
Tn
ABeriTS ' 5-|la jell
~ ; 1975 Tuu
I 1S65 Fals
AoMi
Afi* AfMfila
1
64 *- 1962 True

\ PERS Ni,ri
Dep
Fam ' Nm Par
1 Atstmiii't ,a\ earn-'
2 0561
3,085 2
4.0561
SAo6SSfoi;e

e;08s2
, 7|0Sei

0
9'Ad6Sas&aa&v

10;0ao2

i H

P.KO-d 1 of 11

Database Desktop
Paradox 7. Paradox 7 ,
.db.
Windows, , . File | New Database Desktop. ,
:
QBE Query

SQL File

SQL

Table

Table. . , . , , Paradox 7. , . 9.5.


( ),
, ,
.
. 9.5

Paradox 7

:
^ '
Field Name
, 1>Num
' 2;Dep
3s Fam
- A\Ham
- 5 ; ?ar
' rise
- SjCtiaract

Type

rabtefiioperties
Size Key'. , Vafatty Checks

A '
A
A '
" A

s
I
M'
G

is'
2020'
20'

1 Rqu<l

20

3. Maxrnum value"
1385

jj

j. Minimum value'
131?

t Debjl value:
1350
5. Piclute:

Entei the irexmum vekie atoned fa thit Md


I

AssisJ... j

Pa* Table
|

Save

Savefes

Corc-ti I ^ _ j




(Size)

565

1-240

Memo

. .mb.

,
. Memo Paradox
C++Builder.

0-240

Formatted
Memo


. .mb.
, . Formatted Memo Paradox C++Builder.

Graphic


.bmp, .pcx, .tif, .gif .eps. Database
Desktop
.BMP. Graphic Paradox
C++Builder.

OLE

OLE , , . Database Desktop


. OLE Paradox
C++Builder.

Logical

. true false.
.

Autoincrement
1 . .

.

Binary

, .mb, Database
Desktop .

.

Bytes

, Database Desktop
.
Binary ,
.

1-255

Pers (. . 9.1) Num Autoincrement, . Dep, Fam, Nam Par Alpha, Year_b
Short, Sex Logical ( -

566

), Charact Memo, Photo Graphic. Dep (.


. 9.2) Dep Alpha, Proisv Logical.
(Size). , Alpha .
"*" .
, , . ,
Paradox . Pers
Num. Dep Dep.

9.2.3
(. 9.5).
(Table properties).
.
9.2.3.1 Validity Checks
: Validity Checks .
. 9.5 , , . :
Required Field , . .
, , Fam, Nam Par.
Minimum

. .
Year_b.

Maximum

. .
Year_b.

Default

. . Year_b
Sex ( ).

Picture

. , # # # - # # - # # . Database Desktop.

Assist

, Picture ,
.

9.2.3.2 Table Lookup



. 9.5: Table Lookup .
- ( ) ,
,
. Table Lookup Define . , . 9.6.

567

, , , ,
Field Name.
(Lookup table). (Drive or Alias)
(Browse). , ,
, ,
Lookup field. , Dep. , ,
Pers Dep Dep Dep .
Pers - , Dep.
. 9.6

lookup labls

Fam|A20)
Nam (420|
'(420]
- |S |

raCURRENCTOB

- Lookupylpe -

'1

I <~ Mcoftespondfng liekJ*

SDICDBDB
EPEBS.Oe
EPEnS2.De

i Lookup access --- - <"* Finohefc


\ < Help and N1

, . , , .
9.2.3.4 .
9.2.3.3 Secondary Indexes
: Secondary Indexes
.
( ).
, Pers
:

fio

Fam, Nam, .
Par

depfio

Dep, Fam,
Nam, Par

,
.

year

Year_b

, Define . , . 9.7.

568

Fields , Indexed fields


, .

. Change order ( ) .
. 9.7

lds
Num
Dep

Indexed fields

Changs ordei fj
Index options Unique
P Maintained

f~ Case sensitive
" Descending

Index Options ( ) :
Unique

,

. , fio , .

Descending


( ).

Case Sensitive , .
Maintained

,
.
.
. , .

, .
(. 9.8), .
. 9.8

&

<

569

9.2.3.4 Referential Integrity



. 9.5: Referential Integrity .
, . , (), (),
, , ( ) .
, Paradox .
, Referential Integrity, . Pers Dep, , Dep Pers
Dep Dep. ,
, ( File | Working Directory). Pers
( File | Open), ( Table | Restructure) Table properties Referential Integrity.
Define, ,
. 9.9. Fields , , Child fields. Table
( ,
)
Parent's key. Update rule , ,
,
- . Prohibit,
Database Desktop . Cascade, .
, , ,
.
*1

. 9.9

*>.

Child Held!

IDep|A15[

(A2D1

lAMl
= 1A2D]

1 Update mli:
! ff Cascade

I Dep 14151

BDICDBDB
BPIRSDB
DPERS2D8

<~ Erahbn

Strict Referential Integrity


Paradox ( , Paradox DOS) , .
, (. 9.10) .

570
. 9.10

Referential htegrty name-

9.2.3.5 Password Security



. 9.5: Password Security . Paradox
, . Define
, . 9.11. ( Master password), ( Verify master password),
Auxiliary Passwords ( ) (. 9.12), .
. 9.11

Auxiliary Passwords.-

9.12

Current Password ( ) ( , ),
.
Table Rights ( )
:

571

, , , .

Insert & Delete

(,
, ), .

Data Entry

., .

.

Update
Read Only

.
:

Field Rights ( )
, :

,
.

Read Only

None

, .

, Add
Passwords. New
. Change , Change
Delete.
9.2.3.6 Table Language
Table Properties (
) ( Modify) ,
BDE Administrator
(. . 9.3.3). , . , , .
. , , , .
, ,
.
9.2.3.7 Dependent Tables
Table Properties , ,
Referential Integrity.

9.2.4
, , Save as ( ) (. 9.13), . Alios.

572

( ), ,
.
,
.
(). , Paradox
, .
. 9.13

| )DBPAR

J *- IS * a -

"--CURRENCY OB
1;

&PERS.DB

: JPERS DB

1 :: | Paradox j" db)


fili-ss

.;.-.-.-.' jBWORK.
:

zJ

Optraiss-4,/ J7 oispMable
:P Add data to table

. 9.13 . Display Table


.
Add Data to New Table ,
, . , , .
Paradox. .
.

9.2.5
Database Desktop
, , File |
Open. , Display Table, . , . 9.4. ^
Table ( | View Data)
( Table | Edit Data). ,
. Database Desktop
. , , , . ,
. Database
Desktop . ,
C+4-Builder, .
Table | Info Structure
, Table j Restructure

573

- . ,
.

9.3
, ,
,
: Database Desktop, BDE Administrator Database Explorer. , Database Desktop.

9.3.1

(. . 9.1.1)
. , ,
, BDE. : (working) (private).
.
Database Desktop
...\Program Files\Common Files\Borland Shared\Database Desktop\WorkDir. WORK. Database Desktop, File | Working Directory. , . 9.14.
(Working Directory),
Browse, Aliases . WORK .
Database Desktop, ,
. , WORK. ,
, ,
Database Desktop.
9.14

(private)
Database Desktop , .
, . PRIV.
Database Desktop, File | Private Directory. , . 9.14. .
PRIV .

574

9.3.2
Database Desktop
.
: ", ,
, . ...\Borland\Borland Shared\Bde
IDAPI32.CFG. . IDAPI.CFG
.
, , .
Database Desktop,
Tools | Alias Manager. Alias Manager (
), . 9.15. , , . Public alias ( ) ,
, . Database Alias,
. , ,
. Shaw Public Aliases
Only, ; Shaw Project Aliases Only, ; Shaw All Aliases .
. 9.15

Alias availaUe lor this session


Choose Save As to save
permanent^*.

Database afos
Driveiijipe [iNTRBASE
SERVER NAME |F .'DATABASErtBASE/ ' StTO p"bli alases a*
' *~ Show ptotgct abases Qrty
USER NAME ]a
f ShowalaSases
OPEN MODE jREAO/WRITE
SCHEMA CACHE .1"
IANCDRIVER
3OLQRYMQDE-. f
SQIPASSTHRU JSHABEOAUTOCOMMI
SCHEMA CACHE [7
Password: j"

Database Alios
Driver type
. . 9.15 INTERBASE
INTRBASB ( SQL Link
ORACLE, SYBASE). :
SERVER NAME

USER NAME

.
.

S75

OPEN MODE

: READ/WRITE ( )
READ ONLY ( ).

SCHEMA CACHE SIZE


.
5, 0 32.

LANGDRIVER

SQLQRYMODE
SQL

: NULL ( ) , , Desktop, SERVER ,


, , LOCAL
Desktop.

SQLPASSTHRU MODE
QBE SQL

, Database Desktop
QBE SQL . : NOT SHARED
, SHARED AUTOCOMMIT ( )
SQL
, SHARED NO AUTOCOMMIT ,
SQL
.

Possword

, .

SCHEMA CACHE TIME

. -1
.

j
|

Connect () . Remove () . Soye as ( ) . New () .


.
(. 9.16). , . 9.15 . 9.16 ,
. ( , New Keep New ) Dotabase Alias
, .
. 9.16

p Public alias
Database alas I
Oliverlipe | STANDARD _^J
athF
| SOATABASESDBPAR

Defining new database alias Enter ]


changes and choose Keep New

Shgw publrc. aliases ony


l
Show project aissesonly
Show aB aliases

Cancel
JjaysAs.,.|-

Hell)

576

:
Public alias (
).
Driver type . Paradox', dBase STANDARD, .
Browse. SQL- .
Database Alias - , , , .
Database Alias .
Keep New, ,
Save as .

9.3.3
BDE Administrator
BDE Administrator ( BDE) , BDE : (STANDARD), SQL, Access, ODBC. BDE BDE Administrator
Windows. +-(-Builder Tools | Configure Tools. ...\Program Files\Borlandy
Borland Shared\BDE\bdeadmin.exe.
/
(. 9.17) : Databases
Configuration .
. ,,
Definition .
.
. 9.17
Databases
BDE

BDE Admimsttator \1
Object dit View 0e** Help

I Database Abases

Definition of 4P

Databases | Configuration j
Q) Databases
BCDEMOS
"a dBASE Fil
itl So 4 P
Sj DefauUDD
+, *" Excel Res
t

Definition ]
Typo
DEFAULT DRIVER
ENABLE BCD
PATH

STANDARD
PARADOX
FALSE
F \DATABASESDBPAR

{Database Location

STANDARD, , ,
Paradox, :
PATH . PATH,
(. 9.17). Windows,
. , , ,
. , , '" -i, , . \

577

INTERBASE SQL Link


(ORACLE, SYBASE .) .
, ,
.
.

New .
, . 9.18.
,. STANDARD
Paradox, dBASE, FoxPro, ASCII.
. 9.18

" database DriverName i


|

'

OK | Caned |

, OK , .
,
. STANDARD :
PATH

DEFAULT
DRIVER

: PARADOX Paradox
( .db), DBASE dBASE ( .dbf), FOXPRO FoxPro ( .dbf), ASCIIDRV
ASCII ( .txt).

ENABLE BCD

, BDE
, BCD. BCD . ENABLE BCD = true,
DECIMAL NUMERIC BCD.


Apply. .
, Delete.
Dotoboses BDE.
Configuration () - , , , .

9.3.4 SQL Explorer


C++Builder Database | Explore. SQL Explorer . 9.19.
Databases . ( . 9.19
dbP), . .
,
Object | New .
, . 9.18 19 C++Builder 6

578

BDE, , BDE. . 9.3.3, .


9.19
SQL Explorer

Object dictionary Ed* Ve


i w Ceoons Help
All Database Aliases
Databases j Dictionary ]
Databases
Ig BCDEMDS
^ dBASE Files
"ft dbP
?B DefaulIDD

Oetntion of dbP
Definition I
Tfpe
DEFAULT DRIVER
ENABLE BCD
PATH

STANDARD
PARADOX
FALSE
F^DATABASEWBPARj

" Excel Files


'ft fc

\<\
Database locators

SQL Explorer
. , , (, ..),
( . 9.20). Definition ,
Text SQL,
( SQL). Data . ;
, .. -:
Enter SQL .
. 9.20
SQL Explorer Pers

iif '

' '- -

Object Edit View Qetions


-

"

AIIDatabajeAiases

dS
""

Databases JDictiorav I
Tables
H CURRENCYDB
DEPDB
PICOB-DB
- | Fields
( Indices
' VaSdilii Creel.

*-

Contents of PEHS DB
Delnton Data | Enter SQL |
Num

jFairi

jNarn

2 1

3 2

Ct

4 1

Hi

5 Hi
6 2

7 1

to items PERSXC.

. . 9.21
Dep Pers, .
SQL Explorer , . , ,

dbP, Pers Dep, . 9.1, . 9.1 9.2.
, .


. 9.21
SQL Explorer
Dep

579

Qbe
j ct; Qcto
l nary dSt lew opto
i ns Hdp
-;- > -_ ti
-^
AH Database Afas
Defm
i tQ
i fiof Dep
Database j Dc
i to
i nary |
Delnton JEnteS
l OL)
8 dbP
Order
2
- j !
!! H CURRENCY
!*i H DEPDB
3 H DICDB BB
H H PERS DE
:-> Fields

Li

Type
ALPHA
Size
15
F'huical Length 15

_ _ ^ ! 5

9.4 ,

VCL C++Builder
C++Builder. , C++Builder 6, , BDE, Data Access. C++Builder 6
DataSource,
BDE. Data Control.
, , ^
:
(data set),
. , Table, Query, StoredProc, BDE&ientDataSet. , . 10, .
(data source),
. DataSource.
, , DBGrid, DBText,
DBEdit .

, . 9.22.

^__

:
Table, Query
StoredProc

<

:
DataSource

:
DBGrid,
DBText,
DBNavigator ...

. 9.22. C++Builder


Database. ,
/. , , . Database

580

. ,
(-Builder
. . 10.2.2, . 10.
, C++Builder
Session. ,
.
,
. Session . 9.8.

9.5 Table

9.5.1 ,

, . Paradox Pers, dbP. .
Table. Table BDE. Dato Access DataSource, . , ,
.
DBGrid Data Control.
, . <>
, Align alClient (. 9.23).
. 9.23
,

1

DataSoutcel

, . 9.22. DBGrid DataSource. 7


DBGridl DataSource . , . DataSourcel. DataSource. . . DataSource 1 ^
DataSet. Tablol
( , Ct;
).

581

Tablel . Table: DatabaseName TableName. DatabaseName. BDE


. dbP,
. , .
, , Database Desktop,
. 9.3.2.
TableName. , . Pers.
. . Active. false. true. , DBGridl
(. 9.24) .
. 9.24


Table

$-'
Num

..iPlxi
Nam

1
2 1

3
4
5
6

Ai-

2 T " y " i
1

7 1
8 1

Gu

|Dep

i d

, Active = true
, .
,~<~.*,~.,~~,,,,. _ _ _ _ _ _ , , _
Active = false, OnCreate true,
OnDestroy false. , ,
.

, , , , . , (

). , Pers dbP Num,
(. . 9.2.2). , Dep, Dep, Dep,
Dep (. . 9.2.3.2 9.2.3.4).

, ,
. ,

582

, . Tools | Debugger Options, Language Exceptions


Stop on Delphi Exceptions Stop On C++ Exceptions (. . 15.8).
, , . , . , ReadOnly DBGridl true.
Options dgEditing false. . Options .
C++Builder.
Table Exclusive. (, ). true, . Active = false.

, DBNavigator, Data Control .
Align DBGridl alBottom,
DBNavigator (. . 9.25).
. 9.25

OS

Num|Dep

+ 1-1
(Farn

1
2 1

3 2

4 1

5
G 2
7 1
8 1
9

*!

"|

Nam

Par

Year Sex I *
1350 Tiue
1360 Tiue
1955
1361
1930
1930
1337
1375
1965

False
Tiue
True
True
True
False

,.

, . , :
nb First
nb Prior
nbNext
nbLast
nblnsert
nb Delete
nbEdit
nbPost

583

nbCancel

nb Refresh

Hint
, Hints . ,
, , ,
.
VisibleButtons, . , , false nblnsert. ,
nbFirst, nbPrior, nbNext nbLast, .
, DataSource ( DataSource).
, .

9.5.2
, , . -, Num, ,
. , . Num, Fam .., ,
-. Sex true false, a
, , .
. .
Tablel.
IndexName IndexFieldName.
, . , , fio,
, ,
Fain, Nam Par. depfio , . IndexFieldName.
, , .
. . ^ Tablel. (. 9.26 ). Add fields (
). , . 9.26 , .
. Ctrl,
. , , , .
, Charact, Photo , , Num.
, , (. 9.26 ).
. , -
. , ,
, .

584

1...

9.26
:

(),
(6),
()

Dep
Fam
Nam
Pat
Yeai.b
Sex

- . , , or
: TStringField, TSmallintField, TBooleanField .. TField . ,
.
, .
Alignment
: , .
DisplayLabel . , Fam DisplayLabel ,
Nam ..
Display Width .
EditMask EditFormat
.
( Sex)
Display Values. ,
, true false.
. , true.
: ; ^ ;.
Readonly, true,
. Visible ,
. , , Visible = false
Num, Tablel.
(. 9.27).
. 9.27


^ I "

&-I

|!3

1937

1
1

1961
1975

1960

1930

1975

[- 2

[
|

1965

1950

zi

585

. - , , Fam, .
TDBEdit , DisplayLabel. Sex TDBCheckBox. Charact Photo
TDBMemo TDBImage. ,
Active true, .

9.5.3

. C++Builder .
, , . .
, , Table
.
MinValue MaxValue,
. ,
, Year_b MinValue = 1970 MaxValue = 1980. .
. , . 9.28. .
(. . 13.10.5.2, . 13) -.
. 9.28


MinValue MaxValue

1961 Knot a vaMvak far field ' .p.'. The dkm&S range 1970 to 1980.

CustomConstraint
ConstraintErrorMessage. CustomConstraint SQL (. . 10.1). ,
Year_b CustomConstraint:
X < 1980 and X > 1970

( X) .
CustomConstraint,
ConstraintErrorMessage. ,
, , . ,
(. . 9.29, ). ,
MinValue MaxValue, .
.

586
. 9.29


CustomConstraint ConstraintErrorMessage

On Validate.
. , , , EAbort Abort. ,
OnValidate OnChange, .
.
,
. Constraints Table. , ,
. 9.30. Add New ( )
Constraints . . ,
. CustomConstraint
SQL, . ErrorMessage
, . , CustomConstraint:
((Sex=true) and (ear_b >1955))or
((Sex=false) and (Year_ b>1965) )
ErrorMessage: >1955 .. >1965 ..
.
. 9.30

((Sex-ttue) and (Yeai_b >1955M(Sex=false) and (YeaiJ1965))

Table,
.

9.5.4
,
,
. (calculated
fields). , . Tablel, . '
New field ( ). , . 9.31.


. 9.31

587

Field properties
Harne JAge
iKpe-

Component JTableUge

jSmafcnl

Field type
ata
Lookup deftnrtion
- '
1

<! Calculated

-.. -. |
|

Lookup

- '

......
OK

"|

J ,

Cancel

_ E * _ J

Field properties ( ) (Name)


Age, ()
Smallint, (Size).
.
,
Field type Calculated ( ).
, Age.
DisplayLabel .
Age, ,
. , ,
Tablel, OnCalcFields. , .
,
:
TablelAge->Value = 2002 - TablelYear_b->Value;
TablelAge>Value TablelYearJb>Value
Age Year_b . ,
2002 , . . , , . :
void

f a s t c a l l TForml::TablelCalcFields(TDataSet

*DataSet)

unsigned short Year, Month, Day;


Date () .DecodeDate(SYear,SMonth,SDay);
TablelAge->Value = Year - TablelYear_b->Value;
Year, Month Day
, . Date (. . 16.3.2 . 16), TDateTime ( C++Builder
). DecodeDate , . Year
( Month Day , DecodeDate).
, (. 9.32).

588
. 9.32

I
|

| | \^_
1965
37
;
1950
52
1930
72
1937
41
1961
1975
27
1960
42
1930
72
:
1975

9.5.5
Table , , .
, , , ,
, .
Filter, Filtered FilterOptions
Table. Filtered
. Filter ,
. ,
Filter
Dep='

1'

Filtered true, ,
, Dep 1.
, , .
" " , , : .
,
Dep='qex*'
, Dep
. , . , , , ,
FilterOptions foNoPartialCompare, ( ).
FilterOptions foCaselnsensitive
, .
, 1 1 .
=, >, >=, <,
<=, <>, and, or not. ,
(Dep='Uex 1')and(Year_b<=197 0)and(Year JD>=194 0)
1,
. (, Age) .
, , ,
, , . -

589

. DBGridl
Align alNone, RadioGroup ( RGF),
ComboBox ( CBDep), CSpinEdit
Samples ( SEmin SEmax), , , , , 9.33.
. 9.33

- 1

,'-

U S S W M S I

'

"

..| | ] _iJ
1955 4?

1960 42

1^1 41
1*2 40
2

1965 37
1
19?5: 2?


1975 27
2

-4>
1

i Bee

|16

CBDep , . Items
. SEmin SEmax .
MaxValue, MinValue Value. RGF ( Items Caption), . 9.33, Itemlndex = Columns = 2. , . .
unsigned short Year, Month, Day;
//
void
fastcall TForml::TablelCalcFields(TDataSet *DataSet)
(
TablelAge->Value - Year - TablelYear_b->Value;

void
{

fastcall TForml::RGFClick(TObject *Sender)

Tablel->IndexName - "depfio";
if (RGF->ItemIndex == 0)
Tablel->Filtered = false;
else
(
if (RGF->Itemlndex 2)
Tablel->Filter = "Dep='"+CBDep->Text+"'";
else if (RGF->Itemlndex == 3)
(
Tablel->Filter = " (Year_b<-" +
IntToStr(Year-SEmin->Value)+
")and(Year_b>="+IntToStr(Year-SEmax->Value)
Tablel->IndexName = "Year";
else
Tablel->Filter

"(Dep='"+CBDep->Text+

590

9
"')and(Year_b<="+IntToStr(Year-SEmin->Value)
+")and(Year_b>="+IntToStr(Year-SEmax->Value)+")";
Tablel->Filtered = true;
)
)
//__
void fastcall TForml: : ForrnCreate (TObject *Sender)
(
~~
Date () .DecodeDate(SYear,SMonth,SDay);
Tablel->Active = true;
}
void
fastcall TForml::FormDestroy(TObject *Sender)
{
Tablel->Active = false;
)

. TablelCalcFields
. , Year, Month Day (
) Date DecodeDate
FormCreate OnCreate. ,
Year
TablelCalcFields RGFClick. FormCreate
Tablel->Active = true;

( OnDestroy).
RGFClick,
.
OnClick RGF ,
. , , ,
. RGFClick OnChange .
RGFClick dcpfio,
. , ..
. ( ),
Filtered false.
true. 2 ( ), Filter Dep='...',
, CBDep. 3 ( ), Filter
(Year_b<=...)and(Year_b>=...), ,
SEmin SEmax. ,
Age .
C++Builder 6 5.
C++Builder , C++Bailder : Ambiguity between '_fastcall Sysutils::IntToStr( int64)' and 'fastcall Sysutils::IntToStr(int)'. ,
IntToStr
int64 int. . . 14.2,
. 14. , IntToStr . , IntToStr((int)(Year-SEmin->Value)).
.

591


OnFilterRecord.
, Filtered true. Accept . ,
, Accept true. , Accept false. OnFilterRecord, , RGFClick ,
void
f a s t c a l l TForml::TablelFilterRecord(TDataSet *DataSet,
bool SAccept)
{

Accept = (RGF->IteraIndex = = 0 ) ||
((RGF->ItemIndex == 2) SS (TablelDep->Value==CBDep->Text))
((RGF->IteraIndex = 3) &&
(TablelYear_b->Value <= (Year-SEmax->Value)) &&
(TablelYearjD->Value > (Year-SEmin->Value) ) ) | I
((TablelDep->Value == CBDep->Text) &&
(TablelYear_b->Value <= (Year-SEmax->Value)) &&
(TablelYear_b->Value >= (Year-SEmin->Value))) ;

I!

Accept ItemIndex RGF. , RGF>ltemlndex = ( ), Accept = true -


.
. , . -, Tablel Filtered = true. , ,
. OnFilterRecord . RGFClick OnClick RGF :
Tablel->Filtered = false;
Tablel->Filtered = true;
if (RGF->IteraIndex == 3)
Tablel->IndexName - "Year";
else Tablel->IndexName = "depfio";
.
OnFilterRecord.
, . RGFClick OnClick .
,
.

9.6
.
, , , .. Table .
.

592

. SQL Explorer, Datobase |


Explore. . 9.3.4 Databases SQL Explorer.
Dictionary
Dictionary | New. , . 9.34. Dictionory Name
. ,
. Database
, . Paradox. Table Name
, .
Description , . .
create new OicttorwHSJfllilll

. 9.34
SQL Explorer

Dictionary Name JDicdb

Database: |BCDEMOS

zl

Table Name: JDicdb


Description: | dbP ib

Canoe)

, . 9.35. Dictionary,
: Databases , Attribute Sets . .
. 9.35

Qbjert dictionary
Dictionary: Dicdb
Databases Dictionary I
Dictionary
Databases

*-

a t> Albibute Sets

PersFaro
fH PersNam
ffi PertPar
PersSex
PeisYear_b

)> fji fS
i EJE

ffi

Definition of PeisDep
Definition I
ServerDoroainName
TFieldQass
TControDass
Alignment
Displaylabel
DisplajiWidth
ReadOnly
Required
Visible

12
False

Transliterate
2 Items In PenDep.

, Dictionory | Import From Database.


.
, , . . 9.35 Databases , .
, Dictionory
Import From Dotabase .

593

.
. Attribute Sets,
New.
. .
, , - , . - , Pers. Table. ,
. , Save Attributes
as. , . 9.36.
Attribute set name
, .
, . , .
Based on
, . , ,
Pers, Dep. Dep
PersDep.
. 9.36

&tttibute set name


[PsrsDep
' Uased on
D
j ep

[
3 .

OK 1
CancelJ
Hep
l J

. 9.36 ,
. , .
Database | Explore.
, . 9.35, . , ,
Refresh .
, . , . , -, , , ..
, SQL Explorer, . , ( Object | Delete ). , . (. . 9.35 PersDep).
( Object | Cancel ).
Object | Apply .
Dictionary | Select . (, ,
).

594

Dictionary | Register - , , . ,
DICDB.DB, ,
. dbP.
, Dictionary | Register .
, . , Table, DataSource
DBGrid, Pers dbP.
Table Active true. ,
, . Table . , , . , ? , , Unassociate
attributes. , - .
Associate attributes. . , .

9.7

DBGrid. . , , . , ,
, : 1. ,
, .
, Columns DBGrid.
,
. , .
, Columns.
.
(. 9.37 ). , Add ( ) FieldName. To , Add. A
: Add All Fields
( ).
, Table. Delete ( ) , .
, Dep,
.
ButtonStyle.
. ButtonStyle :

595

ebsAuto

,
.

cbsEllipsis

'..,",
OnEditButtonClick DBGrid.

cbsNone

- .

ebsAuto ( ), PickList,
. Dep PickList , 1 2. , ,
(. 9.37 ).
PickList Sex. DropDownRows ( 7)
, .
DropDownRows, .
d
. 9.37


()
Dep ButtonStyle
= cbsAuto ()
ButtonStyle =
cbsEllipsis ()

6)

*;|-

'- m m

1 Few
Nam
3 Pat
4 Ysat b
5 Sex

1|
'

fTTfffltlfllfflff
Lex 1

||

f xj

I d

1 '

1|

, ebsAuto
, (. . 9.9.2). . PickList , .
ButtonStyle cbsEllipsis, "..." (.
. 9.37 ). OnEditButtonClick DBGrid. - ,
. OnEditButtonClick , ,
SelectedField DBGrid. . :

596

9
if(DBGridl->SelectedField == TablelDep)
DBGridl->SelectedField->Value =

ButtonStyle cbsNone,
- .
DBGrid , . : , , - . , Data Control
, DBGrid.
.
DBText Label, .
, .
: , , . .
DBEdit Edit.
: ,
, . , ReadOnly=true, ,
DBText, , , DBText.
DBMemo Memo.
Memo, , . , , .
DBRichEdit
RTF. ,
DBMemo.
DBImage Image. , , .
DBCheckBox CheckBox.
. true, . ,
. ,
,
DBGrid.
DBRadioGroup RadioGroup.
.
Dep Sex. Items, , . Values,
, . ,
.
Values , Items, .. . DBRadioGroup
,
.
, .

597

: Data Source ( TDataSource) DataField , .


, , , , : Caption
DBText, Text DBEdit, Picture DBImage .. , .
, , ,
. , .
, , ,
, , ,
DBCtrlGrid. , ,
,
. DBCtrlGrid DataSource, , . RowCount ( 3),
ColCount ( 1).
DBCtrlGrid PanelWidth PanelHeight , Width Height.
C++Builder , .
. . 9.38 , . DBCtrlGrid 3 3 .
DBText, Fam.
DBCtrlGrid ( fio). . , , DBEdit, DBText. , ,
, , .
DBEdit ReadOnly=false, . , ,
, , , DBEdit
.
. 9.38
,

ju'eii'i

fiospacr

41


(. 9.39), .
DBImage DBMemo. , DBMemo, .

598
. 9.39
,


13
1

*
(

-Li

. #include
,
TDataSource. , File | Include
Unit Hdr. DataSource ,
,
Forml>DataSourcel, . , . OnClick
:
if (! Form2->Visible) Form2->Show();

Form2 , .
:
,
. , , , , . . , .

9.8 Session
Session . Session, C++Builder Session , .
Session.
Session
BDE. Session. , .
(. 9.40) TComboBox, cbAlias
.
, . Style
csDropDownList, , . TDBGrid, DataSourcel Tablel.
;
, -1
cbDatabase BDB . - , OnCreate :

599

Session->GetAliasNames(cbAlias->Items);
cbAlias->ltemIndex = 0;
cbAliasChange(Sender);

GetAliasNames Session,
TStrings ( cbAlias>
Items) , BDE. .
On Change cbAlias, cbAlias .
. 9.40
,

I "FIT"'

' "iVHr' T - 7

Hum|Op
1
2 1

3 2

4 1

1
1
1
1

cbAlias cbTable .
OnChange cbAlias :
Session->GetTableNames(cbAlias->Text,"",true,false,cbTable->Iteras);
cbTable->ItemIndex = 0;

GetTableNames
TStrings ( cbTable>
Items) , ( cbAlias>Text). , . , * ,
. , , . , true, , (
Paradox dBase). false
Paradox dBase, , SQL, true, , .
.
:
Tablel->Active = false;
Tablel->DatabaseName = cbAlias->Text;
Tablel->TableName = cbTable->Text;
Tablel->Active = true;

Tablel ,
, DatabaseName TableNarae
Tablel .
. , ,
C++Builder.

600

Session,
. Session
, .
Session , .
Session
SessionName , , , si.
SessionName TDatabase, TTable, TQuery .. .
Session.
Session, Session - . TSessionsList Session.

9.9 BatchMove
BatchMove . : Source
(, ) Destination
. Mode . :
batAppend
batUpdate

,
. -
.
- , -,
. . -
.

batAppendUpdate

- , -,
. , ,
. -
.

batDelete

-, , . -
.

batCopy

- . - ,
.

Execute -.
. MovedCount ,
-.
;
, I
- --.
. AbortOnProblem , :'

601

, - -. AbortOnProblem = false ProblemTableName. Paradox, , .


ProblemCount ,
. AbortOnProblem = false - -. , BatchMove - -. , .
- , -, , , .
AbortOnKeyViol , , -. AbortOnKeyViol = false KeyViolTableName. Paradox,
, - . KeyViolCount .
, TBatchMove , -.
ChangedTableName, Paradox,
-.
ChangedCount ,
- ( Mode = batUpdate batAppendUpdate), ( Mode = batDelete).
ChangedTableName.
Mappings TStrings . , .
, Mappings .
Mappings, . -, ,
. . , Mappings, . ,
, . , Mappings
Dep

Dep Dep .

DepNew = Dep

Dep DepNew .
, , , . , , .
, .

602

9.10

9.10.1
. ,
.
. (master), , (detai!). , , Dep, ( Dep) ( Proizv , true , false ). , ,
, , , .. Pers,
Dep Dep .
Dep,
Pers, , , Dep .
2 Table, DataSource . ,
. 9.41. DBCtrlGrid, DBText.
, (master) Dep. Dep,
. , DBCtrlGrid, Dep Proizv.
. 9.41
,

I Uexi

. j^j

S5

41

27

42

DBGrid.
Pers. ,
Dep. , , , , .
, .
. , Pers ( Active =
false). MasterSource Table, , .
MasterFields. (Field Link Designer).
. 9.42. Detail Fields
, , . , Dep. Master Fields . ( Dep).

603

Add, Joined Fields . (, , , ) .


MasterFields Table .
(Active = true) .
. 9.42

Indexes
Dlail

M
Add

Joined Fields

(. 9.43), ,
, . , ,
& , .

9.10.2 (lookup fields)


, .
Table, , ,
.
. , ,
2, , , , . Dep Proizv. Tablel.
2 ,
.
New Field.
,
(. 9.43). (Nome) .
. () . , ,
,
. Dep
Proizv, .
(Size).
, Field
type Lookup. Key Fields (
) , (2). ,
.
Dataset , (Tablel). Lookup Keys ( )
( Dep Tablel). , ,
Result Field (Proizv). .

604
. 9.43

ill

Field properties ~~ ~
Hamr

Opponent )2

Ivpe ] oof ean


, Field type
ata

<* Lookup

<"" Calculated

Lookup definition
&w Fields.

_2J Djtaset

JDep

JTablei

_-j BesuSReld: jProisv

, Loofcijp Keys JDep

Cancel

Help

, Pro.
DisplayLabel (), ,
, , , DisplayValues ( true false), , .;..
, , DBGrid, (. . 9.44).
. 9.44

(
)

S
. 1330

. 1965

JflxJ

Hex 1|
I . 1937
{ . 1975

. 1950

. 1930

. 1975

. 1961

, Pro
FieldKind ( fkLookup), KeyFields, LookupDataset, LookupKeyField LookupResultField. , .
. 9.7 , DBGrid
Columns ButtonStyle cbsAuto ,
. .
. ?
. , , ,
, , DepLook . 9.43 Result Field Dep. ( DisplayLabel), Dep.
Columns DBGrid Dep
DepLook. , . -
. . 9.44
, 1 2.
LookupCache. , , -

605

. (, ) , . , , , . , .
RefreshLookupList,
.
.
, .
. ,
: DBLookupListBox DBLookupComboBox .
, DataSource, , , DataField
, .
,
DBListBox DBComboBox.

9.11
9.11.1

.
. - .

State , . . :
dslnactive , .
dsBrowse

, .
.

dsEdit

dslnsert

dsSetKey

SetRange. .

,
, .
Close ,
Active false. State dslnactive.
Open ,
Active true. State dsBrowse.
Edit dsEdit.
Insert InsertRecord , ,
C++Builder, State dslnsert.

606

EditKey, SetRange, SetRangeStart, SetRangeEnd ApplyRange, ,


State dsSetKey. .
. , . , ,
dsEdit Edit,
EDatabaseError Dataset not in edit or insert mode Edit Insert.

9.11.2
, , .
Post. ,
dsEdit dslnsert. , , Tablel>Post().
, .. .
, dsEdit dslnsert.
, , Cancel. , Post, , , , dsBrowse.
, Post
.
- , , - . ,
. , Table.

Table. , Post BeforePost,
AfterPost. Beforelnsert Afterlnsert
Insert .. .
BeforePost. :
void
fastcstll TForral: :TablelBeforePost (TDataSet *DataSet)
<
if ( )
<
if (Application->MessageBox(
" ?",
" ",
MB_YESNOCANCEL + MB_ICONQUESTION) != IDYES)
(
DataSet->Cancel ();
Abort () ;
}
)
else
(
Application->MessageBox (" ", "", MB__ICONSTOP) ;
Abort () ;

607


Post, : ,
.
. ,
Abort, Post. dsEdit, , .
, ,
. , Cancel,
Abort. Cancel ,
, .. . Cancel DataSet. , BeforePost , Post. DataSet
. DataSet
, , Tablel.
, BeforePost
.
:
- , ,
,
, . .
, .

9.11.3
, Post,
Insert, Delete .., .
, , , .. .
, . .
CachedUpdates
Table. false .
true, .
Apply Updates.
CancelUpdates, , ApplyUpdates, .
ApplyUpdates ,
. CommitUpdates,
ApplyUpdates, ,
, . ,
Rollback, .
, ,
. 9.45. . .
. , , , . , .

608
. 9.45
,

--.

{,

| | . !.;

1950

I960

1355

UBXI

1961

1930

1965
1962

_ 2

if

1930
1937

1
- -

1975

~ "

. Tablel CacliedUpdates true. modif, "!:


bool modif - false;

OnClick :
Tablel->CachedUpdates = ! Tablel->CachedUpdates;
BApplyUpdaCes->Enabled = Tablel->CachedUpdates;
BCancelUpdaCes->Enabled = Tablel->CachedUpdates;
if (Tablel->CachedUpdates) modif = false;

,
( BApplyUpdates) - ( BCancelUpdates) , , false modif.
AfterEdit, AfterDelete Afterlnsert Tablel ;.'1
:
if

(Tablel->CachedUpdates) modif = true;

modif , ;1
.
OnClick
Tablel->ApplyUpdates();
Tablel->CommitUpdates();
modif = false;

OnClick
Tablel->CancelUpdates();
modif = false;

modif false, .
OnCloseQuery :
if ( T a b l e l - > C a c h e d U p d a t e s & modif)
switch
(Application->MessageBox(
" ? 1 1 ,
" " ,
MB YESNOCANCEL + MB ICONQUESTION))
Tablel->ApplyOpdates() ;
break;
c a s e IDCANCEL: CanClose = false;
break;
Tablel->CancelUpdates
();
case IDNO:
case IDYES:

609

?. ApplyUpdates. CancelUpdates.
, (CanClose false).
, .

9.11.4
TField
TStringField, TSmallintField, TBooleanField ..
:
(Table .)


TField , : . (
).

.
. , , , . ,
, ,
.
TField
.
:



TField*
Fields[int i], i . , C++Builder, 0. , Tablel>Fields[O] Tablel.
FieldByNa(""). , Tablel>FieldByName("Fam") ,
Fam.
,
. C++Builder
(Name) . , TablelDep.
, . ,
. ,
, . TablelDep
.
Name
. .
, ,
.
, . ,
, 20 C++Butldcr 6

610

Fields[i] ( i ), FieldByName(s) ( s ).
TField
. Readonly, DisplayLabel, CustomConstraint
. , .
Value. Variant, ..
. , Tablel>FieldByName("Fam")>Value
, a Tablel->FieldByName("Year_b")>Value .
, . , AsString
,
.
EDep->Text = Tablel->FieldByName ("Dep") ->AsString;
EYear->Text = Tablel->FieldByName("Year_b")->AsString;
ESex->Text = Tablel->FieldByName("Sex")~>AsString;

EDep, EYear ESex Dep, Year_b Sex, Dep ,


Year_b , Sex . Sex
DisplayValues, ESex
true false. DisplayValues,
; ;, .
AsString . , EDep, EYear ESex,
, , :
Tablel->Edit();
Tablel->FieldByName("Dep")->AsString = EDep->Text;
Tablel->FieldByName("Year_b")->AsString = EYear->Text;
Tablel->FieldByName("Sex")->AsString = ESex->Text;
Tablel->Post();

Year_b Sex . , ESex .


: t f, true false, >>,
.
, ( Edit), ,
. , ,
,
. .
AsString Aslnteger, AsFloat,
AsBoolean, AsDateTime. Aslnteger
32- , AsFloat , AsBoolean
, AsDateTime C+H-Builder TDateTime.
.
DataType,
: ftUnknown (), ftAutoInc ( ),
ftString () ..

611

9.11.5
, :
Fibrst

Last

Next

Prior

MoveTo(int i)

( i > 0) ( i < 0) i

, dsEdit, Post, ,
, . Cancel
. , , dsEdit,
( . 9.11.2 , ), - (,
dsBrowse).
, . , Prior,
, Next, .
, : Eof (end-of-file) ,
Bof (beginning of file) . true,

, Last First.
.
CBdep, ,
Dep , Tablel.
:
CBdep->1 () ;
Tablel->First();
while (!Tablel->Eof)
<
CBdep->Items->Add(TablelDep->AsString);
Tablel->Next () ;
)
CBdep->ItemIndex = 0;
Tablel->First () ;

CBdep.
. , , Tablel>Eof.
Dep, Next . .

9.11.6
. , SetKey, FindKey, Lookup Locate.

612

SetKey.
,
. dsSetKey. SetKey. dsSetKey , . dsSetKey
. GotoKey , . ,
. ,
GotoKey false.
GotoKey, GotoNearest. , . ..
, . GotoNearest . ,
" .
, , (
Year_b) EYear,
:
Tablel->IndexFieldNames = "Year_b";
Tablel->SetKey();
Tablel->FieldByName ("Year_b") ->AsString = EYear->Text,if (! Tablel->GotoKey() )
ShowMessage(" ");

Year_b, dsSetKey, ,
.
, EFam, :
Tablel->IndexFieldNames - "Fam";
Tablel->SetKey ( ) ;
Tablel->FieldByName("Fam")->AsString EFam->Text;
Tablel->GotoNearest ;

, ( ).
FindKey . , . FindKey :
bool

fastcall FindKey(const System::TVarRec * KeyValues,


const int KeyValues_Size);

KeyValues : , , , . . KeyValues_Size ,
. 0, KeyValues_Size
, .
FindKey
FindNearest, ,
.
, FindKey. FindNearest
. , .

613

FindKey FindNearest OPENARRAY,


:
OPENARRAY(TVarRec,( ))
OPENARRAY , 19 , .
. ,
. :
Tablel->lndexFieldNames = "Fam";
Tablel->FindNearest(STVarRec(EFam->Text) , 0) ;
,
, , EDep, OPENARRAY :
Tablel->lndexFieldNames = "Dep;Fam";
Tablel->FindNearest(OPENARRAY(TVarRec,(EDep->Text,EFam->Text)));
Dep Fam,
. ,
. .
. . EFam
,
. Fam. OnChange
EFam
T a b l e l - > F i n d N e a r e s t ( S T V a r R e c ( E F a m - > T e x t ) ,0) ;

Locate. , , , .
:
bool
fastcall Locate(const System::AnsiString KeyFields,
const System::Variant iKeyValues,
TLocateOptions Options);
KeyFields , . KeyValues . Options ,
loCaselnsensitive
, , loPartialKey . false, .
Locate
. , ( )
TLocateOptions SearchOptions;
SearchOptions < loPartialKey < loCaselnsensitive;
Tablel->Locate{"Fam",EFam->Text, SearchOptions);
, .
, ,
.
:
TLocateOptions SearchOptions;
Tablel->Locate("Fam", EFam->Text,
SearchOptions<loPartialKey<loCaseInsensitive);

614

VarArrayOf, Variant
. ,

TLocateOptions SearchOptions;
Variant locvalues[] = (EDep->Text, EFam->Text};
Tabiel->Locate("Dep;Fam", VarArrayOf(locvalues, 1) ,
SearchOptions<loPartialKey<loCaselnsensitive);

Lookup.
:
System::Variant

fastcall Lookup(
const System:: AnsiString KeyFields,
const System::Variant SKeyValues,
const System::AnsiString ResultFields);

Locate. ,
, Variant.
, false.
, , , EFam, EDep , , :
EDep->Text = Tablel->Lookup("Fam",EFam->Text, "Dep");

Lookup . . . ,
KeyValues Lookup
Locate. .

9.11.7
. , . SetRangeStart dsSetKey

. SetRangeEnd ,
.
, Apply Range.

, .
,
Tablel->IndexFieldNames = "Fam";
Tablel->SetRangeStart() ;
Tablel->FieldByName("Fam")->AsString = "A";
Tablel->SetRangeEnd() ;
Tablel->FieldByName ("Fam")->AsString = "";
Tablel->ApplyRange();

, , , , .
SetRangeStart SetRangeEnd
KeyExclusive. , ( KeyExclusive = false,
), ( KeyExclusive =

61!

true). , KeyExclusive = false $ >, KeyExclusive = true >, <. , , ,



Tablel->IndexFieldNames = "Year_b" ,Tablel->SetRangeStart();
Tablel->FieldByName("Year_b")->AsInteger = 1950;
Tablel->SetRangeEnd();
Tablel->FieldByName ("Year_b") ->AsInteger = I960,Tablel->ApplyRange();
, 1950-1960,
1950 1960.
Tablel->IndexFieldNames = "Year_b";
Tablel~>SetRangeStart ();
Tablel->FieldByName("Year_b")->AsInteger = 1950;
Tablel->KeyExclusive = t r u e ;
Tablel->SetRangeEnd();
Tablel->FieldByName("Year^b")->AsInteger = 1960;
Tablel->ApplyRange();
, 1950 , .
SetRange.
:
void

fastcall SetRange(const
const
const
const

System::TVarRec * StartValues,
int StartValues_Size,
System:: TVarRec * EndValues,
int EndValues_Size);

StartValues EndValues , . , SetRange


SetRangeStart, SetRangeEnd ApplyRange. , , ,
:
Tablel->IndexFieldNames = "Fam";
Tablel->SetRange(STVarRec("A"),0,STVarRec(""),0) ;

, , ^
TVarRec ( , OPENARRAY), . 9.10.6.
,
-, , 1, :
Tablel->IndexFieldNames = "Dep;Fam";
Tablel->SetRange(OPENARRAY(TVarRec,(" 1 " , " " ) ) ,
OPENARRAY(TVarRec,(" 1 " , " " ) ) ) ;

9.11.8
Table , . .

616

CreateTable

, Table, Fields FieldDefs.


, TableName
, .
, , , - , TableName
.

DeleteTable

,
DatahascNamc TableName. .

RenameTable(s) ,
, s. .
Deletelndex(s)

s .

i
,
Dep. , Tablel,
, .
// Tablel
Tablel->Active = False;
//
Tablel->TableName = "Dep.db";
// ,
if(! Tablel->Exists)
{
//
Tablel->TableType = ttParadox,//
Tablel->FieldDefs->Clear();
//
TFieldDef *pNewDef = Tablel->FieldDef s->AddFieldDef () ;
//
pNewDef->Name = "Dep";
pNewDef->DataType = ftstring;
pNewDef->Size = 20;
pNewDef->Required = True;
//
pNewDef = Tablel->FieldDefs->AddFieldDef();
pNewDef->Name "Proisv";
pNewDef->DataType = ftBoolean;
//
Tablel->IndexDefs->Clear();
// -
Tablel->IndexDefs->Add("","Dep",
TIndexOptions() <ixPrimary < ixUnique);
// CreateTable
Tablel->CreateTable();
Tablel->Open();
//
Tablel->Insert();
Tablel->FieldByName("Dep")->AsString = "";
Tablel->FieldByName("Proisv")->AsBoolean = false;
Tablel->Post();

617

9.12

, . . . 9.46 9.47.
. 9.46


<~

jljexi

_3

(
|

1 {
J

jr.. {|
19?6 27
1960 42

[Z0

(*"

zl
*

>

IH

...


.
Tablel 2.
Tablel Dep dbP. . Tablel DataSourcel. 2 Pers. ,
Tablel. 2 MasterSource = DataSourcel
MasterFields = Dep. 2 DataSource2,
TDBGrid, Tpers.
.

TComhoBox, CBdep.
Tablel, .. .
.
Tpers . Tpers .
,
, DBEditl TDBEdit,
Tablel DataSourcel Proisv.
CBdep DBEditl .
, . OnCreate CBdep:
Tablel->Active = true;
Tablel->First();
CBdep->Clear () ;
while (!Tablel->Eof)

'

CBdep->Items->Add(TablelDep->AsString) ;
Tablel->Next () ;
]

CBdep->Items->Add(" ");
CBdep->ItemIndex = 0;
Tablel->First () ;
Table2->Active = t r u e ;

'

Tablel , CBDep, Dep Tablel. , .


, .
Tablel CBDep. OnChange :
if (CBdep->ItemIndex CBdep->Items->Count-l)
Table2->MasterFields = " " ;
Table2->IndexFieldNames = "Fam;Nam;Par";
DBEditl->DataSource = NULL;
}

else
{
Table2->MasterFields = "Dep";
Table2->IndexFieldNames = "Dep;Fam;Nam;Par";
Tablel->FindNearest(STVarRec(CBdep->Text), 0) ;
DBEditl->DataSource = DataSourcel;
)
/* TPers,
*/
TPers->SetFocus () ;

( ), Tablel
2 MasterFields
2. DBEditl . 2
. Tpers. ,
Tpers CBDep.
CBDep ,
2 DBEditl Tablel.
2, Dep,
. FindNearest Tablel , .
Tablel , Tpers DBEditl.
.
,
,
. OnClick :
Table2Dep->Visible = CheckBoxl->Checked;

Dep .
,
Form2, . . 9.7 (. . 9.39).
.
PageControll TPageControl.

619

. 9.46.
. 9.5.5, , . Editl OnChange
:
if

(CBdep->Text -= " ")


Table2~>FindNearest(STVarRec(Editl->Text) , 0);
else
{
TLocateOptions SearchOptions;
Variant locvalues[] = (CBdep->Text, Editl->Text);
Table2->Locate("Dep;Fam", VarArrayOf(locvalues,1) ,
SearchOptions<loPartialKey<loCaseInsensitive) ;
)

, FindNearest
( , Locate).
Editl. ( )
Locate, , CBdep->Text,
Editl->Text.
PageControll
, . 9.47. . , , , , .
. 9.47


[ 1

*J

jgxj

; '
^

.-$/\;!


)|
1937
1361 41
1975 27
195D 42

, , ( ). ,
.
Modified DBMemol, (. . 9.39), . , Clipboard, DBImagel Clipboard Ctrl-V.
, , . ChangePhoto, true.

620


, . .. , ,
Edit, DBEdit.
. TPers
Options dgEditing = false,
.
2 OnAfterScroll 2
:
if

(PageControll->ActivePage == TabEdit)
(
RGF->ItemIndex = 0;
CBEDep->ItemIndex =
CBEDep->Items->IndexOf (Table2Dep->AsString)-;
EFam->Text = Table2Fam->AsString;
ENam->Text = Table2Nam->AsString;
EPar->Text = Table2Par->AsString;
SEYear->Value = Table2Year_b->AsInteger;
if (Table2Sex->AsBoolean)
RGSex->ItemIndex - 0;
e l s e RGSex->ItemIndex = 1;


CBEDep->ItemIndex = CBEDep->Items->IndexOf(Table2Dep->AsString);

:
CBEDep->Text

Table2Dep->AsString;

.. CBEDep >Text Dep? , CBEDep Style = csDropDownList,


, , . Text. IndexOf, CBEDep>Items ( TStrings), ,
, CBEDep>ltemlndex.

OnAfterScroll 2, .. 2. OnChange
PageControll, .. .
Form2->DBMemol->Read0nly - !

(PageControll->ActivePage == TabEdit);

,
, .
;
?
. OnClick :
AnsiString s;
const AnsiString si =",";
if (Table2Dep->AsString != CBEDep->Text)
s "";
if (Table2Fam->AsString != EFam->Text)
{
if (s != "") s += si;
s += " ";


if
f

621

(Form2->DBMemol->Modified)
i f (s !- "") s += s i ;
s += " ";

)
if (ChangePhoto)
(
if (s != "") s += si;

s += " ";
)
if (s != )
if
(Application->MessageBoxj
(" " + s + " ? " ) . c _ s t r ( ) ,
" ",
MB__YESNO + MB_ICONQUESTION) == IDYES)
{
T a b l e 2 - > E d i t () ;
Table2Dep->AsString = CBEDep->Text;
Table2Fam->AsString = EFam->Text;
Table2Nam->AsString = ENam->Text;
T a b l e 2 P a r - > A s S t r i n g = EPar->Text;
T a b l e 2 Y e a r j 3 - > A s I n t e g e r = SEYear->Value;
Table2Sex->AsBoolean = (RGSex->ItemIndex -= 0) ;
CanPost = t r u e ;
T a b l e 2 - > P o s t () ;

CanPost = false;
Form2->DBMemol->Modified - false;
ChangePhoto=false;

);
, ,
, ?, , .
Post.
Modified ChangePhoto,
.
Post , CanPost.
? ,
DBMemol
Form2 TDBImage Form2 .

. BeforePost 12

if ( ! CanPost)
{

DataSet->Cancel(> ;
Abort () ,-

, CanPost = false. .. . Post CanPost true .


, , . OnClick Table2->Insert(), -

622

.
Pers.
, , : 2 Num.
. 2,
.
2, Post , . ,
. .
OnClick
if

(Application->MessageBox(
" ? " ,
" " ,
MB_YESNO + MB^ICONEXCLAMATION) == IDYES)
T a b l e 2 - > D e l e t e () ;


.
. , . , , , , ,
.

9.13
, , . C++Builder TDataModule.
, , , , , .
C++Builder . C++Builder 4, 5 6. C++Builder 4
. C++Builder 5 . C+4-Builder 6
. : C++Builder 6
(. 2.5.5).
.
, C++Builder. C++Builder 4.
+-I-Builder 4
C++Builder File | New Data Module. File | New New Dato Module.
(. . 9.48), ( Table,
), (DataSource) ,
.

623

. , , .
9.48
C++Builder 6 4

Queiji DataSoutce2 Oatabatel

, ,
uses, . ,
File | Include Unit Hdr.
OnCreate OnDestroy,

( Tablel>Active = true) ( Tablel>Active = false).
C++Builder 5
(Data Module Designer). File | New New Data Module. ,
. 9.49 9.50.
, , .. :
Components (. 9.49), Data Diagram
(. 9.50).

Components. Components
.
9.49

C++Builder

IttDatiiModuleS
*> Defau!i {Sesso
i n}
-:->| DEP DB {TDep}
H ^ Constants
*^ 0- TCheckConsta
i rt
V$ DSDep
!.t; -AFiFee
ildd
l sDesl
T; 3*
*| O-Dep{TDepDep}
, 1 -PtobvjTDepProisv}
- - ^ IndexDefs
A O-TDepindexi
t PersDBfTPers}

Component! | D#a

.
TDep

Pes
T
r

BSOI
DSDep

DSPers

Components
. - , , Table ( . 9.49 9.50 Table TDep
TPers), .
Table , Fields Editor , Explore
SQL Explorer. , , .

624
9.50


C++Builder 5

' Derate {Sesso


i n!
j
!.;dbPWas)
\k
-, J1DEP-DB {TDep}
- ^ Constran
i ts
S 0 TChe
% OSOeo

awwx ^ &
Dcp - Pec

Fields,
, Add fields
, Add all fields , New field , , .
. ,
Fields Editor. - , . , .
, . , DataSource ( . 9.49 9.50 DSDep DSPers)
, , , Table. DataSet . ,
.
Data Diogram (. 9.50)
.
, , .. , .

. .
.
, Color, .
, ,
Ctrl, ,
. -

625

Ctrl Shift, .
, , "-". ,
, ,
, ( . 9.50 ).
, , . . , . . 9.50
,
Session.
. .
.
, , . . 9.50
, DSDep. ,
DataSet, , DataSet. , MasterSource, MasterSource TPers TDep.
, , , Remove Relationship
. .
. .
.
. 9.50 , TPers TDep. , ( . 9.50 Dep).
, .

(. . 9.10.2). . 9.50 TPers TDep, TPersPro. , .
. , , , , . -
, ,
.
, .
. Comment block ( . 9.50).
(. . 9.50). Comment Allude ( ) , , .

. . 9.50 Dep Pers
. , , ( Starts With) ( Ends With).

626

,
,
Bring to front ( ) Send to back ( ).

. File | Print
Print. , .
, ,
(Print Text as Graphics).
.
. . , ,
.
, dbP: , Dep, ,
Pers. Dep, (. . 9.10.1).
Pro, Proisv Dep
(. . 9.10.2).
(
Components) Table. ( DatabaseName) dbP, ( TableName) Dep Tablel Pers Table2. 2 IndexName depfio IndexFieldNames Dep;Fam;Nam;Par.
, 2 Dep, .
.
, Tablel 2,
Master Detail ( . . 9.51),
. ,
Tablel, , , ,
2. .
2 ,
. 9.10.1 (. 9.42). ,
Dep . ,
(. 9.51).
(Dep), .
DataSourcel ,
. 9.51


IftJOntaModuM
** DataMuduld
C~ 4 Delault (SsssorJ
j-i *, dbP Was}
,&j Constraints

on )

TatlePra
t i l !*1) 1

.J, FindOr's
s i
.- *% PERS.DB [T(Ote21 A
^ HeUieis
* Cj Fields

PERS 08 I
--
>
^^^Masler5cur;e

{12} 1

JDa'aSa1

''it OataSausce')
<u

1.

1.

627

Tablel. DataSourcel Data Diagram,


, DataSet MasterSource 2.
, .
2 Pro.
Data Diagram Lookup ( ) 2 Tablel. (. . 9.10.2, . 9.43). , . 9.43. 2 , Tablel 2 .
, ,
. ,
. 9.51,
Send to back. , .
, . 9.61.
DataSourcc2, 2. DataSource
, . 2, .
. ,
.
2. Table2. A
DataSource2 , Property
( ) DataSource2 2. DataSource2 2 DataSet.
.
Tablel 2
, , , , , .
, C++Builder 5
. , , ,
, , .
C++Builder 6 File | New | Data Module
, , New Data Module. , C++Builder 4 (.
. 9.48). Object TreeView ( , View | Object
TreeView) . 2.5.5.
C++Builder 5. C++Builder 5
C++Builder 6. , (. 9.49-9.51) C++Builder 6 : Components C++Builder 6,
Data Diagram , C++Builder 6.

628

9.14
9.14.1
, BDEClientDataSet,
ClientDataSet , ,
TDataSet, , ,
. , , , , .
, .
, MyBase .
,
- , . ,
.
. , , . , , . , , , .
.
, .

9.14.2 ,
BDE BDEClientDataSet, C++Builder 6
BDE ( C++Builder ). ClientDataSet, C++Builder 6 Data Access.
FileName. ( ), . FileName , . , FileName, , , .
LoadFromFile:
void

f a s t c a l l L o a d F r o m F i l e ( c o n s t A n s i S t r i n g FileName = " " ) ;

FileName ,
, FileName. ,
ClientDataSetl->LoadFromFile("");

,
. , , . LoadFromFile .

629

SaveToFile .
:
void
fastcall SaveToFile(const AnsiString FileNarae - "",
TDataPacketFormat Format = dfBinary);
FileName LoadFromFile. A
Format
:
dfBinary

dfXML

XML escape-

dfXMLUTF8

XML ,
UTF8

(. 9.11.3),
, SavePoint. ,
. -
,
int MySavePoint;
MySavePoint = ClientDataSetl->SavePoint;
, ,

ClientDataSetl->SavePoint = MySavePoint;
,
,
MySavePoint - ClientDataSetl->SavePoint;
, , (. 9.5.2). IndexName lndexFieldName. ,
Table,
,
.
lndexFieldName , , . , Dep;Fam;Nam;Par , , . ,
9.14.3, , . IndexName. , , .
IndexDefs.
. New,
. Name , . Fields
, lndexFieldName.

630

Name Fields ,
IndexName
. , & .
Filter Filtered '
, Table 9,5.6.
. ,
. ++15 | 3 ] .

9.14.3
& .
, - , ..
, , ,
, * , ClienffiataSet. New, . , . 9.52, (, 9.31)
: tnternctiColc Aggregate.
, ,
9.5,4, ,
. Aggregole
. Name, Aggregate.
. 9,52

. 9.52,
,
. , , Expression.
, . , , ,
:
Sum

.
, , .

Count

. imt(*) , .

631

Min

, ,
.

, ,
.

, : , . . :
Max(YearjD)

- Min(Year_b)

Year_b.
Sum(Year_b)

/ Count(Year_b)

Year_b, ,
Avg(Year b)


Avg(2002 - Year_b)

, , 2002 .
, , true Active . , AggregatesActive true.

, . , - ,
,
. , , ..
IndexName .
9.14.2.
.
IndexName , . GroupingLevel , , . , , Dep;Year_b, , ,
. ,
Count(*)
GroupingLevel = 1, , . GroupingLevel = 2,
, , ..
.
GroupingLevel = , .

9.14.4
- , -, . , -

632

, . DataSetProvider Dato Access.


ProviderName.
DataSetProvider.
DataSet ,
. : Table, Query,
.. ,
XML. . , Resolver. , . Resolver = nil.
,
.
ResolveToDataSet ,
, . ResolveToDataSet = true , DataSet.
DataSet.
ResolveToDataSet = false , DataSet. , DataSet. ,
, DataSet , , .
Open , FileName, ,
-, , , .
Data OleVariant.
Data,
. , -
DataSetProviderl ClientDataSetl,
ClientDataSetl->Data = DataSetProviderl->Data;

- -.
ApplyUpdates
:
virtual int

fastcall ApplyUpdates(int MaxErrors);

MaxErrors ,
. MaxErrors = - 1 , . ,
.
,
. , , ,
CloneCursor.
:
virtual void

fastcall CloneCursor(
TCustomClientDataSet* Source, bool Reset,
bool KeepSettings = false);

633

Source ,
. Reset KeepSettings ,
.
Reset, KeepSettings false, , , : Filter, Filtered, FilterOptions, OnFilterRecord, IndexName, MasterSource, MasterFields, Readonly, RemoteServer,
ProviderName. , ,
. Reset = true, . Reset = false, a KeepSettings = true, .
, .
.
.
.
, , Readonly, .

9.14.5
, ,
. , , . 9.53.
. 9.53

|
}
|
[[
9 54 1965
1950
1

5
1930
1937
7 1

19G1
4 1

1975
8 1

JZ.
]

1:
5:'
7 : 1
.
4:llex1

8 ; 1

,
Pers dbP Table.
, .
, ClientDataSet. ,
, . . , , .
,
, . . ,
.

634

, . , . .
.
. 9.54. .
. 9.54

(DBImagei)

Table! DataSctrcel PaiaSetProvideii

|DBImage2J
Cfen!DataSet1

DalaSomceS

,
. Tablel, DataSourcel DBGridl
Pers dbP.
, (
) . Charact Photo, . , ,
. Tablel ReadOnly true, .
IndexName depfio, . DBImage
Photo;
ClientDataSetl, DataSource2
DBGrid2. DBGrid2 DataSource
DataSource2, DataSet DataSource2 ClientDataSetl. DBNavigator DataSource2.
, ,
FileName ClientDataSetl , , ,1, . .
, .. .
,
. , Delphi .
. FileName .
.

635

.
DataSetProvider. DataSet
Tablel. ProviderName ClientDataSetl DataSetProviderl. .
ClientDataSet,
. CreateDataSet . ClientDataSetl
Tablel, , , Tablel. , , Tablel, . Assign Local Data
, ,
.
Tablel. , , Tablel.
Load from MyBase toble ,
, .
, Save to MyBase XML table, Save ta
MyBase XML UTF8 table, Save to binary MyBase file. (
) , ClientDataSet. Clear Data .
, XML MyBase,
. ,
. , . , ClientDataSet.
. , ClientDataSet , .
. 9.54 ,
( , ).
, ,
ClientDataSetl , depfio,
, . , 9.14.2, IndexDefs.
. New, .
Name depfio, Fields Dep;Fam;Nam;Par.
ClientDataSetl IndexName depfio.
, . 9.14.3. . Count.
Expression Count(Dep) .
GroupingLevel 1, IndexName depfio.
, depfio -

636

( depfio
Dep). true Active Count.

. CountAH.
Expression Count(Dep). , Dep . GroiipingLevel
, IndexName . , , . true Active CountAH.
CountAH Count(Dep) Count(*) . .
, Dep
(, , ),
.
, true AggregatesActive ClientDataSetl.
DBImage2, DataSource2 Photo, , . . 9.54 : Label, ( . 9.54) DBText, Dep, Count CountAH.
( BDataBase),
( BToFile) ( BRolIback). . :
int MySavePoint;
bool Modified;
void
fastcall TForml::FormCreate(TObject *Sender)
{
Tablel->Open();
ClientDataSetl->FileName = "XMLl.xml";
ClientDataSetl->Open() ;
ClientDataSetl->SaveToFile("", dfXML);
MySavePoint = ClientDataSetl->SavePoint;
void
fastcall TForral::BDataBaseClick(TObject 'Sender)
{
ClientDataSetl->ApplyUpdates(-1);
Tablel->Refresh();
MySavePoint = ClientDataSetl->SavePoint;
Modified = false;
void
fastcall TForml::BToFileClick(TObject *Sender)
{
MySavePoint - ClientDataSetl->SavePoint;
Modified = false;
void
fastcall TForml::BRollbackClick(TObject *Sender)
{
ClientDataSetl->SavePoint = MySavePoint;
Modified = false;


void

fastcall

637

TForml::ClientDataSetlAfterPost(
TDataSet *DataSet)

Modified = true;

void

fastcall TForml::FormCloseQuery(TObject *Sender,


bool SCanClose)

{
if (Modified)
switch (Application->MessageBox(
" . ?",
" ",
MB_YESNOCANCEL+MB_ICONQUESTION))
(
case IDCANCEL: CanClose = false;
break;
case IDNO: ClientDataSetl->SavePoint = MySavePoint;
}
)

/I
void

fastcall

TForml::ForraClose(TObject *Sender,
TCloseAction SAction)

(
Tablel->Close() ;
ClientDataSetl->Close ();
}

. MySavePoint,
.
Modified ,
. .
FormCreate OnCreate, .
Tablel. .
, . . .
, ClientDataSetl. ,
Tablel .
.
, . ,
. ,
. MySavePoint.
BDataBaseClick
.
ApplyUpdates . Tablel,
.
MySavePoint ,
Modified false, , .
BToFileClick .
MySavePoint ,
. , , - , .-

638

SaveToFile, FormCreate. , ..
BRollbackClick .
,
. Modified false, .
ClientDataSetlAfterPost AfterPost ClientDataSetl. Post
(. 9.11.2) - .
Modified true, , . , Post ,
. , . ?
'
FormCloseQuery OnCloseQuery. Modified,
. , . ,
, MySavePoint, ..
.
,
CanClose false.
, .
FormClose OnClose. . .
. . , Windows , , .

9.14.6 BDEClientDataSet
BDEClientDataSet.
BDE . , SQL Database, . 10. , BDE, BDEClientDataSet . , '
. 10.
BDEClient-DataSet , K
. BDEClientDataSet
, . -1
Database
DBConnection CommandText.
|
. *|"
9.14.5, ClientDataSet BDEClientDataSet
, ( File | Sove Project As) (
File | Save As). ClientDataSetl DataSetProvideritf
BDEClientDataSet Database BDH
DatabaseName Databasel dbP. : '

639

. DBConnection
BDEClientDataSetl Database!.. CommandText BDEClientDataSet. SQL .
, , , FileName .
Select * from Pers ( ,
SQL :
Pers).
CommandText , SQL. . , ,
, .
BDEClientDataSet ClientDataSet. depfio
. , , , ,
ClientDataSetl BDEClientDataSetl.
, ,
. 9.14.5. , ,
C++Builder 6, Delphi 6 ( , ). , BDEClientDataSet,
, -, , IndexDefs. , depfio . ,
. C++Builder 6 , . IndexDefs, FormCreate :
TIndexDef *pNewDef = BDEClientDataSetl->IndexDefs->AddIndexDef() ;
pNewDef->Name = "depfio";
pNewDef->Fields = "Dep;Fam;Nam;Par";
BDEClientDataSetl->IndexName = "depfio";
BDEClientDataSetlCount->IndexNarae = "depfio";
BDEClientDataSetlCount->Index = 1;

,
.




10.1 SQL

10.1.1
SQL (Structured Query Language )
70- . .
, , .
, SQL . SQL ANSI, , . , Sybase SQL Server Microsoft SQL , ANSI. InterBase, Oracle
ANSI,
. , InterBase,
. , , . SQL, , .
C++Builder SQL
:
PARADOX dBase SQL.
InterBase
.
SQL SQL Links.
SQL . SQL , , , Select
SELECT, Select, select. SQL, ";". ,
, .
: /*<>*/,
Pascal: {<>}. , , .
SQL.
.

642

- ..

10

10.1.2 Select
10.1.2.1

SQL Select.
, ,
.
C++Builder Query,
SQL,
Select
. C++Builder, Query Dato Access DatabaseName dbP Paradox,
. 9.
ib InterBase. .
(. . 9.3).
DataSource DataSet
Queryl. DBGrid DataSource
DataSourcel.
SQL .
SQL SQL Queryl, , Active Queryl true. .
Select.
:
SELECT > FROM <>
WHERE < > ORDER BY < >;

1 WHERE ORDER BY . WHERE : , . ORDER BY .


<> Table, ,
, , Pers.

Select, ,
. . ,
SELECT Fam, Nam, P a r , Year__b FROM P e r s

, Fam, Nam, Par Yearjb Pers. SQL Queryl, Active Queryl true .
"*" , . ,
SELECT * FROM P e r s

,
,
+, , *, /.
: AS <>.
, . .

643

, Table OnCalcFields. ,
, . , , Query,
+-kBuilder SQL, OnCalcFields.
:
SELECT Fam, Nam,

(2000-Year_b) AS Age FROM P e r s

Age, (2000Year_b).
,
WHERE. , . Select , . ( ), , , , and, or, not :

:=
>

>=

<

<=

Like
between ... and

in

. ,
SELECT Fam FROM P e r s WHERE S e x = f a l s e and Year_b > 1960

, , 1960 .
Like :
<> LIKE ' "^ >'
true,
, "^ >.
"%", . , . ,
Fam

LIKE

'A%'

, , "" ( Like ).

Faro LIKE '%'

,
Fam LIKE '%%'

, , .

644

10

between ... and :


<> between <> and <>

. ,
SELECT Fam, Year_b FROM P e r s
WHERE Year_b BETWEEN 1960 AND 1970

(
1960 1970).
In :
<> in (<>)

, . ,
SELECT Fam, Year_b FROM Pers
WHERE Fam IN('','','')

,
SELECT Fam, Year_b FROM p e r s WHERE Yearjo IN(1950,1960)

.
Select, ORDER BY, () .
, . , ( SELECT).
.
, . ,
SELECT Dep, Fam, Year_b FROM P e r s ORDER BY Year_b

.
,
DESC:
SELECT Dep, Fam, Year_b FROM Pers ORDER BY Yearb DESC

ORDER BY ,
. ,
.. ,
SELECT Dep, Fam, Year_b FROM Pers ORDER BY Dep, Fam

( Dep), .
SELECT Dep, Fam, Year_b, Sex FROM P e r s

ORDER BY Dep, Sex, Fam

, .
10.1.2.2
Select ,
() ,
. ,
, (<>) ,
. ,
SELECT count(*) FROM Pers

Pers.
SELECT c o u n t ( * )

FROM P e r s WHERE D e p = ' U e x 1'

1.

645

, DISTINCT (),
. ,
SELECT count(DISTINCT Dep) FROM Pers

, Dep Pers.
min(<none>), (<>), avg(<none>), sum(<none>) , , . ,
SELECT min(Year_b), max(Year_b),

avg(Year_b) FROM Pers

, ,
SELECT min(2000-Yearjo), max (2000-Year_b),
FROM Pers WHERE Dep=''

avg(2000-Year_b)

, .
Select , . ,
SELECT 1999- (min (Year__b) +max (Year_b) ) /2 FROM Pers
WHERE Dep=''

( )
. , ,
.
2 2., .. , .
,
SELECT
( ), , , ( , ). , , ,
. , ,

SELECT Fam, m a x ( Y e a r J o ) FROM P e r s

. , , .
,
, GROUP
BY. ,
SELECT. : , , . ,
SELECT Dep, count(*) FROM Pers GROUP BY Dep

, 2 : , , :
GROUP BY
HAVING. ,
:
SELECT Dep, c o u n t (*) FROM P e r s
GROUP BY Dep HAVING Dep

''

, , .

646

10

, HAVING. dbP (Paradox) Query HAVING.


InterBase HAVING .
10.1.2.3
, Select,
Select. , , , . ,
. :
SELECT Fam,Year_b FROM P e r s
WHERE Year_b= (SELECT max(Year_b) FROM P e r s )

SELECT max(Year_b) FROM


Pers ,
WHERE Select ( ),
.
. , ,
Pers Persl, , Pers . ,
Database Desktop Pers, Table |
Restructure, , Save as
, Pers, Persl. , , Pers, - . , ,
Persl Pers, ..
. .
, .
SELECT * FROM P e r s WHERE Fam IN (SELECT Fam FROM P e r s l )

Select Fam from Persl


Pers I, WHERE Select Pers , Persl.
WHERE
: Any. All , , a Any . ,
SELECT * FROM P e r s
WHERE Year_b >= ALL (SELECT Year_b FROM P e r s l )

Pers, Persl. ,
Persl Pers, , .
SELECT * FROM P e r s
WHERE Year_b > ANY (SELECT Year_b FROM P e r s l )

Pers, Pers I.
10.1.2.4
. , ,
.
Pers Dep , . Dep Dep Prosv (true,
). :

647

SELECT Pers.* FROM Pers, Dep


WHERE (Pers.Dep=Dep.Dep)AND(Dep.Proisv=true)

Pers Dep, FROM.


, . , ,
( Dep). Proisv
. WHERE Pers.Dep=Dep.Dep
Dep, Dep Dep Pers. Dep.Proisv=true , Dep Proisv = true.
, ,
, , , .
FROM,
. , ;
SELECT P . * FROM P e r s P, Dep D
WHERE (P.Dep=D.Dep)AND(D.Proisv=true)

Pers , Dep D. ,
, .
.
. , , .

SELECT pi.fam, p2.fam, p l . y e a r _ b FROM Pers p i , Pers p2
WHERE (pl.year_b = p2.year_b) AND (pi.fam != p2.fam)

Pers : pi 2. WHERE . pl.fam != p2.fam , . , , , ,


- , - .
pl.Fam < p2.Fam:
SELECT pl.fam, p2.fam, p i . y e a r _ b FROM Pers p i , Pers p2
WHERE (pl.year_b = p2.year_b) AND (pl.fam != p2.fam)
and (pi.Fam < p2.Fam)

pi 2
.
, , . ,
,
. (outer join). : , .
( LEFT OUTER JOIN ... ON)
, ,
. (
RIGHT OUTER JOIN ... ON) ,
. ( FULL OUTER JOIN ... ON) , .
, , Pers
Chef, -

10

648

. " , .
, Pers
, , .
Chef ,
.
SELECT * FROM P e r s LEFT OUTER JOIN Chef ON P e r s . F a m = Chef.Fam

:
Pers

Chef

Pers (
FROM) Chef ( LEFT OUTER
JOIN). ON
.
, Pers, Chef.
Pers. ,
, Chef , Chef .

SELECT * FROM P e r s RIGHT OUTER JOIN Chef ON P e r s . F a m = Chef.Fam

:
Pers

Chef

Chef. , , Pers , Pers


.

SELECT * FROM P e r s FULL OUTER JOIN Chef ON P e r s . F a m = Chef.Fam

:
Pers

Chef

, Pers, ,
Chef, Pers.

10.1.3
,
SQL .
, . 10.3.2, 10.3.3
Interactive SQL.

649

Insert,
:
INSERT INTO < > >)
VALUES (< :)

, . .
( ) .
:
INSERT INTO Pers (Fam, Nam, Par, Sex)
VALUES ('', '',

'', true)

.
.
Insert , Select. -
. Insert :
INSERT INTO < > < Select>

, , Old_Pers Pers.
:
INSERT INTO Old_Pers SELECT * FROM Pers WHERE Year_b < 193 9

Old_Pers Pers.
Insert
,
.
Update:
UPDATE < > SET < <>=<>>
WHERE <>

, . , 1 2 1, :
UPDATE Pers SET Dep = ' 1' WHERE Dep = ' 2'

Delete:
DELETE FROM < > WHERE <>

, . ,
1 , :
DELETE FROM P e r s WHERE Dep =

' 1'

10.1.4
Create Table:
CREATE TABLE < >
(< < > <>(<>)>)

.
PRIMARY KEY,
, . , NOT NULL, ,
" . :

650

10
CREATE TABLE P.erson (
Fam char(15) NOT NULL PRIMARY KEY,
Nam char(15) NOT NULL PRIMARY KEY,
Par char(15) NOT NULL PRIMARY KEY,
Year_b integer
)

Create Table .
, ,
, .
[1].
Drop Table:
DROP TABLE < >

,
. ( ) ,
Drop Table .

Alter Table:
ALTER TABLE < > <> < > < > . . .

<> ADD , DROP . ,


< >. , . :
ALTER TABLE Pers DROP Year_b, ADD Age integer

10.1.5

. Select ORDER BY
, . .
Create Index:
CREATE

INDEX < > ON < > < >

:
CREATE INDEX depyear ON Pers Dep, Year_b

" Drop Index:


DROP

INDEX < >.< >

:
DROP

Index P e r s . d e p y e a r

,

.
:
ALTER INDEX < > DEACTIVATE
ALTER INDEX < > ACTIVATE

651

10.1.6 Query
10.1.6.1
SQL, ,
. TQuery. ,
Table, Query
Table. Query
SQL.
Table Query. Table.
, , , .
Table .
. , .
Query. SQL
( Select), ( ) . , , Table, - . , ,
, . SQL
- ,
. BDE ,
, . Query
, Table. SQL
, Table.
,
Query Table.
.
Table Query, , Query, Table.
Query, C++Builder Query, DataSource, DBGrid. DataSet
DataSourcel Queryl, DataSource
DBGridl DataSourcel. , : (Queryl), (DataSourcel),
(DBGridl). Query.

Query SQL, TStrings. , SQL.


, , SQL, ,
.
SQL ,
TStrings: Clear , Add ..
Query
, ,
.
Query SQL
Builder. -

652

10

. , ++ilder. ,
, .
, , DataBaseName Query , Table, , . , ( ).
DotaSaurce , .

TableName, Table, Query , .. , , SQL. SQL , ,


.
D G i iv n D G G G

'^^s^^**^**^^-^^^***^^^^^.^^^

, Query,
SQL , ,
. SQL ,
Query . , SQL , . .

, SQL , , , :
Select * from pers

, ,
Query. , . :
Select * from pers, dep

,
Active Query true. ,
DBGridl .

, , ,
. , Select . , , ,
. Queryl RequestLive true. , , . , RequestLive true . , :

( ORDER BY)
Sum, Count .
( CashedUpdates false)

653

.
RequestLive true , ,
.
, . 9
Table. ,
Table, (Field Editor). Query,
Query Fields Editor .
(. . 9.5.2, . 9). ( Add), , , -
(Visible), (Readonly), (;), , , , .
(. . 9.6, . 9),
, , ,
.
10.1.6.2 Query
SQL, . : , , .. SQL
, . , .
, ,
.
, :
:< >

, Select WHERE :
WHERE YearjD <= :PYear

- , , PYear.
Query. SQL , , :
Select * from pers where (year_b>:PYear) and (dep=:Dep)

Params, PYear
Dep (. . 10.1).
. :
DataType

(int, string ..)

Name

ParamType

( , . . 10.3.5.2)

Value

Type Value
,
.

654

10

. 10.1

. Params
TParam, Items[Word Index]. ,
,
SQL.
, , -, Value, As String, Aslnteger .. (.
. 9.11.4 . 9 -). ,
f o r ( i n t I = 0; I < Q u e r y l - > P a r a m s - > C o u n t ; I++)
if ( Q u e r y l - > P a r a m s - > I t e m s [ I ] - > I s N u l l SS
Queryl->Params->Items[I]->DataType -- f t l n t e g e r )
Queryl->Params->Items[I]->AsInteger - - 1 ;

-1 ,
. Count , IsNull, true, , DataType,
, Aslnteger, .
:
Queryl->Params->Items[0]->AsInteger = 1950;
Queryl->Params->Items[1]->AsString = "";

( 0) ( 1)
Query 1, SQL Select :PYear :Dep. :PYear , 0.
Items Params ParamValues.
Variant.
, . ,
Queryl->Params->ParamValues["PYear"] = 1950;
Queryl->Params->ParamValues["Dep"] = "";

, . , .
ParamValues . :
Variant par[] = {1950,"");
Queryl->Params->ParamValues["PYear;Dep"]

= VarArrayOf(par,1);

, ParamByName Query. ,
Queryl->ParamByName ("PYear")->AsInteger = 1950;
Queryl->ParamByName("Dep")->AsString = "";

PYear Dep , .

655

,
.
, . , ,
.
10.1.6,3 Query,
Query Table, (. . 9.5, . 9). ,
SQL. , Table, Fields (, Queryl>
Fields[O]) FieldByName (, Queryl>FieldByName('Dep')).
,
Query , Query
.
(, QuerylDep).

Query , SQL , , .

, .

Value,
AsString, Aslnteger .., Table, , Table, , , , .
, Table, DataSource.
,
. , , , . 10 Table. , Dep, ( Dep) , Pers,
Dep , . ,
Dep Pers , .
. Queryl, DataSourcel, DBGridl : DBGridl
DataSource DataSourcel, DataSourcel DataSet Queryl. Queryl Dep.
DatabaseName (, dbP), SQL
Select * from Dep

Active true , :
DBGridl Dep.
, Query2,
DataSource2, DBGrid2, Pers
Select * from Pers

Query2. Active Query2 true


DBGrid2 Pers.
, ,
. . -

656

10

. SQL
Query2
Select * from Pers where

(Dep=:Dep)

: Dep
:Dep. , . , Params Query2. DataSource Query2 DataSourcel , Dep. , :Dep .
,
. , ,
Query2, , Queryl.
SQL Active
Query2 false. true . , , , .
10.1.6.4 Query
Query .
Close , Active
false. - ,
. , SQL Close ,
, .
Open , SQL. , Select. , , Update Insert, Open EDatabaseError. , Select,
ExecSQL. ,
, . .
Prepare.
SQL Close Prepare .
Open ExecSQL :
,
?. , ssql , :
try
{

Queryl->SQL->Clear();
Queryl->SQL->Add(ssql);
Queryl->Open();
)
catch (EDatabaseErrorS)
{
Queryl->ExecSQL();

657

try (. . 13.10.3, . 13) Open. , .. , Select,


EDatabaseError, catch, ExecSQL.
, Query. GetFieldNames, TStrings, . ,
Queryl->GetFieldNames(ComboBoxl->Items);
ComboBoxl ,
Queryl. .
10.1.6.5 ,
Query UpdateSQL
ExecSQL .
( ),
, ,
, , .
, Table (. . 9.11.3, . 9): true CachedUpdates Query ApplyUpdates , CancelUpdates
CommitUpdates .

UpdateSQL. ,
Data Access, , . ,
Query Select, Select .
, , . 9.11.3, . 9. (. 9.45), Tablel Queryl Tablel
Queryl. SQL Queryl Select * from Pers CachedUpdates true.
, , , , . .
.
Query Select .
. UpdateSQL Dota Access. , Queryl UpdateObject
UpdateSQLl.
UpdateObject.
UpdateSQLl. , Name Tag, 3: DeleteSQL, InsertSQL ModifySQL. , , . , .
UpdateSQL,
UpdateSQL UpdateSQL . , . 10.2.
Options UpdateSQL, , : Key Fields Update Fields.

658
. 10.2
UpdateSQL

Opter JSQL I
SQlSanwiton

Quote Field Nanwt

Key Fields , . ,
,
.
. Ctrl , ,
.
Update Fields , .
, , , , . , , .
, Generate SQL.
SQL UpdateSQL, (Modify), (Insert) (Delete) .
DeleteSQL, InsertSQL ModifySQL, .
ModifySQL :
update Pers
set
Nurn - :Num,
Dep = :Dep,
Fam = : Farn,
Nam = : N am,
Par = :Par,
Year b - :ifear b,
Sex = :Sex,
Charact = :: Charact,
Photo = :Photo
where
Mum = :OLD Num and
Dep = :OLD Dep and
Fam = :OLD Farn and
Nam = :OLD Marn and
Par = :OLD Par and
Year b = :OLD Year b and
Sex = :OLD_Sex and
Charact = :OLD_Charact and
Photo = :OLD Photo

Set , , . *
, Update Fields

659

TJpdateSQL. : UpdateSQL. Where , .


, , OLD_. , . Where ,
Key Fields UpdateSQL.
, .
. , -, ,
.
SQL UpdateSQL,
. , -. .

UpdateSQL , , , (.. Query ), . : Field ... is of an unknown type ( ... )


.
UpdoteSQL ,
Query, Query ,

ModifySQL . ,
where Charact Photo,
.
Num, . , set Num, Autoincrement, :
. Charact
Photo, . ,
ModifySQL :
update Pers
set
Dep = Dep,
Fam = Fam,
Nam - Nam,
Par = Par,
Year b = :Year b
Sex = Sex
where
Num OLD Num

DeleteSQL .

660

1
d e l e t e from Pers
where
Nurn = : 0LD_Num

InsertSQL, . 10.2,
:
i n s e r t i n t o Pers
(Num, Dep, Fam, Nam, Par, Year_b, Sex, Charact,
values
(:Nurn, :Dep, : Fam, :Nam, :Par, :Year__b, :Sex,
:Charact, :Photo)

Photo)

, , , Num, . Charact Photo, . :


insert into Pers
(DEP, FAM, NAM, PAR, YEARJ3, SEX)
values
( : D E P , :FAM, :NAM, : PAR, :YEAR_B,

:SEX)

Table
OnClick . :
Queryl->ApplyUpdates {);
Queryl->CommitUpdates();
Queryl->Close ( ) ;
Queryl->Open () ;
modif = f a l s e ;

, , (Close) (Open) Queryl.


, Queryl . , , ,
, ,
. , Queryl,
. , , ( ).
, , ,
Table. , ,
, .
, UpdateSQL DBNavigator
DBGrid. . .

Apply(Db::TUpdateKind

UpdateKind)

UpdateSQL. UpdateKind, ukModify, uklnsert


ukDelete, , ModifySQL, InsertSQL DeleteSQL.
,
UpdateSQLl->Apply(ukModify)

, ModifySQL.
SQL , UpdateSQL, ExecSQL:
ExecSQMDb: : TUpdateKind UpdateKind)

661

, . ,
SetParams (Db: :Tt)pdateKind UpdateKind)

SQL . , Apply SetParams ExecSQL.

10.1.7 SQL
Query Table
, . 9. . Query Table,
. 10.1.6.1, ,
, . ,
.
SQL , , Query .
, .
, ,
. 10.3. .
. 10.3
,

JYuarb

Selea Dep. Fam. Nam, Pat. Yca( FROM PERS WHERE Yeai b
|
>1950 BY Ye a r t .

Dep
2
1
!

F
ja
m

2

1

Nam

|.

1955
1960

1961
1962
195

1975

1975

1
J;

Select Pers. ( TComboBox, CBFilds) ,


. , (
TComboBox, ) , , . , ,
( MSQL). SQL. DBGridl TDBGrid,
DataSource Query TQuery. .
, MSQL
Select . ^
, , , .

, .

662

10

(
WHERE), ( ORDER BY)
( GROUP BY) , , . , , .
.
// ,
//
enum TRegim {RNone, R F i e l d s , RWhere, ROrder,

REndf Regim;

//
void
fastcall TForml::ADDS(String s)
f
'
// Memo s
MSQL->Lines->Strings(MSQL->Line3->Count-l] =
MSQL->Lines->Strings[MSQL->Lines->Count-l] + s;

void
fastcall TForml:iCBFieldsChange(TObject *Sender)
i
if ((Regim == REnd)I|(MSQL->Lines->Count < 1))
ShowMessage(
" ");
else ADDS(" "+CBFields->Text);
}
//
.
void
fastcall T F o r m l : ; F o r m C r e a t e ( T O b j e c t *Sender)
i
//
Query->GetFieldNames(CBFields->Items) ;
CBFields->Items->Insert(0,"*");
CBFields-Mtemlndex = 0;
CBOp-Mtemlndex = 0;
Regim = RNone;
void
fastcall TForml::BbeginClick(TObject *Sender)
i
MSQL->Clear () ;
MSQL->Lines->Add | "Select " ) ;
Regim - RFields;
}
//
void
fastcall TForml::BexecClick(TObject *Sender)
(
if (Regim -= RNone)
{
ShowMessage(" ");
return;
)
if (Regim -= RFields)
ADDS(" FROM PERS");
Regim = REnd;
Query->SQL->Assign(MSQL->Lines);
Query->Open() ;
)
//
void
fastcall TForml::BWhereClick(TObject *Sender)

663

if (Regim == R F i e l d s )
ADDS(" FROM PERS");
ADDS(" WHERE");
Regim = RWhere;

void
fastcall TForml::CBOpChange(TObject *Sender)
i
if ((Regim == REnd) I I (MSQL->Lines->Count < 1))
ShowMessage(" ");
else ADDS(" "+CBOp->Text);
}
//
_
void
f a s t c a l l TForml::BOrderClickiTObject *Sender)
{

if (Regim = RFields)
ADDS(" FROM PERS");
ADDS(" ORDER BY") ;
Regim = ROrder;
)
//
void
fastcall TForml::BGroupClick(TObject Sender)
i
if (Regim RFields)
ADDS{" FROM PERS");
ADDS(" GROUP BY");
Regim = ROrder;
)

. Regim :
enum TRegirn

jRNone,

RField3,

RWhere,

ROrder,

REnd)

Regim;

, . Regim RNone.
Regim .
, , , . ,
BexecClick Regim , RNone, , , ,
. .
.
ADDS,
, MSQL.
. .
, :
void

f a s t c a l l ADDS(String s) ;

FormCreate OnCreate .
CBFields
. GetFieldNames,
TStrings, .
, ,
. , , ,
.

664

10

10.2
10.2.1

, , ,
( ),
/. ,
,
. , - . , , .
?
(transaction). ,
. SQL,
.
, . . , , , .
Post,
. . . ,
. ,
.
:
,
, , . , , .
, . .
, , (
), ,
.
, .
, , .
, . , .

665

10.2.2 , Database
, ,
. TDatabase, C++Builder , i1 . :

'


(
)
,
Database . Data Access.
Database Table, Query , . DatabaseName.
. , BDE, AliasName, DriverName Params .
AliasName, DriverName Params.

, , Database (. 10.4). ,
( Name).
, ( Alias
Name). Defaults ()
Parameter overrides .
- . , , , ( . 10.4 1) Login prompt , .
. , , , .
Keep inactive connection KeepConnection,
.
DatabaseName, AliasName, DriverName, Params
KeepConnection.
. 10.4

Database
arameter cveeides:

BLOBS 70 CACHE-64
BLOB SIZE-32
WAIT ON LOCKS-FALSE
COMMIT RETAIN-FALSE
ROLE NAMEPASSWORD=1|
Opiiont
I
p eep

10

666

Connected () KeepConnection
. KeepConnection true, . KeepConnection false, ,
Connected true .
Translsolation . :
tiDirtyRead
tiReadCommit
tiRepeatableRead

, , .
, .
.
, . ,
,
.

, ,
, tiRepeatableRead -:
,
. tiReadCommit
.
Translsolation
, .
, , . .
Translsolation
tiDirtyRead

InterBase
Read commited

Oracle
Read commited
commited

Sybase & Microsoft


Read

tiReadCommit
tiRepeatableRead

Read commited
Repeatable Read

Read commited Read commited


Repeatable Read Error
(READ ONLY)
( )

StartTransaction
Database.
Translsolation .
Commit, |
. Rollback i]
, *!
Commit.
,
:
Databasel->StartTransaction() ;
(ExecSQL .)
: - Databasel->Commit();
- Databasel->Rollback();

667

Rollback ,
, . , , , , .
II:i .
SQL . , (,
2 1 ):
Tablel->First();
while (! Tablel->Eof)
f
if (Tablel->FieldByName("Dep")->AsString == " 2")
{

Tablel->Edit() ;
Tablel->FieldByName("Dep")->AsString = " 1";
>
Tablel->Next();
}
Tablel->First() ;

, .
Update. ,

. - , , .
, StartTransaction. .

Query :
UPDATE P e r s SET Dep='4ex I1 WHERE Dep=' 2'

,
Bfe , ,
- .

, .

, . , Pers,
, ,
, :
UPDATE

Pers

SET

Dep='

WHERE

1'

(Num BETWEEN

AND

10000)and(Dep='

2')

1!

UPDATE Pers SET Dep-' 1'


WHERE (Num > 10000)and(Dep=' 2')

10.2.3 SQL Monitor


, ,
SQL Monitor, Databose | SQL
Monitor. SQL Monitor . 10.5 . , SQL Monitor -

10

668

SQL, SQL
Links . .
Options | Always on Tap ,
SQL Monitor .
. 10.5
SQL Monitor ()
().

)
RelNa T12.33
im* S02
tampSQL
SQLExecute
StatemeINTRBASE
nt
- Select" from Pers

14
15
16
1
7
1
19
20
21
22
?.1

1233 02
12-33 02
12:33 02
12:33:02
12:33 02
12:33.02
12:33 02
12:33 02
1/M.W

SQL Vendor INTRBASE - c dsql execute


__j
SQL Stmt INTRBASE-Fetch"
SQLVendoi INTRB4SE isc.dsqljelch
SQL Data Out INTRBASE - Column - 1 . Name - NUM. Type SQLDataOut INTRBASE -Column a 2. Name DEP Type = f
-SQL Data Out INTRBASE - Column - 3. Name - FAM, Type - f
SQL Data Out INTRBASE Column . 4. Name . NAM. Type .
SQLOataOut INTRBASE -Column. 6, Name-PAR. Type-f ,
SOI I M a d i i INTRfiA4F-rniumn.fi Nn.YFAR R TutvO

SQL Data Out INTRBASE Column = 7. Nar


Precision = 1, Scale 0, Data .

* SEX. Type fldZSTRINQ

6)
Categories ]

TiaceCdtcgoiies"

p1 gxecutedQueyi Statemente
j? Input Parameters
17 ;lcbedOala
17 Statement Qpaato
j ns
& Qsnnect / Dsi connect
<
l 7 Xtansacto
i ns
p |

. . _

Options | Trace Options (. 10.5 ), , :


Prepared Query ,
Statements

Executed Query
Statements

Statement
Operations

ALLOCATE, PREPARE, EXECUTE, FETCH |

Connect /
Disconnect

(- '
..)

Transactions

: BEGIN, COMMIT,
ROLLBACK, ABORT

BLOB I/O

BLOB ()


Miscellaneous

Vendor Errors

Vendor Calls

API

669

, , Executed Query Statements Transactions. .


.

10.2.4
, . , .
, , , , . , , , , - , . , .
+-I-Builder . , .
, . ,
.
C++Builder . ,
- ,
Update. SQL Where, , . , , ,
.
Table Query UpdateMode . , Where Update. :
up Where All

Where ( )

upWhereChanged Where ,
upWhereKeyOnly Where
upWhereAll , {|. , Where . upWhereChanged , . , ,
, ,
. upWhereKeyOnly, . ,
, ,
.

670

10

10.3 InterBase
/
10.3.1
, , /.
, , Views *
, . , , InterBase. ,
C++Builder InterBase Borland InterBase Server.
Borland Workgroup,
.
Borland InterBase Server , .
, , , . .
, Borland InterBase
Server, InterBase, , SQL, , , Informix, Microsoft SQL Server, Oracle, Sybase .
InterBase, Paradox dBase, ,
.gdb.
, , .
Borland InterBase Server , .
. , ?
InterBase, , /.

10.3.2 IBConsole
, Borland InterBase Server,:
, . , InterBase
, , .
InterBase, C++Builder 6 5, IBConsole ( -;
Server Manager Ibmgr32.exe, *
...\Program Rles\lnterBase Corp\lnterBase\BIN ...\Program Files\Borland\lnterBase;;
BIN). IBConsole Windows | .*]
InterBase. , InterBase ^
, Tads C++Builder. CnoceR
. 15.3.
;
IBConsole , -^
. 10.6. , , InterBase Servers. peris-f
.

671

.10.6
IBConsole

Server | Register
InterBase Servers. , . 10.7.
Local Engine .
(User Name)
(Password). SYSDBA. (, , ) masterkey. , . ,
IBConsole (. 10.6) .
. 10.7

1 K M I S V

SsMsNan'
J- . , . ' .
ASotHanc
1 ' -

tjslvuok FloteCOt

. --J

1
f? gave Atos Infomiatiiyi '
- Loflin n
ItomaSon

ISYSDBA

, , , . 10.7 (
) .
- Server |
Un-Register.

. IBConsole . 10.6.
, . ,

10

672

Server | Login Login ,


. ,
. .
. , InterBase tb,
' , . Database | Register , Databases.
, . 10.8. File
(, , -, ,
) (, .gdb)
. ,
, , .
, .
. 10.8

3v Local Saver
Debase
~ JF \DATABASEMBASE4B GOB
Efe
\b

Jj
|

p Save Alias n
i fctevSc
in
1*
UsetName:
j"
1
a*

-.-.-.. .
1
DsfaulChaiaciniStt

Alias Name ,
. 10.6. .
, (User Name) (Password). . 10.6 . , , .., .
, IBConsole
, . Database | Canned
,
. Canned
As. , , . ,
.

673

, . ,
InterBase ib, , : ,
( ), 1. ,
, ,
( , .
Windows ).
,
Users . 10.6. Add User. ,
. 10.9. (User Name), (Password),
(Confirm Password) .. . ( ) , . . 10.6 .
. 10.9

.''- ' Jfcsi


Requred f nfc*Fneton
User N erne 1*
, gassword
1"
^ P3V90fL]
' Opto
i nalInformato
in
, &sN
l ame
1
Middle -

1
1

Server | User Sequrity.


, ,
. , SYSDBA. , , ,
.
, Database | Create Database
,
Databases. . , . 10.10. File(s)
.
,
. ,
, (
).
. , . 10.10 .
InterBase . File(s) , . , , .

674
. 10.10

10
JJ*J
Svet Local Server
1

[CVRT~

P R egsler daiabsse
ASas

Alias , . 10.6. Options


. , (Default Character Set) CYRL.
10.3.3 Interactive SQL
Interactive SQL SQL . Interactive SQL C++Builder 6 .
10.3.2 IBConsole (. 10.6) Tools | Interactive SQL
. , .
C++Builder Interactive SQL Wisql32.exe, ...\Program
Files\lnterBase Corp\lnterBase\BIN).
Interactive SQL ,
. 10.11. SQL. . , .
. 10.11
Interactive SQL

Transacto
i n si ACTV
I E.
Data |n,

Stabs!

MUM7DEP

j T'EAR

TSEX *

1950

2 1
3 14**2

!**

1%0
1355

4 1
5

1361 *

1330

6 *2

^30

liU

"JNAM

*J

675

, Query | Execute
. , ,
. 10.12.
1, 9.
fromm. A
, Select
* fromm Pers .
21!

. 10.12

Detail Message:
Dynamic SQL Enor

SQL code-104
T oken unknown - line 1, cliar 9
fromm
Statement Select*[romrnPets

,
. 10.11 .
, .
. Transactions | Commit.
Transactions | Rollback ,
Commit. , Commit Rollback
, . 10.11.
SQL. , . , .
Interactive SQL,
ib.gdb, . , . 10.3.2.
.
, . 10.3.2. ,
. 10.11,
Database | Create Database.
. 10.11
, , :
create table Pers (
Num smallint Not Null Primary Key
Dep char (15)
Fam chai'(20) Not Null,
Nam chai'(20) Not Null,
Par chai"(20) Not Null,
Year smallint DEFAULT 1950,
Sex chai"(1) IDEFAULT ''
Charact blob
Photo blob

676

10
create table Dep(
Dep char(15)
Not Null Primary Key,
Proisv char(l)
);

, Pers Sex ()
1 ,
. InterBase ,
.
ib
. Create Table, , [1].
, ,
Query | Execute ( . 10.11).
SQL , .
Insert
Into SQL. :
I n s e r t I n t o PERS(Num, Dep, Fam, Nam, Par, Year_b, Sex)
Values(1, "", "", "", "",
1950,
"")

, . ,
. , . , Query | Previous (
. 10.11). Values.
, Select . 10.11.
, ..
( Query | Sove Output), ,
( File | Save SQL History
.hst .txt), SQL.
Interactive SQL , SQL, Execute query
, .
, script-.
.sql . Query | Load Script ( C++Builder File | Run an ISQL Script).

( ),
,
:
Connect < > User < > Password <>;

:
CONNECT " c : \ t e s t \ i b . g d b " USER "A" PASSWORD " I " ;

SQL.
: /* <> */.
.
createdb.sql ib.gdb, , (
).

677

10.3.4 Views
(views) , , ,
. , , , Pers. , ,
. , .
, , , .

, - (-
) , . , , . -
( , - , - ,
, ), , , .
:
CREATE VIEW < > AS SELECT < >
FROM <> WHERE <>

:
CREATE VIEW DEP_1 AS SELECT Fam, Nam, Par, Year_b, Sex
FROM Pers WHERE Dep = ' 1'

:
DROP VIEW < >

, , ,
:
DROP VIEW Dep_l

10.3.5
10.3.5.1
, SQL ,
. ,
. ,
, . , , ,
. , .
, InterBase,
, . ,
. InterBase Sybase Microsoft SQL .
InterBase 2 : (Execute),
, (Select), ,
, .
. script- -

678

10

Interactive SQL. Interactive SQL ,


script- . Interactive
SQL .
:
SET TERM * ;
CREATE PROCEDURE < > AS
BEGIN
END"4
SET TERM ;
COMMIT;

Set Term ";" "*".


? InterBase SQL,
, ";".
, InterBase, .
, Set
InterBase """. , , """ InterBase. A
";".
Set Term Create Procedure, . AS
, begin end".

InterBase. Set Term ";", Commit
.
.
script-, :
CONNECT < > USER < > PASSWORD <>;

.
. ,
, .
, , Interactive SQL
.
EXECUTE PROCEDURE <>;

: Interactive SQL,
, ..
.
, ,

DROP PROCEDURE <>;

.
, , , , . '
. Getlnf , .
: , , , .
,
0, , , .

679

:
CREATE PROCEDURE Getlnf(pFam char(20), pNam char(20), pPar char(20))
RETURNS (pYear integer, pDep char(15) , pSex char(l))
AS
BEGIN
pYear=0;
SELECT Year b, Dep, Sex From P e r s
WHERE (Fam=:pFam)and(Nam=:pNam)and(Par=:pPar)
INTO pYear, pDep, pSex;

END;

, ,
, , .
. RETURNS. , , , .
.
. pYear, . Select
, Fa , Nam Par , ( pFam, pNam
). , pYear, pDep pSex (
Into) Year_b, Dep Sex, Select. Select ... Into
. , Select . , pYear 0, . , , .
Interactive SQL
:
EXECUTE PROCEDURE G E T I N F ( " " , " " , " " )

. , .
Interactive SQL .
.
DECLARE VARIABLE < >

as.
10.3.5.2
++ilder Data Access StoredProc. .
StoredProc,
DatabaseName, ,
. StoredProcName. ,
.

680

10

Params. , , , .
, Query (. 10.1). ,
. ,
, :
ptUnknown
ptlnput
ptOutput
ptlnputOutput
ptltesult

.
, .
, .
, .
, .
.

. . .

StoredProe
, .
.
Params . ParamBindMode StoredProe . :
pbByName pbByNumber . , ParamByName. , StoredProcl->ParamByName("PFAM") PFAM. , , .
Params . , StoredProcl>rams>Items[0] .
. Params.
.
ParamByName .
, Getlnf.
FamEdit, NamEdit ParEdit, , , . LDep, LYear LSex, . , :
StoredProcl->ParamByName("PFAM")->AsString = FamEdit->Text;
StoredProcl->ParamByName("PNAM"j->AsString = NamEdit->Text;
StoredProcl->ParamByName("PPAR")->AsString = ParEdit->Text;
StoredProcl->ExecProc();
if (StoredProcl->ParamByName("PYEAR")->AsInteger 0)
Application->MessageBox(" ",
"",MB J3K);
else
{
LDep->Caption = StoredProcl->ParamByName("PDEP")->AsString;

681

LYear->Caption = StoredProcl->ParamByName("PYEAR")->AsString;
LSex->Caption = StoredProcl->ParamByName("PSEX")->AsString;
)

, , .

, , , .
, .
, ib.
10.3.5.3
. , .
, Selectd,
, .
CREATE PROCEDURE S e l e c t d
RETURNS
(pFam c h a r ( 2 0 ) ,
pPar char(20),
AS
BEGIN

(pDep c h a r ( 1 5 ) )
pNarn c h a r ( 2 0 ) ,
pYear i n t e g e r ,
PSex

char(l))

FOR SELECT Fam, Nam Par, Year_b, Sex From Pers


WHERE (Dep=:pDep)
INTO pFam, pNam, pPar, pYear, pSex
DO
SUSPEND;
END;

Create Procedure , . (
pDep) ,
Returns. , , begin...end,
For Select.
, Select ... Into
, .
, , Do, . ( ) SUSPEND, SQL, .
", . Select,
. . , WISQL :
Select

from Selectd

("")

Select
.
C++Builder
Query, StoredProc, Select. , StoredProc. , , ,
SQL.

10

682

10.4 Microsoft
ActiveX Data Objects (ADO)
10.4.1 BDE ADO
C++Builder 5 Microsoft ActiveX Data Objects (ADO).
ADO , , , ,
. OLE DB.
ADO Borland Database Engine (BDE),
.
ADO (
ADO Windows). , , , Microsoft
SQL Server, ODBC OLE DB ,
.
ADO C++Builder ,
ADO. ADO,
Connection, Command Recordset. C++Builder
ADOConnection, ADOCommand ADODataSet.
ADO : =* ( DataSource)
(DBGrid, DBEdit .).
, , Data
Access , ADO.
, ADO,
, BDE:
ADO
ADOTable
ADOQuery
ADOStoredProc
ADOConnection
ADODataSet
ADOCommand
RDSConnection

BDE
Table
Query
StoredProc
Database
Table, Query, StoredProc
-

1 ADO.

ADOConnection

ADO.
.

ADODataSet

, , BDE Table, Query, StoredProc.


. , ADOConnection.

683

ADOTable
ADOQuery

. , ADOConnection.
SQL, DDL (data definition language), CREATE TABLE.
, ADOConnection.

ADOStoredProc

, . ,
ADOConnection.

ADOCommand

SQL,
.
. , ADOConnection.

, ADO BDB, BDE . ,


, .
ADO . , Paradox ADO .
, , BDE
, Unicode . ADO
.
,
, BDE ADO.

10.4.2 ADO
BDE Table, Query , ADO
DatabaseName, .
ConnectionString,
ADOConnection,
Connection .
ConnectionString
ADOTable. ConnectionString
, .
. C++Builder , .
ADOTable
ConnectionString.
, . 10.13. Use Dofa Link File
. 10.13

Source of C

' Use Date File

&UmQam
on
ictS
n
rig

ns<l TNeads"3,UlD=admniiserCoiri*S3rkc=Yes"

&.

10

684

.ndl. . Use Connection String, , . Build ().


.
, , , C++Builder.
ODBC. Windows. ODBC,
.
ODBC
Windows, , . Windows XP.
, , . 10.13 Build,
.
(Provider , ) OLE DB,
. Microsoft
OLE DB Provider for ODBC Drivers. , Microsoft SQL
Server Oracle .
, (Connection)
(. 10.14). , , .
,
ODBC. (Use data source name),
(data source name
DSN), ODBC. , ,
, .
(Use connection string)
, DSN.
. 10.14

| \ |
***| ODBC yuawctfre .
1 *1!<
f *1

*"
jCoMjSetHJence^Sai.DBQ-F
2.

*- j
_______

, (
:

"
:

685

(Use connection string) (Build). , . 10.15.


:
(File Data Source),
(Machine Dota Source).
, , .
(New).
. 10.15

**. |

"dBASE Files

EMCBI te
fis
M
S Access Database
MS Access
dBASE
Excel
<l

, '
,
-

,
.
Paradox dbP
Microsoft Paradox Driver (*.db).
. ,
, , , ..
. 10.15,
.
, . 10.15 , (Connection) . . 10.14.
, . 10.13, . Paradox :
Provider-MSDASQL.I; P a s s o r d = l ; P e r s i s t S e c u r i t y Info=True;
User ID=a; Extended P r o p e r t i e s = " C o l l a t i n g S e q u e n c e = A S C I I ;
DBQ=F:\DATABASE\DBPAR; DefaultDir=F:\DATABASE\DBPAR;
D r i v e r H M i c r o s o f t Paradox Driver (*.db ) } ; Driverld=538;
FIL=Paradox 5.X; FILEDSN=D:\Program Files\Common Files\ODBC\Data
Sources\dbP.dsn; MaxBufferSize=2048; MaxScanRos=8; PageTimeout=5;
ParadoxNetPath=D:\WINDOWS\System32; ParadoxNetStyle=3.x;
ParadoxUserName=admin; S a f e T r a n s a c t i o n s - O ; Threads=3; UID=admin;
UserCommitSync=Yes; "

, , .
. 10.14 :
(User name), (Password), (Enter the initial catalog to use). (. User
=). ( )
.

686

10

, (Allow saving password).


, : Password=l. , ,
. ,
,
C++Builder.
(Blonk password) .
, , , , .
(Test Connection) .
. , : Test
connection succeeded, . - ,
.

. 10.14 (Advanced)
. () .
, , ConnectionString
.
. ,
.
. 10.15 ,
- . 10.14
(Use data source name)
.
. 10.15 ,
(File Data Source) . ,
.udl. , ,
Windows. , Windows ( ...Common Files\
System\Ole DB\Data Links), . 10.13 Use Dato Link File .

10.4.3 ADOConnection,

ConnectionString, ,
Connection, ADOConnection. ADOConnection,
, ConnectionString.

Connection ADOConnection.
, ADOConnection, , ADOConnection
.

687

Active = true, .
Connected ADOConnection, , true. : ADOConnection?.
ADOConnection . ADOConnection , , . ADOConnection
. - ADOConnection.
ADOConnection Open:
HIDESBASE void _ fastcall Open(const WideString UserlD,
const WideString Password);
:
ADOConnectionl->Open("A","1");

UserlD Password
. , . 10.4.2, ConnectionString. , . , LoginPrompt ADOConnection true.
LoginPrompt, , Open.
Close. tion , , . KeepConnection true ( ) ,
.
CloseDataSets, , ADOConnection,
ADOConnection.
true false Connected.
.
Connected true, . Connected false KeepConnection false, .
Connected ADOConnection Active
, ADOConnection.
Connected = false, Active true, Connected,
true. ADOConnection Close Connected false, Active false. Connected Active.
ADOConnection Open Connected = true, Active false.
.
.
DataSets ADOConnection, , ADOConnection. DataSetCount. ,
. , :

10

688

for(int i = 0; i < ADOConnectionl->DataSetCount;


ADOConnectionl->DataSets[i]->ftctive = true;

.
CursorLocation ,
: . clUserClient (
) . - .
, . , SQL
; WHERE SQL.
CursorLocation, clUseServer, , . .
.
BeginTrans, ,
. BeginTrans OnBeginTransComplete InTransaction true.
, . OnBeginTransComplete - .
CommitTrans
. CommitTrans OnCommitTransComplete InTransaction false.
RollbackTrans : ,
. RollbackTrans OnRollbackTransComplete InTransaction true.
Attributes , , . ,
, : xaCommitRetaining
xaAbortRetaining.
xaCommitRetaining , ( CommitTrans).
.
xaAbortRetaining , ( RollbackTrans). .
IsolationLevel . :
ilReadUncommitted,
ilBrowse

,
.

ilReadCommitted,
ilCursorStability

, .

ilRepeatableRead

, ,
,
.

ilSerializable, illsolated

689

10.4.4
ADO ADOTable. Table, .
. ConnectionString Connection, . 10.4.2.
, ADOTable, DataSource, DataSet ADOTable. DataSource
.
, Table, TableName.
. SQL SELECT.
: SELECT , TableDirect. TableDirect = false, ADOTable SELECT.

, BDE,
Open true Active. , ADOConnection,
. 10.4.3 Active ADOTable
Connected ADOConnection.
ADOTable , , . CursorLocation
. 10.4.3. CursorType .
:
ctUnspecified

ctOpenForwardOnly .
.
ctKeyset

, , , , , . .

ctDynamic


, : , , . .

. , , .

ctStatic

CacheSize ,
. CacheSize = 1. , ,
CacheSize = 10, 10 . ,
. 10, 10 .. , .
ADOTable ,
Table. , Table Query,
,

690

10

, BDE. ,
: ADO . .
, , ADO
. , Paradox ADO . Pers dbP, ,
Photo .
, BDB,
. .
,
Table Query: Fields[i], FieldByName("<HMH>"), .
ADOTable (. . 9.5.3). , Constraints
Table Query, ADOTable .

IndexFieldNames. ,
, . , Dep Pers Dep
. Dep;Fam;Nam;Par Dep , , . IndexFieldNames BDE,
ADO , , . ADO.
, BDE, Filter, (. . 9.5.5). BDE , ADO Filter .
and or. , BDE :
(Year_b<=1960) and (Year_b>=1940)

ADO :
(Year_b <= 1960) and (Year b >= 1940)

Filter , Filtered = true.


OnFilterRecord (. . 9.5.5).
FilterGroup.
, , ,
. :
fgUnassigned
fgNone

He . .
.
|
-
.
.
1

fgPendingRecords

, ,
UpdateBatch
CancelBatch.
i

fgAffectedRecords

691

fgFetchedRecords

,
.

fgPredicate

fgConflictingRecords ,
, - .
, , ADO , Table Query. First, Next, Last Prior.
, Table: Insert, Edit, Post . ADO Locate Lookup. . 9.11.6.
, BDE, .
SaveToFile:
void __fastcall SaveToFile(const WideString FileName,
TPersistFormat Format);
FileName , . Format .
: pfADTG ADTG (Advanced Data Tablegram),
pfXML XML ( ADO 2.1 ). :
ADOTablel->SaveToFile("Test.adt",pfADTG) ;
LoadFromFile:

void
fastcall LoadFromFile(const WideString FileName);
FileName . .
.
SaveToFile LoadFromFile
- . , , , ,
- - .
ADOTable, , , ,
, Table, MasterSource MasterFields
(. . 9.10.1).
ADOQuery
Query, BDE. SQL. SQL, ,
Query. , ADOTable.
Query
. SQL , Query TParams, , Items Params. , Items, ByName, (. . 10.1.6.2), , :

692

10
// string
Queryl->Params->Items[0]->Value = E d i t l - > T e x t ;
Queryl->Params->Items[0]->AsString = E d i t l - > T e x t ;
Queryl->ParamByName("Dep")->AsString = E d i t l - > T e x t ;
// integr
Queryl->Params->Items[1]->Value = Edit2->Text;
Queryl->Params->Items[1]->AsString = Edit2->Text;
Queryl->PararaByName("PYear")->Value = Edit2->Text;
Queryl->Params->FindParam("PYear")->Value = Edit2->Text;
Queryl->Params->PararaValues["PYear"] - Edit2->Text;

ADOQuery , ,
SQL, Parameters TParameters.
,
TParams. Items,
Value, AsString, Aslnteger .. . ByName, FindParam, GetParamList, ParamValues Parameters,
Params Query. , :
// string
ADOQueryl->Parameters->Items[0]->Value - Editl->Text;
ADOQueryl->Parameters->ParamByName("EDep")->Value = Editl->Text;
ADOQueryl->Parameters->ParamValues["EDep"] = Editl->Text;
// integr
ADOQueryl->Parameters->Items[1]->Value = Edit2->Text;
ADOQueryl->Parameters->ParamByName("PYear")->Value = Edit2->Text;
ADOQueryl->Parameters->FindParam("PYear")->Value = Edit2->Text;
ADOQueryl->Parameters->ParamValues["PYear"] = Edit2->Text;

ADOQuery Query , Query , SQL. ADOQuery .


Parameters ,
Add ( ).
,
, - , , Query.
DataType, Name, Value Query. Direction ADOQuery Query.
Size ,
Precision NumericScale
.
Attributes , psSigned
, psNullable ,
psLong .
ADOStoredProc StoredProc, BDE. . , StoredProc (. . 10.3.5.2).

693

, , dureName, StoredProcName, StoredProc. ,


, Parameters,
ADOQuery, . ADOStoredProc.
,
ADOStoredProc,
Add all fields. , .
, , :
ADOStoredProcl->ExecProc();


ADOStoredProc.
, , ADO.
, , .

10.5 InterBase InterBase Express (IBX)


10.5.1 InterBase Express (IBX)
, C++Builder 5, InterBase,
InterBase , BDE.
InterBase, BDE.
IBX , InterBase :

IBTabie

, Table
.

IBQuery

, Query.

IBStoredProc

, .

IBDatabase

InterBase.

IBTransaction

InterBase. , , . .

IBUpdateSQL


. ,
.

IBSQL

SQL,
C++Builder.
InterBase.

10

694

IBDataSet
IBDatabaselnfo

IBSQLMonitor
IBEvents

SELECT
SQL , .
, IBSQL, .
InterBase,
, , , , ..
/ .
InterBase.

, InterBase.
.
IBX IBDatabase
IBTransaction. IBDatabase ,
IBTransaction . : IBTable, IBQuery, IBStoredProc, IBDataSet, IBSQL, . Database IBDatabase, Transaction IBTransaction. DataSource,

.
. 10.16 ,
IBX. ,
.
. 10.16
(), IBX,
()

695

10.5.2 IBDatabase IBTransaction


IBX , . 10.5.1,
IBDatabase. IBX
, , ADOConnection ADO (. . 10.4.3). , , DatabaseName. InterBase . :
D: \DataBase\dbIbase\Ib.gdb


, .
InterBase , TCP/IP, DatabaseName :
< >:< >

InterBase , NetBEUI, DatabaseName :


\\< >\< >

InterBase , SPX, DatabaseName :


< >@< >

IBDatabase. , . 10.17.
Database ( Browse), : ,
(User Name) (Password). Settings. Login Prompt . ,
Login Prompt, .
. 10.17

SQLDialect SQL, .
LoginPrompt ,
.
Connected . Open -

696

10

, Close . Connected
true false.
CloseDataSets, , IBDatabase,
IBDatabase.
Connected IBDatabase Active , IBDatabase. , . 10.4.3 ADOConnection.
IBTransaction, . StartTransaction.
InTransaction.
true, , .
Commit
Rollback .
StartTransaction , , , Commit Rollback.
Commit , . Rollback , .. , ,
.
, :
IBDatabasel->Open();
DataModule2->IBTransactionl->StartTransaction() ;
,
if(< ,
..>)
IBTransactionl->Commit();
else IBTransactionl->Rollback();

:
IBTransactionl->StartTransaction();
IBDatabasel->Open();
if

(Application->MessageBox(
" ?",
" ",
MB_YESNOCANCEL+MB_ICONQUESTION) == IDYES)
IBTransactionl->Comrait();
else IBTransactionl->Rollback();

Commit Rollback
Active IBTransaction false. IBTransaction
IBTransaction
, IBDatabase. , IBDatabase.
. DefaultDatabase
IBDatabase, .
IdleTimer , ,
, . Default Action, :


taRollback

taCommit

697

taRollbackRetaining .
InterBase 6.
taCommitRetaining


OnldleTimer, - , , .
DatabaseCount Databases IBDatabase, , .

10.5.3 IBTable, IBQuery,


IBStoredProc
IBDatabase
IBTransaction Database Transaction,
. 10.5.1.
IBTable Table, BDE, ,
Table. , UniDirectional, , . , , , IBTable . , , .
IBTable Table.
Locate Lookup.
. 9.11.6.
IBQuery Query, BDE. SQL.
IBQuery Query.
IBStoredProc StoredProc, BDE. . , StoredProc
(. . 10.3.5.2).
StoredProcName,
StoredProc. , , Params . StoredProc . StoredProc , . IBStoredProc , . , , ParamByName.
,
StoredProc IBStoredProc, , , IBDatabase IBTransaction.

10

698

10.6
dbExpress
10.6.1
C++Builder 6 dbExpress, , . ++ilder :

InterBase driver

DBEXPINT.DLL

InterBase 6.5

DB2 driver

DBEXPDB2.DLL

DB2 7.x

Oracle driver

DBEXPORA.DLL

Oracle 8.1.7

MySQL driver

DBEXPMYS.DLL

MySQL 3.23.xx

Informix driver

DBEXPINF.DLL

Informix 9.21

SQL
. dbExpress
DLL , , , .
..
dbExpress :

SQLConnection

dbExpress .

SQLDataSet

,
SQL .

SQLQuery

,
SQL .

SQLStoredProc

, , .

SQLTable

, .

SQLMonitor

, , .

SQLClientDataSet

,
SQLDataSet DataSetProvider
.

. . - . -;
. ~:
dbExpress. -*:
dbExpress.

699

, . ,
First Next. , , .
, . CanModify false . , , , .
, SQL UPDATE.
. , ,
dbExpress SQLClientDataSet,
.
, .
, ,
SQL.
, , .
, dbExpress , .

10.6.2 SQLConnection
dbExpress SQLConnection. , dbExpress
.ini. dbxdrivers.ini, DLL . :
[DB2]
GetDriverFunc=getSQLDriverDB2
LibraryName=dbexpdb2.dll
VendorLib=db2cli.dll
Database=DBNAME
User_Name=user
Password=password
BlobSize=-l
ErrorResourceFile=
LocaleCode=0000
DB2 TransIsolation-ReadCommited

dbxconnections.ini, . SQLConnection
. :
[ib]
DriverName=Interbase
Database=f:\database\ibase\ib. gdb
RoleName-all
User_Name=a
Password=l
ServerCharSet=
SQLDialect=l
BlobSize=-l
CommitRetain=False
WaitOnLocks=True
ErrorResourceFile=
LocaleCode=0000
Interbase TransIsolation=ReadCommited

'

10

700

SQLConnection ,
ConnectionName . .
, .

dbxconnections.ini ,
, SQLConnection.
. 10.18.
, ,
. , Add Connection.
. . 10.18
.
. 10.18

dbExpress

: dbEHpr ess Connections: .

r Name

Connection Name
DB2Connecbon

B
II nfCo
nK
e
o
tionmecotin
on
tm
ioc
C
M
y
S
O
L
C
n
e
Oe
ice
iConnenc
o
ilco
nitn

Cortnecttori Settings

Key
DftverName
Database
RdeName
Use_tName
Passwad
ServerChatSet
SQLDatecl
Bo
lbSzie
CommtR
ietani
WatO
i nc
lxks
EfrafResouceRe

Vau
le
i
n
iterbase
KdatabaseSbaseSb
igdb
aN
a
1
1
-1
Fasle
Tu
ie

Database. InterBase .gdb. Oracle TNSNomes.ora. DB2 . MySQL ,


CREATE DATABASE.
, User_Name Password.
, , .
Test Connection ( . 10.18)
. , ,
.
, , , dbxconnections.ini.
, , . 10.18. ConnectionName
SQLConnection.
DriverName ( ), LibraryName ( ), VendorLib ( ), Params ( , . 10.18).
, ,

dbxconnections.ini, -

701

. , - (, , ,
.), . ConnectionName LoadParamsFromlniFile:
procedure LoadParamsFromlniFile( AFileName

String -

''

) ;

, ConnectionName. AFileName , dbxconnections.ini. , .


LoadParamsFromlniFile ,
. , , trne
LoadParamsOnConnect. dbxconnections.in.
SQLConnection
, Connected.
, Open Close .
SQLConnection , . , StmtsPerConn. ( Connected = true). MaxStmtsPerConn = 0,
. MaxStmtsPerConn > 0, ,
. ,
SQL, . ,

ActiveStatements.
SQLConnection,
,
AutoClone. true. , , MaxStmtsPerConn. , . - . AutoClone =
false, .
, . ActiveStatements MaxStmtsPerConn,
CloneConnection, . ,
SQLConnection.

10.6.3 SQLTable, SQLQuery,


SQLDataSet, SQLStoredProc, SQLClientDataSet
SQLTable, SQLQuery, SQLDataSet, SQLStoredProc .
10.6.1. SQLConnection. SQLConnection
.

702

10

SQLTable , TableName. SQL


.
SQLQuery , SQL.
SELECT SQLQuery
. : INSERT, DELETE, UPDATE,
ALTER TABLE .. SELECT Open Active true. ExecSQL:
function ExecSQL(ExecDirect:

Boolean - False):

Integer;

ExecDirect , . , dbExpress . ,
ExecDirect = true. , ExecDirect = false
.
, Prepared.
Prepared true,
ExecSQL .
, ExecSQL . , , , ,
. Prepared
false.
ExecSQL ,
. RowsAffected.
SQLStoredProc 10.3.5
StoredProc .
StoredProcName. , SQLStoredProc Open true Active. SQLStoredProc. , :
function :

Integer;

, . RowsAffected.
SQLDataSet . SELECT , , . , . , , , ..
CommandType CommandText. CommandType = ctQuery, CommandText SQL.
SELECT, .
SQL , ExecSQL. SQLTable, SQLDataSet.
CommandType = ctStoredProc, CommandText . , . ExecSQL.

703

CommandType = ctTable, CommandText . . SortFieldNam.es ,


, . SortFieldNam.es .
NoMetadata. , true, . , NoMetadata = true . , (, / SQLTable) NoMetadata = false.
SQLClientDataSet
dbExpress. , dbExpress, DataSetProvider SQLDataSet.
, . 9.14, . 9, SQLDataSet. SQLDataSet, DBConnection CommandType CommandText. . 9.14.
.

10.7 MIDAS
MIDAS (Multitier Distributed Application Services) .
MIDAS : DCOM, CORBA, OLEnterprise, HTTP, TCP/IP, MTS .
MIDAS :
, . . , . , , - , .
, -
. C0RBA, MTS ..
, .
,
RDBMS. ,
, . ,
C++Builder.
. 1.4, . 1 . 7. MIDAS
. 9.14, . 9. MIDAS,
ClientDataSet DataSetProvider MIDAS. , , , ClientDataSet
ConnectionBroker RemoteServer, .
SOAPConnection, SocketConnection, WebConnection, DCOMConnection, CorbaConnection, WebSnap. - Multitier , ,
RemoteDataModule CorbaDataModule.



11.1
Decision Cube
11.1.1
, ,
C++Builder , Decision Cube. () .
. , , Pers, , , , , . .
,
, , , ..

- , ,
, , , . ,
, . Decision Cube.
:
DecisionCube
DecisionGraph

.
, ,
.

DecisionGrid

, , .

DecisionPivot

.
DecisionQuery ,
. Query,
Decision Cube.
DecisionSource , DataSource, Decision Cube.
|

. , Pers
ib dbP. ib . -

11

706

Pers dbP
Sex. , , ,
Persm, Pers,
Sex. dbP .
, Pers.
DecisionQuery, DecisionCube,
DecisionSource DecisionGrid. DecisionQuery, DecisionCube DecisionSource . .
DecisionGrid .
Align alClient, .
,
, , .
DecisionGridl DecisionSource DecisionSourcel. DecisionSourcel DecisionCube
DecisionCube 1. DecisionCubel DataSet DecisionQuery 1. :
(DecisionQuery) => (DecisionCube) => (DecisionSourcel) => (DecisionGrid). , ,
.
DecisionQuery 1.
. Decision Cube, . 11.1.
. 11.1

Decision Cube

mm IBffifefcvi*
Dimensions/Summaries j SQL Query
j_isl of Available Fields
dimensions
Hum
. Dep
ep
Sen
?
_ d Year_b
Fam
'
Ham
, j
Par
,
_Li
Year b
Surmiaries:
Sex
OUNT) Year b]
Charact
i j C
Pholo
' I SUM(Year_b!
gdd
Xable:
PERSM
SQL Builder... j

Database'
jj dbP
i

OK

t~ Count (") for Averages


jrj

||

Cancel

Query Fields
j

H*

Database ,
, Table . (List Of Available Fields)
. , .
List Of Available Fields Dimensions .
, .
Dimensions .
, ,
. ,

707

Dimensions.
, . 11.1.
Summaries ,
,
. , , , , , .
, .. . Yearjb,
. Year_b
Summaries.
: sum , count average .
average. Summaries AVGjYEAR_B), SUM(YEAR_B|
COUNT(YEAR_B). , .
SQL Query (. 11.2) SQL,
. :
SELECT Dep, Sex, _, SUM( Yearjb ), COUNT ( Year b )
FROM "PERSm.DB"
GROUP BY Dep, Sex, Yearjo

SELECT (Dep,
Sex, Year_b), . GROUP BY.
, , ,
SELECT. , Edit Query, -
. Edit Query Edit Done. ,
, , - . Edit Cancel .
. 11.2
SQL Query
Decision Cube

Dimensions/Summaries SQL Quay |


fluetji Text
SELECT Dep.Sex. Year_b. COUNT( Yea_b ), SUM[ Year_b )
FROM PERSM
GROUP BY Dep. Sex. Yeai_b

dit Done

Cancel Ed*

Cancel

Help

, SQL,
.
SQL , . -

708

11

, COUNT(YEAR_B) SUM(YEAR_B)
(. 11.2). Dirnention/Surnmaries, , Summaries (.
. 11.1).

. 11.1 11.2 SQL Builder. SQL,


.
Decision Cube.
, .
, SQL Database SQL DecisionQuery.
, DecisionQuery .
. Active true.
DecisionGridl
(. 11.3).
. 11.3

i
!

"

4
4


DecrsoinQuerylDecsionCubel

. 2
9
11

Decisions ourcel

, . . . DecisionCubel, DimensionMap ,
Decision Cube Editor.
, . 11.4.
. 11.4
Decision Settings

Dimension Settings I Memo Control I


Available Fields
Dep*
Sex-

Ds
ipa
i y Ha

Ivpe

l r.,ii":?

Active Type
Formal

As Needed

Year b"

SUMOFYea_ib"
Average ol PERSM.Year_b"

709

Decision Settings , Available Fields, Display Name , .


Available Fields :
. .
Active Type ,
: As Needed , Active , Inactive . As Needed.
Format . Grouping (None), : Year , Quarter ,
Month , Single Value . ,
, .
Memory Control
. ,
Designer Data Options, ,
. .
( , Display Name )
, .
.
DecisionGrid Dimensions.
, ,
. (DisplayName), Subtotal
,
: , , ,
. , , , Subtotal = false.
" # # # 0 . # " . , , - , ,
0, 0 .
DecisionGrid DefaultColWidth . .

.
LabelColor LabelSumColor . , , , .
DecisionGrid Options.
cgGridLines cgOutliner .
cgPivotable .
.

11.1.2
(. 11.5).
, "+" , "-" . (. 11.5.),
. ,
, .
.

11

710

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

j^jOl.xl
1
,
I
US! 2
* j 1961
i
i
I 1965
1
1
t
2
M
1930
1
1
2
1937
i
1
1950
,1
1955
l
1
I960
i
1
1*2
1
1
1975
i
1
2

2
3
4
11
3
4
4

.
, (. 11.6), Subtotal
on/off , . Subtotal on/off . . ,
. 11.6

Subtotals on/off
v"
v"
irp.
v* .
.
, .,

711

" + " "". , . , . .., , .



. Subtotal on/off :
Display Doto and SubTotal ,
, Display Data Only
.
- , Drill in to this value. .
, DecisionGrid Options cgPivotable.
. , .
.
. - . , .
, . , , DecisionGrid cgPivotable Options.

. ,
true ShowCubeEditor DecisionGrid. (.
. 11.6) , .. ,
. 11.4. ,
.. ,
, .
, , , Decision Cube, , .

11.1.3 DecisionPivot
DecisionPivot
, .
, Align DecisionSource DecisionSourcel. ! ,
DecisionPivot, , ,
cgOutliner Options DecisionGrid.
" + " "-",
. 11.5 . Options cgPivotable, .
, (. 11.7).
DecisionPivot . , , .
, ( ). ,
( ..)- -

11

712
. 11.7
DecisionPivot

^t <

)
. .-

H j

| | ^ 1

] |
j-|4 S * - - j

1940
1948.3

.jag

1961

1957,3

155.5

1963
1957

1958.3

1955.5

1954.5

6)

-J.Qi.xl

. I

ft

2
2

11

)
'

|]I

\Sn-r

^ ^ ^

2
1

, ().
.
,
.
,
.
DecisionPivot
. - Drilled in,
(. . 11.7 ).
. , , Open Dimention (..
), All Values ,
. -
(. 11.7 ) , . , . , , - , - .

713

11.1.4 DecisionGraph
Decision Cube
DecisionGraph.
. DecisionGraph
(. 11.8) Decisionsource DecisionSourcel.
DecisionGrid
Align alBottom. . ,
, .
, ,
.
. 11.8

DecisionGraph Chart (. . 3.6.4, . 3). ,


, .
Decision Cube ,
. , .
Decision Cube ,
, . ,
Decision Cube (, ). Decision Cube +-(-Builder.

11.2
+-(-Builder QuickReport. QReport .
QuickReport , .
(band) , , , , ..
, .
,
, -

11

714

. , , , ,
.
, ,
,
. , , , .
. 9 10 dbP,
. 11.9. ,
... :

...,
.

|
|
|

, |
..., j
, , - t
, , , S
.
i,

, , j

...
.
. , , .
, .
, , QuickRep.
, , , , . , .
QuickRep , :
PrinterSetting

Page

PaperSize ( Custom Length Width),

Options

,
(FirstPageHeader)
(LastPageFooter)
, ..:
, , ..

Units
Zoom

ReportTitle

715

. 11.9.


31.03.2002

mi
. .
mi i> IJ


' 1

DataSet , .
TTable, TQuery ..
QuickRep : Preview , Print .
. QuickRep Preview. , , , .
QRLabel, QRMemo, QRRichText, QRShape, QRImage, , Label,
Memo, RichEdit, Shape, Image. QuickReport , . , : Frame Size.
Frame , : Color , Style , Width , DrawBottom, DrawLeft,
DrawRight, DrawTop , ,
.

11

716

Size ,
. , Units QuickRep.
AlignToBand . true, , Alignment: taLeftJustify , taCenter , taRightJustify .
.
QuickRep. Table, TDep
Dep dbP. DataSource, DSDep TDep.
Table, TPers Pers dbP.
, TDep ,
TPers Dep ( TPers
IndexName, MasterSource, MasterFields . . 9.10.1).
Active Table true.
DataSet QuickRep TDep,
.
QuickRep Bands. :
HasTitle
HasDetail
HasPageHeader
HasPageFooter
HasColumnHeader

,
.
,
, .
() .
.
.

true HasTitle
HasPageFooter . QuickRep . , .
QRLabel Caption .
, AlignToBand
true, Alignment taCenter.
(, 14). .
QRSysData. . Data, :
qrsDate
qrsDateTime
qrsDetailCount
qrsDetailNo
qrsPageNumber
qrsReportTitle
qrsTime

717

Text QRSysData ,
.
Data qrsDate, Text >>. . QRSysData ,
QRLabel, .
QRLabel,
, , .
Frame DrawTop true. , .
QRSysData, Data qrsPageNumber .
.
QuickRep ,
Preview, .
. QuickRep . ,
QReport .
.
QRSubDetail.
QuickRep .
DataSet , . Dep, DataSet TDep. , .
Bands : HasFooter ,
, HasHeader , .
true HasHeader. Group
Header QRLabel ,
QRDBText , . , ,
, DataSet DataField, . DataSet = TDep DataField = Dep.
,
.
: . , : QRSubDetail, TDep, true HasHeader
Bands. QRLabel
.
QRLabel QRDBText,
Dep TDep.
, .
QRSubDetail Master.
. ,
. Master .
PrintBefore ,
( PrintBefore = true) .

718

11

, QRSub
Detail TPers. Master QRSubDetail2 QRSubDetail, . PrintBefore false. QRDBText, Fam, Nam Par TPers.
,
.
. . QRDBImage, QRDBRichText. TPers. , ,
. , ForceNewPage . true. .
. QRSubDetail, QRLabel QRRichText, .
, . . ,
. ( ), . , , .
.
QRRichText, ParenfRichEdit.
RichEdit, ParentRichEdit. RichEdit .
. ,
( Visible false).
FRep. , , , URep.
, , .
( File | New Form).
FMain. , , , UMain. .
Project | Options, Forms Main Form
FMain. FRep .
MainMenu, FontDialog, RichEdit . , . , . 11.10,
.
.
URep UMain
URep #include. , URep File | Include
Unit Hdr.


1. 11.10

719

,
.
.

QRRichText FRep ParentRichEdit. RichEdit


FMain. ,
.
File | Include Unit Hdr URep.

FRep->QuickRepl->Preview() ;


FRep->QuickRepl->Print() ;


if (FontDialogl->Execute() )
RichEditl->SelAttributes->Assign(FontDialogl->Font) ;
RichEditl->SetFocus () ;

RichEditl. , RichEdit (. . 3.2.4).


. .
.
, . 11.11. , ,
. 11.11

'720

11

( ),
( ), ,
- . Close
,
.

11.3

, , ,
QuickReport, . 11.2.
QuickReport . QuickReport .
,
. Windows Word,
, .
Word
C++Builder , . Word C++Builder.
Word, Excel , Word Microeoft Office,
C++Builder , Servers C++Builder 5 Office2k
Office97 C++Builder 6. , , . 7.9, . 7.
, Word
.
. 11.12. . , .
Pers dbP Word, ,

. , . , .
. , , ... . ...
, ( TBDep). , , TBYear, TBCharact, TBPhoto . . 11.12 . Word, , . 11.13.
.
TBBold , TBItalic - , TBUnderline .
, TBLeft (),
TBCenter ( ) TBRight () . . 11.12
.


. 11.12

()
()

721
4---;

; Hj#jv

jib!!*

llr

IDBEST" ("

JDBEfk'i

JDi^

JDBE

|D6EdiM

15

|D

DBRehEdul

.
1961 ..
;0 1
.
.

!<

. 11.13
,


1950
''

,
1950 ..,

.. .

..

11

722

Word,
, , ,
, , .
Word (, ,
..). , , Word , , , , ..
Word.
.
. dbP
Queryl, SQL
S e l e c t * from Pers Order by Fam, Nam,

Par

, Queryl, DataSourcel. DBEditl DBEdit6, , DBRichEditl, ,


DBImagel, .
ActionListl,
, :

11

TForml->AAllExecute

AExit

TForm 1 -> AExitExecute

ANew

TForml->ANewExecute

AOpen

TForml >AOpenExecute

APreview TForml>APreviewExecute
APrint

TForml->APrintExecute

ARecord

TForm 1 -> ARecor dExecute

ASave

TForml->ASaveExecute

AWord

Word

TForml->AWordExecute

ActionListl TImageList,
.

ToolBarl . , , . , , MainMenu.
, . ApplicationEventsl,
OnHint Hint
.
,
, ProgressBarl (. . 3.6.6).
Visible false, . .
: WordApplicationl, WordDocumentl, WordFontl WordParagraphFormatl. AutoConnect false. ConnectKind WordApplicationl -

723

ckRurmingOrNew, ckAttachToInterface.

.
:
class TForral
!

published:

: public TForra

// IDE-managed Components

private:
// User declarations
void
fastcall DocumentSearch(void);
public:
// User declarations
fastcall TForml(TComponent* Owner);

:
t i n d u d e <Clipbrd. hpp>
void
fastcall TForml::DocumentSearch(void)
{
//


if(WordApplicationl->Documents->Count == 0)
{
Application->MessageBox(" Word ",
" ",
_ + MB_ICONEXCLAMATION);
Abort () ;
}
WordDocumentl->ConnectTo (WordApplicationl->ActiveDocuraent);
]

__
_.
:
void
fastcall TForml::FormCreate(TObject *Sender)

Queryl->Open();
/* ,
WinWord*/
WordApplicationl->Options->CheckSpellingAsYouType - false;
WordApplicationl->Options->CheckGramraarAsYouType = false;
if(WordApplicationl->Documents->Count == 0)
{ .
ASave->Enabled = false;
APreview->Enabled - false;
APrint->Enabled = false;
ARecord->Enabled r false;
AAll->Enabled - false;

void
fastcall TForml::ANewExecute(TObject "Sender)
{
//
WordApplicationl->Documents->A.dd (EmptyPararn, EmpcyParam) ;
ASave->Enabled - true;
APreview->Enabled true;
APrint->Enabled - true;
ARecord->Enabled - true;
AAll->Enabled - true;

724

fl
__

//
void

fastcall

TForml::AAllExecute(TObject

'Sender)

//
TBookmark SavePlace;
//
SavePlace = Queryl->GetBookmark() ;
Queryl->First();
//
StatusBarl->SimpleText = " ";
//
ProgressBarl->Max = Queryl->RecordCount;
ProgressBarl~>Position = 0;
ProgressBarl->Visible - true;
//
while (! Queryl->Eof)
{
ARecordExecute(Sender) ;
ProgressBarl->Position - ProgressBarl->Position + 1;
Queryl->Next();
}
//
Queryl->GotoBookraark(SavePlace) ;
// ,
Queryl->FreeBookmark(SavePlace);
StatusBarl->SimpleText = ""',
ProgressBarl->Visible = false;
)
//
void
fastcall TForml::ARecordExecute(TObject *Sender)
{
TVariant snew = "\n";
//
DocumentSearch();
WordApplicationl->Selection->InsertAfter(snew) ;
dApplicationl->Selection->InsertAfter(
TVariant(QuerylFam->AsString + ' ' +
QuerylNam->AsString + ' ' +
QuerylPar->AsString + '\n'));
WordApplicationl->Selection->InsertAfter(snew) ;
if(TBYear->Down)
{
WordApplicationl->Selection->InsertAfter(
TVariant(QuerylYear_b->AsString + " \"));
WordApplicationl->Selection->InsertAfter(snew);
1

if(TBDep->Down)
{
if(QuerylSex->Value)
WordApplicationl->Seleetion->InsertAfter(
TVariant(" '"+
QuerylDep->AsString + "'\n"));
else WordApplicationl->Selection->InsertAfter(
TVariant(" '"+
QuerylDep->AsString + "'\n")(;
}
if(TBCharact->Down)
{
WordApplicationl->Selection->InsertAfter(snew);
WordApp1ication 1->Seleetion->InsertAfter(
TVariant(DBRichEditl->Text));
WordApplicationl->Selection->InsertAfter(snew);


//
WordFontl->ConnectTo(WordApplicationl->Selection->Font) ;
// C++Builder 6:
if(TBUnderline->Down)
WordFontl->set_Underline(wdUnderlineSingle) ;
else WordFontl->set_Underline(wdUnderlineNone) ;
if(TBBold->Down)
~
WordFontl->set_Bold(1);
else WordFontl->set_Bold(0) ;
if(TBItalic->Down)
WordFontl->set_Italic(1) ;
else WordFontl->set__Italic(0) ;
// C++Builder 5:
// if(TBUnderline->Down)
// WordFontl->Underline = wdUnderlineSingle;
// else WordFontl->Underline - wdUnderlineNone;
// if(TBBold->Down)
//
WordFontl~>Bold - 1;
// else WordFontl->Bold = 0;
// if(TBItalic~>Down)
//
WordFontl~>Italic = 1;
// else WordFontl->Italc = 0;
//
WordParagraphFormatl->ConnectTo (
WordApplicationl->Selection->ParagraphFormat);
// C++Builder 6:
if(TBLeft->Down)
WordParagraphFormatl->set_Alignment(wdAlignParagraphLeft);
if(TBCenter->Down)
WordParagraphFormatl->set_Alignment(wdAlignParagraphCenter);
if(TBRight->Down)
WordParagraphFormatl->set_Alignment(wdAlignParagraphRight);
// C++Builder 5:
// if(TBLeft->Down)
// WordParagraphFormatl->Alignment = wdAlignParagraphLeft;
// if(TBCenter->Down)
// WordParagraphFormatl->Alignment = wdAlignParagraphCenter;
// if(TBRight->Down)
// WordParagraphFormatl->Alignment = wdAlignParagraphRight;
TVariant Direction - wdCollapseEnd;
WordApplicationl->Selection->Collapse(SDirection);
//
if(TBPhoto->Down)
{
Clipboard()->Assign(DBImagel->Picture) ;
WordApplicationl->Selection->Paste();
WordApplicationl->Selection->InsertAfter(snew);
}
}
//
void
f a s t c a l l TForml::ASaveExecute(TObject *Sender)

DocumentSearch();
WordApplicationl->Dialogs->Item(wdDialogFileSaveAs)->
Show(EraptyParam);'
)
//
'
void
f a s t c a l l TForrt)! : :AWordExecute (TObject *Sender)

725

726

11
// Word,
//
WordApplicationl->Connect() ;
//
WordApplicationl->set_Visible(true); // C++Builder 6
// HordApplicationl->Visible = true/ // C++Builder 5
)
/i

void
fastcall TForml::ApplicationEventslHint(TObject 'Sender)
(
//
StatusBarl->SimpleText = Application->Hint;
}
//
void
fastcall TForml::FormDestroy(TObject *Sender)
{
/ */
Queryl->Close <);
}
//
void
fastcall TForml::APrintExecute(TObject *Sender)
{
//
DocuraentSearch();
WordApplicationl->set_Visible(true); // C++Builder 6
// WordApplicationl->Visible - true,- // C++Builder 5
WordApplicationl->Dialogs->Item(wdDialogFilePrint)->
Show(EmptyParam);
)
//
void
fastcall TForml::APreviewExecute(TObject *Sender)
{
~
//
DocumentSearch();
WordDocumentl->PrintPreview();
WordApplicationl->set_visible(true); // C++Builder 6
// NordApplicationl->Visible = true; // C++Builder 5
}
y/
void
fastcall TForml::AExitExecute(TObject *Sender)
{
"
//
Close () ;
)
/ /

void

fastcall TForml::AOpenExecute(TObject *Sender)

//
WordApplicationl->Visible = true;
if(WordApplicationl->Dialogs->Item(wdDialogFileOpen)->
Show(EmptyParam) -1)
{
ASave->Enabled = false;
APreview->Enabled = false;
APrint->Enabled = false;
ARecord->Enabled = false;
AAll->Enabled = false;

. ,
. 7.9. .

727

, , : C++Builder 6
C++Builder 5 (. . 7.9). C++Builder 5 . .
TForml::ARecordExecute Clipboard, , , Clipbrd.
Clipboard.
, ,
.
, TForml::AAllExecute,
, , ,
TForml::ARecordExecute, . , ,
GetBookmark SavePlace TBookmark, . GotoBookmark ,
FreeBookmark.
ProgressBarl. Position . ProgressBarl .
DocumentSearch,
- , Word
. ,
, .., . DocumentSearch.
.
. , , , . . C++Builder, .
, , .
, .. , C++Builder , . Word , , , .
Word ++ilder, . : ' Word
C++Builder, . , Word
- ,
. , - , C++Builder, (, ), .
, Word , . Word . 7.8.4. Word
, , , C+4-Builder, Shell.
: pathname ,
, windowstyle .
Shell . .

If

728

pathname , . , .
windowstyle . , .
windowstyle:

vbHide

. i
, - j
, , >

.

vbNormalFocus

vbMinimizedFocus

vbMaximizedFocus

vbNormalNoFocus


, Word.

vbMinimizedNoFocus

. Word.

:
Dim RetVal
RetVal = Shell("f:\Tests\Servers\PWord2.EXE",

1)

RetVal, Shell. , pathname, (, ),


windowstyle = 1. , C++Builder , Word
- .



12.1 WWW
, . ,
, . .
U ,
. : C++Builder C++Builder
Web. , .
, . ,
Internet, TCP/IP (
/ transmission control protocol/internet protocol). , , . , TCP/IP
.
World Wide Web (WWW),
s ,
;: . WWW- ()
. HyperText Transfer
Protocol (HTTP) File Transfer Protocol (FTP) .
HTTP , WWW. ;1|
".
/.
, , URL : (universal resource location). , ,
-: http://www.borland.com. Web {
^) , Web
.
HTTP , : . , ,
' , .
.
, , Web. -: , ,
- .

730

12

HTTP :
, , . HTML,
, , , .
, WWW.

12.2 ,
WWW

, Web CGI, ISAPI,
NSAPI WIN-CGI, . Web Microsoft Internet Information Server Personal Web Server,
CGI ISAPI. Windows 95/98/2000
Web, FrontPage, Web. , ActiveX, , Microsoft Internet Explorer.
,
,
. , FrontPage, ...\FrontPage Web.
: Content Server. Server
vhttpd.32.exe. . , - , .
Content ,
cgi-bin. .
. .dll, . , . Allow Scripts or Programs to be Run.
FrontPage
. , MyComputer. , , Windows.
. ,
- .
, , Computer. , ,
TCP/IP.
, , cgi-bin, URL (. .
12.1): http://mycomputer/cgi-bin/_aa. http://
,
mycomputer/cgi-bi/_aa.

12.3 HTML
Web HTML (Hypertext Markup Language)
, WWW.
. , -

731

. , , .html , .
, Microsoft
FrontPage, Web. To ,
, , , Word, Word 97. HTML.
, , HTML, . ().
, . , <>
<strong> . , ,
"/"
:
<HTML>
<> </>
</HTML>

<> <html>, HTML. . .html. - , , Internet Explorer, .


.
C++Builder 6 HTML ,
C++Builder. ( File | New | Other, Text New) .
( File | Sove As), .html.
html Editor.
Internet ,
. 15.7, . 15, Open, ,
, ,
. , C++Builder 6!
:
<htral>
<head>
<title> no C++Builder</title>
</head>
<body>
<> </hl>
<hr>
<> ..</>
<p>&quot;<b>C++Builder . noco6e</b>Squot;</>
<>3 <>123-45-67</>
<hr>
< HREF-"file:11II:I tests/internet/html2.htm">
<> </></>
</body>
</html>

, , .
, , , : !
HTML, , , C++Builder, , -

12

732

File | New | Other, HTML Document Web Documents). :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Untitledl.html </TITLE>
</HEAD>
<BODY>

</BODY>
</HTML>

<BODY> </BODY> ,
<TITLE> .
- ( ,
f:\tests\lnternet, , , HTMLl.html. - , , Internet Explorer, . . 12.1
Internet Explore.
. 12.1
HTML

^ J } < ^

&',

> % *

j$s F UestsllntemeHht

/"f'

*!



"C-H-Bttflder . *
!23-45-7
i
wifaoDMaioiH iienaic - math

^J

. <title> , (. . 12.1),
<body> . <> . <hr> ,
. <> .
<> . "<" HREF,
URL : http://aflpecs>. , URL
, .
:// . :
< HREF="file:tilt :/tests/internet/html2.htm">
. ,
< HREF="htral2.htral">
HTML2.html , , , :

733

HTML2.html. .
< HREF="/tests/internet/html2.htm">

; , ,
.
URL, -u;.x .
, , ,
* http://, , .
<>. ,
( URL ) , . :
,
.
, ,
, , :
<html>
<title> </title>
<body>
<> </hl>
<hr>
<> </>
<hr>
< HREF="file:lilt:/tests/internet/htmll.htm">
<><> </></>
<b>
</body>
</html>

HTML2.html f:/tests/internet.
. ,
HTMLl.html Internet Explorer,
.

12.4
C++Builder. Internet Explorer.
C++Builder. WebBrowser Internet. ,
Align alClient. , OnCreate

CppWebBrowserl->Navigate(WideString("f:/tests/internet/htmll.htm"

);

Navigate URL
. Navigate BSTR, URL. AnsiString BSTR .
, , WideString. , .
. -
, OpenDialog. Filter :

12

734

HTML ( *.html, *.htm)


*.html;*.htm

,

if

(OpenDialogl->Execute ())
CppWebBrowserl->Navigate(WideString(OpenDialogl->FileName));

. (. 12.2), , .
HTML .
. 12.2
,
WebBrowser



"C++Bui]der . "
123-45-67

, , . .
, . , , - Word .doc. ,
, Word . , , .
, , , . , .bmp Microsoft Paint
. Excel, , Word. - - . C++Builder,
C++Builder .
..
, ,
, , : ,
. , Windows. ,
,
.
.
? , , ! , , , .

735

,
. URL ,
, , . , . , , .
(. . 3.9.5, . 3). (. . 3.9.4, . 3). true ShowCaptions, . . , TBForward. , . (Caption.) , .
Enabled false, . , ImageList (. . 4.2, . 4).
ComboBox.
URL
HTML, . CBURL.
AutoSize ShowText true.

.
. Bands , CBURL, ( Text) :.
StatusBar (. . 3.9.6, . 3). SimplePanel true. ,
. 12.3 (, ).
. 12.3


Web

.!

/ hi ru*xfeh<jp

. - -

--.***

>

*
, en Delphi ++
, .
- *
10 DelpN *Builder

d nor

;#. />*9?6-976

.
, .

736

12
:
class TForml : public TForm
{
published:
// IDE-managed Components
TCoolBar 'CoolBarl;
TCppWebBrowser 'CppWebBrowserl;
TToolBar 'ToolBarl;
TToolButton 'TBBack;
TToolButton 'TBForward;
TImageList 'Imagelndexl;
TStatusBar 'StatusBarl;
TOpenDialog 'OpenDialogl;
TMainMenu 'MainMenul;
TMenuItem *N1;
TMenuItem *MOpen;
TComboBox 'CBURL;
void
fastcall ForraCreate(TObject *Sender);
void
fastcall CBURLClick(TObject *Sender);
void
fastcall CBURLKeyDown(TObject 'Sender, WORD SKey,
TShiftState Shift);
void
fastcall CppWebBrowserlBeforeNavigate2(
TObject *Sender, LPDISPATCH pDisp,
Variant *URL, Variant *Flags,
Variant 'TargetFrameName,
Variant *PostData, Variant 'Headers,
VARIANT_BOOL *Cancel);
void
fastcall CppWebBrowserlProgressChange(
TObject 'Sender, long Progress, long ProgressMax);
void
fastcall MOpenClick(TObject 'Sender);
void
fastcall TBBackClick(TObject 'Sender);
void
fastcall TBForwardClick(TObject 'Sender);
private: // User declarations
void
fastcall LoadO;
public:
// User declarations
fastcall TForml(TComponent* Owner);

:
TForml 'Forml;
//
,
void
fastcall TForml::Load()
// URL , CBURL->Text
CppWebBrowserl->Navigate(WideString(CBURL->Text));
)
/ /_.
i
void
fastcall TForml::FormCreate(TObject 'Sender)
{
// URL
CBURL->Text = "F:\\TESTS\\INTERNET\\HTML1.htm";
LoadO ;
void
fastcall TForml::CBURLClick(TObject 'Sender)
{
// CBURL

LoadO ;


void

737

fastcall TForml::CBURLKeyDown(TObject *Sender,


WORD SKey, TShiftState Shift)

{
// Enter CBURL
if (Key == VK_RETURN) Load();
}
//

void

fastcall TForml::CppWebBrowserlBeforeNavigate2(
TObject *Sender, LPDISPATCH pDisp, Variant *URL,
Variant *Flags, Variant *TargetFrameName,
Variant *PostData, Variant *Headers,
VARIANT_BOOL *Cancel)
//
{
// CBURL
int Index = CBURL->Items->IndexOf(AnsiString(*URL));
if (Index -1)
(
CBURL->Items->Insert(0,AnsiString(*URL| | ;
CBURL->ItemIndex - 0;
)
else CBURL->ItemIndex = Index;
// TBForward TBBack
TBForward->Enabled = (CBURL->ItemIndex > 0) ;
TBBack->Enabled - (CBURL->ItemIndex < CBURL->Iteras->Count - 1);
}
//
void
fastcall TForml: :CppWebB<rowserlProgressChange (
TObject *Sender, long Progress, long ProgressMax)
{
//
if (Progress >0)
StatusBarl->SimpleText =
Format(" %s: %d %d",
ARRAYOFCONST(
(AnsiString(CppWebBrowserl->LocationName),
(int)(Progress / 1024),
(int)(ProgressMax / 1024))));
}
/ /

void
fastcall TForml::MOpenClick(TObject Sender)
(
//
if (OpenDialogl->Execute())
(
CBURL->Text = OpenDialogl->FileName;
Lpad() ;

void
fastcall TForml::TBBackClick(TObject *Sender)
{
//
CBURL->Text = CBURL->Items->Strings[CBURL->ItemIndex
Load ();
void
(

fastcall

TForml::TBForwardClick(TObject

*Sender)

//
CBURL->Text = CBURL->Items->Strings[CBURL->Itemlndex - 1];
Load() ;

738

12

. private - Load, Navigate


URL Web, CBURL. .
FormCreate OnCreate.
CBURL URL Web-, .
, , C++, "\ ". - , OnCreate .
Web,
CBURL URL. :
CBURL->Text = "http://www.Borland.cora/C++Builder/index.html";

,
. :
CppWebBrowserl->GoHorae() ;

Stort Page
HKEY_CURRENT_USER\Softwore\Microsoft\lnternet Explorer\Main. , (. 5.7.2), , , ,
.
CBURL FormCreate
Load ( ,
). Load CBURL ( CBURLClick)
Enter ( CBURLKeyDown).
CppWebBrowserlBeforeNavigate2
OnBeforeNavigate2 CppWebBrowser,
. ,
: Navigate .
URL ,
. Cancel, false,
.
CppWebBrowserlBeforeNavigate2
IndexOf URL CBURL. URL AnsiString.
AnsiString. IndexOf - 1 , . Insert
( 0) 0.
,
. .
CppWebBrowserlBeforeNavigate2 TBForward , .
CppWebBrowserlProgressChange
OnProgressChange.
. Progress
ProgressMax .
. , Progress - 1 . CppWebBrowserl-

739

ProgressChange LocationName , URL.


MOpenClick . Text
CBURL, Load.
TBBackClick TBForwardClick
. CBURL

.
.
. 12.3. URL Web (
) . Enter .
,
. HTML, , . . , . .
, Internet Explorer. , , C++Builder .
C++Builder , , , , . ,
, . ,
, , .

12.5 Web
CGI
Web.
Web. .
, , HTML .

: , , DLL,
. , ., CGI WIN-CGI. , DLL, ISAPI NSAPI.
CGI WIN-CGI DLL, ISAPI
NSAPI, .
CGI (Common Gateway Interface) , . HTML, , ,
CGI .
CGI
. .

12

740

( File | New | Other, Console Wisard New)


:
(finclude <stdio.h>
#include <SysUtils. hpp>
#pragma hdrstop
int main(int argc, char* argv[])
const AnsiString Days[] =
{"", "", "", "",
"", "", ""};
printf ("<HTML>");
printf("<1>!\n</Hl><HR>") ;
printf((" " + DateToStr(Date()) + " (" +
Days [DayOfWeek (Date () )] + ") <HR>") . c_str () ) ;
printf(ForraatDateTirae(
" h . rn . ", Time () ) . c_str () ) ;
printf("</HTML>");
return 0;

,
. , .. , printf.
- , .
PTime . PTime.exe ,
DOS, , . , ,
DOS. PTime.exe
( Web, FrontPage ...\FrontPage Web\Content\ cgi-bin . . 12.2). , , , . 12.3, URL
mycomputer/cgi-bin/ptime.exe. , . 12.4.
, , HTML .
. 12.4
,
CGI

.
jhltp/Zmsiconputer/cgibin/ptnieeve

02 04 2002 ()
15 . 22 .

[ http://myccipufcerjcgi-binyptiwe.exe: ** _,

CGI
ISAPI ( API Internet Microsoft) NSAPI ( API Netscape Netscape) , Web.

741

CGI . , , ' CGI, Web


, CGI-,
, , . ISAPI NSAPI . CGI DLL ISAPI
. 12.7.

12.6 Web C++Builder


12.6.1 Web
, . 12.5
CGI, ( ).
, -

. C++Builder , .
C++Builder Web TWebModule.
. TWebModule . , File | New | Other New Items New Web Server Application.
(. 12.5 ), . CGI Stand-alone executable CGI. C++Builder
.
C++Builder 6 5. C++Builder 6
(. 12.5 ), ,
, ..
, ,
: ,
. 12.5
(), Web ()
() C++Builder 6

)
You m select from one of the loliowing types of Woild
Wide Web server applications
ISAPI/NS/SPI Dmamic Lrts Libtarii

<~ Wt-iCGI Stand-atone executabe


l
Apache Shoied Module (DLL)
Web App Debugger executable

j Art on*
*S 0 - WebActionltemi
4 1 -WebActionlteiru

12

742

. (Object TreeView),
, (, , Actions ). .
C++Builder 5 Web ,
. Dato Diogrom, . C++Builder 6 ,
.
Web ( ++ilder 5 , WebModulel . 12.7). Actions. TWebActionltem. (. . 12.6),

Actions. To ,
( C++Builder 5 WebModulel)
Action Editor.
Add New ( . 12.6) ,
Delete Selected ( ) , .
. 12.6

t'

>

*i

Name
PotMnfo Enabled Detail Producei
WebActionltemi /1"
True
WefcActionltem2
True

TWebActionltems , , . ,
. Pathlnfo. , URL. . 12.1 . URL ,
, :
http://www.myserv.cora/pl/servl,exe/actionl?value=5sResp=Yes

URL (HTTP). ( www.myserv.com). ( /pl/servl.exe). , URL, Pathlnfo.


/actionl. . , ,
.
URL, Query . ,
, . "&".
value 5 Resp Yes. , .

Pathlnfo. Pathlnfo URL.
, Pathlnfo -

743

Pathlnfa. OnAction, , . :
void

fastcall

TWebModulel::WebModulelWebActionItemlAction!
TObject *Sender, TWebRequest *Request,
TWebResponse *Response, bool iHandled)

Request TWebRequest. Query string, Query


URL. URL : value=5&Resp=Yes. QueryFields TStrings. Query URL . : value=5 Resp=Yes. ,
QueryFields .
Values[nMa]. , Request>QueryFields>Values["Resp"] Yes.
Response TWebResponse.
Content string
HTML, HTML .
Handled , , Response . ,
Response ,
Handled false. , ,
Response, Content ,
.
Pathlnfo
OnAction. Default.
true, .
, Pathlnfo ,
OnAction . Enabled
.
TWebModule, , , . BeforeDispatch AfterDispatch,
. OnAction. , BeforeDispatch. , , Enabled . . AfterDispatch. ,
, - .

12.6.2
, , .
12.6.1. , .
, , :
4 5. ,
.
, ,
( File | New | Other, Web Server Application). , . 12.6. .

744

12

Pathlnfo /1.
. .
Default true.
OnAction . :
void

f a s t c a l l TWebModulel : : WebModulelWebActionIten\2Action (
TObject *Sender, TWebRequest *Request,
TWebResponse 'Response, bool ^Handled)

(
Response->Content = "<hl> ? </hl>"
"<> 2 x 2 ?</p><HR>"
"< HREF=\"/cgi-bin/TwiceTwo.exe/l?4\"> 4</A> "
"< HREF=\"/cgi-bin/TwiceTwo.exe/l?5\">5</A> ?, <HR>";
Handled = t r u e ;
)

HTML, . 12.7 .
4 5.
Pathlnfo /1. ,
, Pathlnfo. Query
: 4 5. , . OnAction :
void

fastcall TWebModulel::WebModulelWebActionItemlAction(
TObject *Sender, TWebRequest *Request,
TWebResponse *Response, bool SHandled)

{
if(Request->Query == "4")
Response->Content = " 4. !";
else Response->Content =
" 5. .";
Handled = true;
}

(. . 12.7 12.7 ) Request.Query.


TwiceTwo.
TwiceTwo.exe .
. . 12.7.
. . , ,
HTML , . , , :
<html>
<head>
<title>3HaeTe
</head>

flea</title>

<body>
<!>3 ?</>
<> 2 x 2 ?</>
<hr>
<>< HREF="http://mycomputer/cgi-bin/TwoTwo.exe/l?4">4</a>

< HREF="http://mycomputer/cgi-bin/TwoTwo.exe/l?5">5</a> ? </p>


<>
</body>
</html>


. 12.7
: ()
4 (6) 5 ()

745

)
-3
\!

1
1


2 x 2

^ ?,
:gs-brj/Tv4i eTvo exe: 9 HI 9

6)

JWtp Mnycomputet/cg tWTwceTwo ^~ _-j


4 !

5 ,

htt

nfTwceTwo.eyefi^Si

,;

, ,
,
TwiceTwo.exe, : http://rnycomputer/cgi-bin/
TwoTwo.exe. , HTML
TwoTwo.exe, , .
, TwiceTwo.exe ( . . 12.1).
TwoTwo.html.
TwoTwo, .
, . Pathlnfo = "\1" .
. TwoTwo . TwoTwo.html
, , .

12.7 CGI DLL ISAPI


CGI. . 12.5

(DLL)
ISAPI. CGI DLL ISAPI .
TwoTwo, . 12.6.2.
1. Web
(. 12.5 ) ISAPI/NSAPI Dynamic Link Library. C++Builder
. 12.6.2
, .

746

12

2.

OnAction, TwoTwo . 12.6.2.


3. TwoTwo2 .
TwoTwo2.dll.
.
, ISAPI DLL, DLL Web-, , Web-.
CGI-,
. , ,
ISAPI. URL. :
http://www.mysite.com/scripts/twotwo2.dll

12.8 HTML
12.8.1
. 12.6 .
.
. , <form> HTML. -.
, ,
, , .
.
<FORM>, . =. URL , ,
action. :
action-"http://mycomputer/cgi-bin/test.exe"

method HTTP. get post. get


,
, . Post Web. Post, ContentFields ,
OnAction Request. Get, QueryFields
Request.
<input ="text ">
, <input type="submit"> ,
, <textarea> , . HTML, ,
FrontPage Insert | Form Field.
. type .
name . value
, .. name=value, name value. , Post Get

747

ContentFields Query Fields Request.


, ,
Request->ContentFields->Values["result"]

Request->QuerFields->Values["result"]

result.
size,
.
,
. <table>
</table>. <tr> </tr>, . <td>
</td>, . .
.

. HTML, , . 12.8.
. 12.8



, ,

- 9 9

HTML . , miml num2. , result. , mult.exe Pathlnfo /1. ,


mult.exe.
Web,
. 12.8 , .
<html>
<head>
<title>Ta6nima
</head>

748

12
<body>
<1> </>
<>3 , , ""
</>
<form method="POST"
action="http://mycomputer/cgi-bin/mult .exe/l">
<table>
<trxtdxinput type="text" name="numl" size="l"x/td>
<td> x </td>
<tdxinput type="text" name="num2" size"l"x/td>
<td> = </td>
<tdxinput type="text" name="result" size="3"> </td>
<tdxinput type="submit" name="post" 1=""> </td>
</tr>
</table>
</form>
<form method="POST"
action="http://mycomputer/cgi-bin/mult .exe">
<pxinput type="submit" value=-"HoBbie " name="New"x/p>
</form>
</body>
</html>

12.8.2
, . , ,
. , , , . .
, . , , , . ,
,
. .

. , . .
numl num'2.
HTML . : .
, ,
. Pathlnfo = "/1 "
. Pathlnfo
Default = true HTML. OnAction :
void

fastcall

TWebModulel::WebModulelWebActionItem2Action(
TObject *Sender, TWebRequest Request,
TWebResponse *Response, bool iHandled)

{
randomize () ;

Word Numl = random(8)+1;


Word Nura2 random(8)+l;
Response->Content = "<html><head><title>TaOa "
"</title></headxbody>"

749

"<1> </>";
Response->Content = Response->Content +
" , , "
" \"\"";
Response->Content = Response->Content +
"<form method=\"POST\" "
"action=\"http://mycomputer/cgi-bin/mult.exe/l\" "
" < t a b l e x t r x t d > < i n p u t type = \"text\" name=\"numl\""
"size=\"l\" value-=\"" + IntToStr (Numl) +
"\"></tdxtd> x "
"<tdxinput type=\"text\" name=-\"nun\2\" size=\"l\""
"value-\"" + IntToStr (Num2) + "\"></tdxtd> = "
"<tdxinput type=\"text\" name=\"result\" size=\"3\"> "
"</td> <tdxinput type=\"submit\" name=\"post\" "
" value=\"\">"
"</tdx/trx/tablex/formxBR>"
"<form method=\"POST\" "
"action=\"http://mycomputer/cgi-bin/mult , exe\">"
"<pxinput type=\"submit\" value-\"HoBbie \" "
"name=\"New\"x/px/form></bodyx/html>";
Handled = true;
)

random Numl Num2 , 1 9. randomize ,


.
, . 16, . 16.2.4.
HTML, , . 12.8.
numl 2 value Numl Num2.
,
OnAction HTML. , . HTML , . ! . 12.9 ,
, . .
OnAction :
void

f a s t c a l l TWebModulel::WebModulelWebActionItemlAction(
TObject *Sender, TWebRequest *Request,
TWebResponse *Response, bool SHandled)

if (Request->ContentFields->Values["result"] -=
IntToStr(StrToInt(Request->ContentFields->Values["numl"]) *
StrToInt(Request->ContentFields->Values["num2"])))
Response->Content = "<>! I ! </> !";
else Response->Content =
" <>"
"< HREF=\"http://mycomputer/cgi-bin/mult.exe\">"
"<> <//>";
Handled = t r u e ;
(

if result , numl num2. ,


, . 12.9.
Mult ( ), . , .

12

750
. 12.9
HTML
()
()

6)

' fhttp/Ar^computei^cgibtn/mdt

& jhttp/zriiyrcfflDiitef cgt bn/mult ^

!! I

^-j

_
_
_
[ ; 9

UoK/ 5) ; 9 ,4

12.9 HTML
. 12.8.2 , -
HTML OnAction. HTML. , - HTML.
:
<#TagName

Paraml=Valuel

Param2=Value2

...>

.
" # " ,
. . . , Link , Image .. , .
,
, .
PageProducer, Internet .
, . 12.8.2, , .
.
Pathlnfo = "/1", , .
OnAction
. 12.8.2. Numl Num2 , .
Pathlnfo Default = true ,
, HTML. OnAction. PageProducer. WebModulel, ( ++ilder 5 Components ).
PageProducer. HTMLDoc HTMLFile.
TStrings HTML,
, . HTMLFile
.html .htm. , . , HTML j ( HTMLDoc) .

751

. ( HTMLFile) . , . Web,
, , ,
.
,
HTMLDoc. HTML. HTMLDoc.
. , - ,
. , . , , .. HTMLDoc.
PageProducer OnHTMLTag.
, HTML . OnHTMLTag :
procedure TWebModulel.PageProducerIHTMLTag(Sender: TObject;
Tag: TTag; const TagString: String;
TagParams: TStrings; var ReplaceText: String);
Tag , TagString . , ,
tgCustom. TagParams ,
. ReplaceText , . , .
:
Tag

TagString

TagParams

ReplaceText

tgLink

LINK


HTML, <>
</>.

tglmage

IMAGE

<IMG>.

tgTable

TABLE


HTML,
<TABLE>
</TABLE>.

tglmageMap IMAGEMAP


HTML,
<>
</>.

tgObject

ActiveX (.
. 12.11)


HTML,
<OBJECT>
</OBJECT>.

OBJECT

12

752
Tag

TagString

TagParams

ReplaceText

tgEmbed

EMBED


Netscape


HTML,
<EMBED>
</EMBED>.

tgCustom




, .

, . ,
.
PageProducer
Web . Producer
PageProducer. HTML,
PageProducer, Response.Content OnAction, .
,
OnAction. , PageProducer
OnAction HTML,
.
PageProducer
Producer . ,
, , , Producer
nil.
OnAction
PageProducer PageProducer.Content. PageProducer , OnHTMLTag
- , OnAction.
, , . 12.8.2. , , , PageProducer. HTML, ,
HTMLDoc PageProducer.
:
<html>
<head>
<tit 1> </1:^1>
</head>
<body>
<> />
<>3 , , ""
</>
<forra method="POST"
action="http://mycomputer/cgi-bin/raultl.exe/1"
<table>
< t r x t d x i n p u t type="text" name="numl" size="l"
value="<#TNuml>"x/td>
<td>x </td>

753

< t d x i n p u t type="text" name="num2" size="l"


value="<#TNum2>"x/td>
< t d x i n p u t type="text" name="result" size="3"> </td>
< t d x i n p u t type="submit" name="post" 1="0"> </td>
</tr>
</table>
</form>
<form method="POST"
action="http://mycomputer/cgi-bin/multl.exe">
<p><input type="submit" value="HOBbie " name="New"x/p>
</forra>
</body>
</html>

, . 12.8.1.
mult.exe multl.exe ( ) numl num2 value , <#TNuml>
<#TNum2>. , HTMLFile PageProducer .
C++Builder 6 ,
htm Editor. , Internet ,
, .
, , - .
OnAction , . 12.8.2. OnAction
:
void

fastcall TWebModulel::WebModulelWebActionItem2Action(
TObject 'Sender, TWebRequest 'Request,
TWebResponse 'Response, bool SHandled)

{
randomize();
Numl = random(8)+1;
Nura2 = random(8)+l;
Response->Content = PageProducerl->Content() ;
}

Numl Num2, Content PageProducerl Response>Content. OnHTMLTag


PageProdueerl Numl
Num2, , .. OnAction.
OnHTMLTag PageProdueerl :
void

fastcall TWebModulel::PageProducerlHTMLTag(
TObject 'Sender, TTag Tag, const AnsiString TagString,
TStrings *TagParams, AnsiString sReplaceText)

(
if(TagString == "TNuml")
ReplaceText = IntToStr(Numl);
else if(TagString == "TNum2")
ReplaceText - IntToStr (Num2);

754

12

,
HTML, Nurnl Num2.
Multl (
HTML), . , . , ,
, . ,
, , .

12.10
12.10.1
. dbP, , , . 9. , ,
-
. ,
, . ,
. -, - . -,

.
Web . Internet
DataSetTableProdueer. Web
, Default Default true.
Web Table DataSetTableProducer. Tablel Pers
dbP. , . 9, Age. () (. . 9.5.2, . 9), (.
. 9.5.5) .
DataSetTableProdueer Tablel,
DataSet Tablel. Header
HTML, . :
<html>
<1 </1>
<body>

'

Footer HTML,
. :
</body>
</html>

Caption . ,
Header, Caption . MaxRows .
, -

755

. ,
MaxRows .
DataSetTableProducer
, ,
, ( Response Editor).
. 12.10.
. 12.10

DataSetTableProducer

FieMNam
Dep
Fani
Nam
Par
Year b
S~
Age

TS!imgfld
TStrinsFeld
ISIiingFeld
TStnngfteU
TSmalMFrid
TBooterfield
TSmallintFd


[ {-

.. | .

, , . Add New
( . 12.10), Add All Fields
( . 12.10). , ,
Tablel .
, , .
, Add New. ,
. 12.10 FieldName ,
Caption Title .
. 12.10
. , Border ( . 12.10
1). Width
. 100%,
. Width < 100%,
.
, , .
OnAction
Tablel.Active := true;
Response.Content : - DataSetTableProducerl.Content;
Tablel.Active := false;

, DataSetTableProducerl. DB1, . Web.


Web,
. 12.11.

756

12

Hiiiiii

. 12.11

[ |
1

jhRp //mycomptei/cgi bm/ctol


*~

.. .

1965

,37

1950

52

1930

12

1937

165

,1961

41

'1975

"

.27

_jj

9 9

Microsoft Internet Explorer HTML ( HTML ), HTML,


DataSetTableProducer:
<html>
<1 </>
<body>
< Width="100%" Align="Left" Border=l>
<></><></><></><></>..
</><></><></>/>
<0></><0></00></0>
<TD>AHTOHOBHa</TD><TD>1955</TD><TD>:c</TD><TD>4 5</TD></TR>
<0></0><0></00></>
<TD>HBaHOBM4</TD><TD>1950</TD><TD>M</TD><TD>50</TDX/TR>
</TableX/body>
</html>

, .
. 12.11 ( depfio).
.
HTML, , , IndexName Tablel .
Header DataSetTableProducerl :
<html>
< </1>
<body>
<Table Border-lxCaption ><></1:.>
<TR><TDXA HREF="http://mycomputer/cgi-bin/db2 . exe/index?l">
<//>
<TDXA HREF=-"http: //mycomputer/cgi-bin/db2 . exe/index?2 ">
no oea</A></D></TR>
CTRXTDXA HREF="http://mycomputer/cgi-bin/db2.exe/index?3">
. . </AX/TD>
<TDXA HREF="http: //mycoraputer/cgi-bin/db2 . exe/index?4">
ynopflflO4eHO</AX/TDx/TR>
</Table>

757


/index , 1 4.
, : , , ..
. , . Web, Pathlnfo /index, OnAction :
case
1:
2:

S t r T o I n t ( R e q u e s t - Q u e r y ) of
Tablel.IndexNarae : = ' f i o ' ;
Tablel.IndexName : = ' d e p f i o ' ;

3 : Tablel.IndexNarae : = ' y e a r ' ;


4 : Tablel.IndexNarae : = ' ;
end;
Tablel.Active := t r u e ;
Response.Content : - DataSetTableProducerl.Content;
T a b l e l . A c t i v e := f a l s e ;

2 ( Header),
Web. . 12.12.
.
. 12.12

| > |
[]

'' jhtlp //mycompulei/cgi'brt>'db2 '

1930

72

1930

12

Rip

1937

65

'

19W

52

1955

47

I960

42

19

*"

http Mmytcmputer/tgi /dbZ exe$hdex?3 9 9

'

' zi
~~~~ Ik

, , (. . 9.5.5, . 9) , . Filter
Web ,
. , .

12.10.2
. 12.10.1 DataSetTableProducer
, , . Memo -

758

12

.
Internet DataSetPageProdueer. . 12.9 PageProducer, HTML. DataSet
, , . DataSetPageProdueer
, , , , .
Hani , , . Web. Table DataSetTableProducer. ,
, . 12.10.1.
.
DataSetTableProducer , .
Caption Title . FieldName - , , . , , ,
DataSetTableProducer .
, Web, . OnFormatCell DataSetTableProducer. OnFormatCell
.
:
void

fastcall

TWebModulel::DataSetTableProducerlFormatCell(
TObject *Sender, i n t CellRow, i n t CellColuran,
THTMLBgColor SBgColor, THTMLAlign SAlign,
THTMLVAlign SVAlign, AnsiString SCustomAttrs,
AnsiString sCellData)

CellRow CellColumn
, . 0. , 0 . 1. BgColor . Align VAlign
. :
enum THTMLAlign { haDefault, haLeft, haRight, haCenter );
enum THTMLVAlign { haVDefault, haTop, haMiddle, haBottom,

haBaseline };

Cell Data HTML, . CustomAttrs .


OnFormatCell :
void

fastcall

TWebModulel::DataSetTableProducerlFormatCell(
TObject *Sender, i n t CellRow, i n t CellColumn,
THTMLBgColor SBgColor, THTMLAlign SAlign,
THTMLVAlign SVAlign, AnsiString SCustomAttrs,
AnsiString SCellData)

(
if ((CellRow > 0)&S(CellColumn == 7))
CellData - "<a href=\"/cgi-bin/db3.exe/record?N=" +
TablelNura->AsString + "\"></>";
)

( 7),
, ( -

759

DB3). N ,
Num . , .
OnAction Default :
Tablel~>Active = false;
Tablel->IndexName - "depfio";
Tablel->Active = true;
Response->Content = DataSetTableProducerl->Content() ;


Content DataSetTableProducer.
, DB3, , .
Web, . 12.13.
.
. 12.13

.]
JMIR Mnjtcompuleryc3-t*n/db3 e

..


1
1
2

Web , . , ,
, record PathName = "/record". DataSetPageProducer.
Web , DataSet
Tablel. HTMLDoc :
<body>
<> </>
<table width="100%" Align="Left">
ctrxtd Align~"Left"><fc<l>aMmiHfl
</tdxtdxb>MMs
</tdxtdxb>0T4ecTBO
</tdxtdxb>r.p.
</tdxtd><b>IIo </tdxtdxb>Bo3pacT</tdx/tr>
<tr><td><#Fam></td><tdx#Nara></td><td><#Par></td><td><#Year_b></tdxtd>
<#Sex></tdxtdx#Age></td></tr>
</table>
<br><brxbrxhr>
<table width="100%">
< t r x t d Align-"Left"xb>XapaKTepMCTMKa </tdx/tr>
< t r x t d width="67%"x#Charactx/td>
<td width="33%"x#Photox/td> </trx/table>
</body>
</htral>

, . 12.14.
HTML . -

12

760

DataSetPageProdueer
. , , . HTML
Charact Photo. OnHTMLTag DataSetPageProdueer.
. 12.14
,

..

1950

52

, |
1950 .,
OK |
.

-. I

; 9 9

OnAction record :
Tablel->Active - false;
Tablel->IndexName - " " ;
Tablel->Active = true;
TLocateOptions SearchOptions;
Tablel->Locate ("Num", Request->QuerFieIds->Values["N"] ,
SearchOptions<<loPartialKey<<loCaseInsensitive);
Response->Content = DataSetPageProducerl->Content();

Locate ,
Num N (. OnFormatCell, ).
HTML,
Content DataSetPageProdueerl.
OnHTMLTag DataSetPageProdueer,
Charact Photo. :
if (TagString == "Charact")
ReplaceText - Tablel->FieldByName("Charact")->AsString;
e l s e if (TagString == "Photo")
ReplaceText = "<irag src=photo?N=" +
Tablel->FieldByNarae("Num")->AsString
+">";

: Charact Charact. .
HTML. <img>
,
. Web
. photo, Pathlnfo /photo
OnAction:

761

#include <Graphics.hpp>
void

fastcall TWebModulel::WebModulelphotoAction(
TObject *Sender, TWebRequest *Request,
TWebResponse *Response, bool SHandled)

(
Tablel->Active = true;
TLocateOptions SearchOptions;
Tablel->Locate("Num",
Request->QueryFields->Values["N"] ,
SearchOptions<<loPartialKey<<loCaseInsensitive);
Graphics::TBitraap *B = new Graphics::TBitmap();
B->Assign(tablel->FieldByName("Photo"));
TMemoryStreara *S1 = new TMemoryStreamO ;
B->SaveToStream(Sl);
Sl->Position = 0;
Response->ContentType = "image/x-xbitmap";
Response->ContentStreara = SI;
delete B;
Tablel->Active = false;
)

, Graphics.hpp.
TBitmap.
TBitmap, Photo ( Locate
N). S1
TMemoryStream. .
. Response>ContentType
image/x-xbitmap. ContentType Response
.
ContentType (
image ) ( ).
Response>ContentStream , . .
.
. 12.13 12.14 .

12.10.3
, . . . . , . 12.15. Pers dbP.
HTML
Web. :
<htral>
<head>
<title>ripMeM pa6oTy</title>

</head>
<body>

12

762

<><> </1>
<>3, ,
''</>
<form method="POST" action="http://mycomputer/cgi-bin/DB4.exe/resp">
<table>
<tr>
<td><strong>a</strong></td>
<td><input type="text" name="Fam" size="20"x/td>
</tr>
<tr>
<tdxstrong>MMH</strong></td>
<tdxinput type="text" name="Nara" size="20"X/td>
</tr>
<tr>
<tdxstrong>0T4ecTBO</strong></td>
<tdxinput type="text" name="Par" size="20"x/td>
</tr>
<tr>
<tdxstrong>nc^</strongx/td>
<tdxinput type="radio" value="M"
checked name="Sex"xstrong>M</strong>
<input type="radio" name="sex"
value='^"Xstrong></strongx/td>
</tr>
<tr>
<tdxstrong>rofl po:w.</strong>&nbsp; </td>
<tdxinput type="text" name="Year" size ; = M 4"x/td>
</tr>
<tr>
<tdx/td>
<tdxdiv a l i g n = " c e n t e r " x c e n t e r x p x i n p u t type="submit"
value="" name="Bl"x/td>
</tr>
</table>
</forra>
</body>
</htral>

, ,
. Fam, Nam, Par, Year , , .
. 12.15

-SssLJ



, , ]
''

["

<~

. JT90

763

1 , Post
DB4.exe ( ) /resp.
Sex . , , value, , , .
. , . 12.9,
,. .
Web. Table
PageProducer. Table, ,
Pers dbP. HTMLDoc PageProducerl Web.
Default true.
HTML ,
PageProducerl OnAction.
. Producer
PageProducerl.
HTML,
/resp. , , Response. OnAction , . - , .
, .
OnAction Response :
void

fastcall

TWebModulel::WebModulelResponseAction(
TObject *Sender, TWebRequest 'Request,
TWebResponse ^Response, bool SHandled)

Word year;

if ((Request->ContentFields->Values["Fam"] == "") II
(Request->ContentFields->Values["Nam"] == "") II
(Request->ContentFields->Values["Par"] == "") I I
(Request->ContentFields->Values["Year"] == ""))
//

Response->Content =
"<> "
"<> ";
Handled = true;

}
else
{
try
{
year = StrTolnt(Request->ContentFields->Values("Year"]);
}
catch (EConvertErrors)
//
{
Response->Content =
"<> "
"<> ";
Handled = true;
return;
)
if ((year < 1917} || (year > 1980))

764

12
//
Response->Content =
"<>, ";
Handled = true;
return;
)
Tablel->Active = true;
Tablel-Mnsert () ;
TablelFara->AsString = Request->ContentFields->Values["Fara"];
TablelNam->AsString = Request->ContentFields->Values["Nam"];
TablelPar->AsString = Request->ContentFields->Values["Par"];
TablelYear_b->Value = year;
if (Request->ContentFields->Values["Sex"J == "")
TablelSex->Value = true;
else TablelSex->Value = false;
//
Tablel->Post ;
Tablel->Active = false;
Response->Content =
"<>!<> "
"<> ";
Handled = true;

if , . , ,
.
.
, year*
, Year.
(, ), , catch .
, if , , . , , . , ,
, .
, , Insert ,
, Post
. , , . .
DB4, , (. . 12.15).
, , , . - , .
Table. SQL Ouery ( . . 10.1.6.1, . 10),
DataSetTableProducer
QueryTableProducer. Query TQuery. QueryTableProducer DataSetTableProducer .

765

12.11
12,11.1
C++Builder
Web
ActiveX. , HTML. ActiveX .
, , . Web, ActiveX,
. ,
.
, . ,
ActiveX. ,
ActiveX ,
Windows,
Web.
ActiveX . 7, 7.8.4.
. 7 . ,
,
Web. , , . 7.
, Web .
,
:
1. File | New | Other.
2. New Items ActiveX ( ) ActiveX Library (
).
ActiveX,
. 7.
3. File | New | Other, ActiveX Active Form ( ). Active Form Wizard ( ), . 12.16.
VCL ClassName , (
ActiveX, Active Form, Active
. 12.16

>

Hew ActiveX Name JMyShop


Implementing Urri jUMvShop cpp
:

'
- ActvieX CondolOpo
tins
MakeCcnbol Licensed

IncludeAbcutBox

~ include Version [reformation


|

0K

Cancel

12

766

Control, ).
New ActiveX Name (
MyShop), Implementation Unit
( UMyShop.cpp). , .
,
. ,
.
C+H-Builder .
. ,
C++Builder. , (. 12.17) ,
. . 12.19.
, . , ,
. . , ,
. . , ,
.
. 12.17

- : 0 pjjft.

3was

e-mail:
:

, . .
StringGrid,
, Label, , Edit e-mail, Memo ,
Button Label .
OnCreate :
S t r i n g G r i d l - > R o w C o u n t = 6;
S t r i n g G r i d l - > C e l l s [ 0 j [0]
StringGridl->Cells[1][0]
StringGridl->Cells[2][0]
StringGridl->Cells[3][0]
StringGridl->Cells[0][1]
S t r i n g G r i d l - > C e l l s [ I j [Ij
StringGridl->Cells[2][1]

//
"";
"";
"";
"";
" L&M";
"110":

()


StringGridl->Cells[0][2]
StringGridl->Cells[1][2]
StringGridl->Cells[2][2]
StringGridl->Cells[0][3]
S t r i n g G r i d l - > C e l l s [ 1 j [3]
StringGridl->Cells[2][3]
S t r i n g G r i d l - > C e l l s [ 0 j [4]
StringGridl->Cells[1][4]
StringGridl->Cells[2][4]
StringGridl->Cells[0](5]
StringGridl->Cells[1][5]
S t r i n g G r i d l - > C e l l s [ 2 j [5]
StringGridl->Col = 2 ;

=
=
=
=
=
=
=
=
=
=
=
=

767

" LG";
"30000";
"0";
"";
"20";
"0";
"";

"200";
"0";
"";
"10";
"0";
/ /

1
.
: , , , .
, , , , , . . - ,
StringGrid . 3.2.6, . 3.
,
- .
StringGrid RowCount = 6 (,
,
). ColCount 4. FixedCols 0, FixedRows = 1.

. OnSelectCell
StringGrid, . , , - .
OnSelectCell :
void

fastcall

TMyShop: -.StringGridlSelectCell (TObject *Sender,


i n t ACol, i n t ARow, bool sCanSelect)

{
CanSelect = (ACol == 2 ) ;
i n t summ = 0 ;
if
(CanSelect)
{

for

(int

i=

1;

i < StringGridl->RowCount;

i++)

//
S t r i n g G r i d l - > C e l l s [ 3 ] [i] =
I n t T o S t r ( a t o i ( S t r i n g G r i d l - > C e l l s [ l ] [ i ] . c _ s t r ()) *
atoi(StringGridl->Cells[2j [ i ] . c _ s t r ( ) ) ) ;
//
summ += a t o i ( S t r i n g G r i d l - > C e l l s [ 3 ] [i] . c _ s t r ( ) ) ;
}
Labell->Caption = " : " + IntToStr(summ) + " . " ;

,
. CanSelect ( ) (ACol == 2), ACol .
, ACol, 2 ( ),
CanSelect true, ACol

768

TZ

CanSelect false . ?
( 3) ,
, summ
. Label 1.
, , Enter
. OnKeyDown StringGridl:
void

fastcall

TMyShop::StringGridlKeyDown(TObject Sender,
WORD SKey, T S h i f t S t a t e S h i f t )

{
if (Key -- VK__RETURN)
{
i n t summ = 0;
for ( i n t i= 1; i < StringGridl->RowCount; i++)
{
S t r i n g G r i d l - > C e l l s [3] [ i ] =
IntToStr(atoi(StringGridl->Cells[l][i].c_str(}) *
atoi(StringGridl->Cells[2][i].c_str()));
summ + = a t o i ( S t r i n g G r i d l - > C e l l s [ 3 j [ i ] . c s t r ( ) ) ,
}
L a b e l l - > C a p t i o n = " : " + I n t T o S t r ( s u m m ) + " . " ;
)
}

,
, e-mail,
, .
:
void

fastcall

TMyShop::ButtonlClick(TObject

*Sender)

Application->MessageBox(
" "
" ",
" ",_);
)

. . ,
Web, .
Project | Build.

12.11.2
.
Web.
. Project | Web Deployment Options.
, . 12.18.
Target dir ActiveX
Web. Target URL URL . , , .
HTML dir , HTML, ActiveX. Web,
. Include file version number
,
Project | Options t'.e Versionlnfo (. . 2.3.5, . 2).


. 12.18
Web Deployment Options

769

Piqed j Package* \ AdStional Files ]

Twgal ds (Ful path o* the depbyed 0CX1


]F\Test)Slntetnet
Taiga!URL (Ritualpath of flie depfojied OCXl

[Ful pelh of the depbped HTML

, Seneial Options-~ -~""


Use CA8 He compressi
" le

!.**

Web Deployment Options


. Project | Web Deploy.
Web .
Web. ,
,
ActiveX Windows. Run | Register ActiveX Server. , , .
ActiveX Windows, Run |
Unregister ActiveX Server.
HTML, C++Builder
. , , .htm. , HTML dir
Web Deployment Options. C++Builder. :
<HTML>
<1> C++Builder 6 ActiveX Test Page </1>
You should see your C++Builder 6 forms or controls embedded in the form
below.
<HRxcenterXP>
<OBJECT
classid="clsid:lC17E3C9-8FDl-4AE0-8 971-2E3 93E99D326"
codebase="http://www.Myshop.com/PMyShop.ocx#version=l, 0,0, 0"
width=350
height=250
align=center
hspace=0
vspace=0
>
</OBJECT>
</HTML>

HTML . 12.2,
. <1> , : C++Builder 6 ActiveX Test Page
ActiveX C++Builder 6. , ,
Web. : You should
see your C++Builder 6 forms or controls embedded in the form below
, C++Builder 6.
, , . <HR> .

770

12

C++Builder <OBJECT>. , HTML. width


(), height (), align (), hspace ( )
vspace ( ) . classid , .
ActiveX,
, . , URL.
, , ,
. , .
classid (
#version=l,2,0,0) , . 12.18
Include file version number. , , . , 1.1.0.0 , , .
1, - 1 , 1, -1, .
, C++Builder HTML, . ,
html Editor.
, HTML. , , :
<HTML>

<1> MyShop </1>


.

, e-mail .
<HR><centerxP>
DBJECT
classid="clsid:39A30D25-B8B7-llD4-8 4B9-444553540000
#version=l,2,,"
codebase-"http://www.myshop.com/PMyShop. ocx"
width=350
height=310
align=center
hspace=0
vspace-0
>
</OBJECT>
</HTML>

. Microsoft Internet Explorer, , C++Builder . 12.4. . 12.19 .


Web ,
.
ActiveX,
. Microsoft Internet Explorer, ,
safety level ( ) medium (). .

771


. 12.19
Web.

MyShop


, ?
mail

LG "

20

200

42 <
e m

<&0 "

1 110

31X100
I2D0
0

< 23456
]
|^ ;^
PMy5hop.htm: 9 9

12.12

, , C++Builder 6
. .
[2]. -,
, , ,
C++Builder.

NMMSGServ NMMsg,
FastNet .
C-H-Builder. NMMsg. Host
Port, , .
, , , 6711. Port . FromName , . , . Postlt,
, sMsg .
NMMSGServ . NMMsg. , ,
FromName. OnMSG, sFrom NMMsg.
TNMStrm
TNMStrmServ. ,
, , , -, -,
..
NMStrm NMMsg. -

772

12

6711 Postlt. TStream


. .
NMStrmServ . NMMSGServ .
OnMSG sMsg .

. , . :
, . ,
IP- , .
.
. ,
,
. , .
ClientSocket
Internet. Open, Close. SendText .
SendStream SendStreamThenDrop ,
, . ReceiveText , ReceiveBuf
.
, , ServerSocket, Internet.
OnClientRead OnRead .
FostNet ,
. , . NMDayTime NMTime
. NMFTP
FTP. FTP .
NMSMTP NMPOP3 SMTP POP, . NMNNTP :
. , , .
FastNet ,
, . NMUUProcessor MIME/Base 64 UUEncoding/Decoding. NMURL URL - .

URL, HTTP.
C++Builder 6 WebServices WebSnap. ,
C++Builder, .
C++Builder [2].

12
6711 Postlt. TStream
. .
NMStrmServ . NMMSGServ .
OnMSG sMsg .

. , . :
, . ,
IP- , .
.
. ,
,
. , .
ClientSocket
Interne!. Open, Close. SendText .
SendStream SendStreamThenDrop ,
, . ReceiveText , ReceiveBuf
.
, , ServerSocket, Internet.
OnClientRead OnRead .
FastNet ,
, , . NMDayTime NMTime
. NMFTP
FTP. FTP .
NMSMTP NMPOP3 SMTP POP, . NMNNTP
. , , .
FastNet ,
, . NMUUProcessor MIME/Base 64 UUEncoding/Decoding. NMURL URL
URL, HTTP.
C++Builder 6 WebServices WebSnap. ,
C++Builder, .
C++Builder [2].



13

C++

14

C++

15


C++Builder

16

, C++, C++Builder,
API Windows

17

, , , ,


C++

C++, C++Builder. , , C++Builder, , C++. , , Object Pascal. ,
, , C++Builder. , , , - C++.

13.1
C++
:
. , , DATABASE, DataBase, Database database , . , , "_".
. , .
(, , , ) , .
/* */. , ,
, .
. , ,
"*/". , C++Builder
. Nested Comments Advanced Compiler . ,
. . "//" , , . , "II", .
";". .
.
. ,
, , ,
, , . -

16.8.3 RegisterWindowMessage

, SendMessage PostMessage.

UINT RegisterWindowMessage(
LPCTSTR l p S t r i n g
//
);

lpString , .

, OxFFFF. ,
.

,
. , .
Windows.
RegisterWindowMessage ,
.

WM_USER 0x7FFF.

16.8.4 Perform
TControl, Windows.

int

fastcall Perform(Cardinal Msg, int WParam, int LParam);

Msg , WParam LParam .

Perform API Windows, , , C++Builder. , .


Perform TMessage Msg,
WParam, LParam .
, WindowProc. , Perform . ,
Form2->Perform(WM_CLOSE,0,0);

WM_CLOSE Form2, .

16 8.5 WMUSER
. .

WM_USER ,
Windows, .
:
0 WMJJSER - 1

, Windows

\VM_USER 0x7FFF

0x8000 OxBFFF

, Windows

OxFFFF

, , RegisterWindowMessage

OxFFFF

, Windows

WM_USER 0x7FFF
.
, , (, TButton, TEdit, TListBox TComboBox) . , .
WM_USER . 7, . 7.4.4.

16.8.6 TMessage

, Windows WndProc
Messages

Messages
struct TMessage
{
Cardinal Msg;
struct
{
Word
Word
Word
Word
Word
Word

WParamLo;
WParamHi;
LParamLo;
LParamHi;
ResultLo;
ResultHi;

..-^-.. -..--

. ,.
. -- .-.::... .--. -.-.. .-..-. .....

, , ,
. , #define PI =3-14159 PI =3.14159.

C++
const, .
. , , , . , const , , , , .
#define :
// :
t d e f i n e Anyk " "
// Delete :
#define Delete
// #include:
#define GETSTD #include <stdio.h>

13.2.2.2
#define, :
define _() _

.
:
_()

, #define,
. ,
.
,

.
, , :
#define

CIRC(x)

(3.14159

()

())

, CIRC (), ;
!
. , :

S = CIRC(4);

i
:

:
S =

(3.14159

(4)

(4));

, S .

S - : 1 ( -t ) ;

:
S

( 3 . 1 4 1 5 9 *

( + )

b ) ) ;

, . , .

.
CIRC(4) .
:
S = 3 . 1 4 1 5 9 * a + b * a + b ;

(. . 13.7.15) 3.14159 * , b * , . , .

. , .

: ,
,
# d e f i n e

E l l ( x , y )

( 3 . 1 4 1 5 9

()

())

:
S

E l l ( R l ,

R2);


. ,
:
double circ(double x)
{

r e t u r n 3 . 1 4 1 5 9 * * ;
}

:
S = c i r c ( + );

, , :
.

. .
, , .
, , , . , . ,
.
+ ,
. , . , - , .
.
,
. ?1 -- -

, . , CIRC, , :
S = CIRC(a++)

(.
. 13.7.2) 1, :
S =

(3.14159 *

(++)

(++));

,
. 1, 2.
:
S = CIRC(++a)

1 , :
S = (3.14159 * (++) * (++));
, :
S = (3.14159 * ( + 1) * ( + 2) ) ;
, circ.
. , , (inline . . 13.5.6). , , , .
VIHJ1D
, . inline.

13.2.2.3 #undef

#undef, :
#undef


. ,
#undef . #define.
, :
Idefine MyConst 128
// MyConst 128
#undef MyConst
// MyConst
#define MyConst 64
// MyConst 64

13.2.3 : #if, #endif, #ifdef,


#ifndef, #else, #elif
i
.
" . , sizeof , .
#if if.
:
#if

#endif

. (), , #if #endif, .


(), , .
, ,
defined
defined 1, ' #define, 0 . , :
#if defined Debug && !defined MyConst

#endif
,
#define Debug

#define MyConst

;

#undef MyConst

#if defined
#ifdef, #if ! defined #ifndef. ,
#ifdef Size
fendif

#if defined Size


tendif

#elif ( else if if)


HFelse ( else if). ,
I1#if 1
1
ttelif 2
2
#else
3

* ' endif

1 , 1,
2 , 2, 3 , .
. ,
, (. . 2, .
2.8.11). ,
,
tifdef Debug

#endif

,
#define Debug

<

. .
#define, Debug, . 0
, , Conditionals Directories/Conditionals Project Options (. . 15, . 15.9.5).
, :
Debug, true :
#if (Debug)
<

}

Debug false, . , , .
.
.
,
, C++Builder :
ifndef UnitlH
define UnitlH


tendif

? #include, . Unitl.h,
UnitlH . .
#include , , UnitlH , .

13.3
13.3.1
. 4 : , , ( ) . : 25 -5 -

, 4.8, 515, 515, -5.18 , '',


'\0', '\', '007' , .
, . , ( 0 7). : 032. 08 , 8 .
037777777777. ,
, .
X ,
( 0 F,
). : 0XF01.
OxFFFPFFFF. , , ,
. char, signed char unsigned char.
. , '\0'. .
, . :
" , " " "

" , "
" "

" , "

, , '\'. ,
" , \
"

.
, . ,
"\"\"\ \tA.flpec\nI4BaHOB\t XtMocKBa"


""

\ , Kai
. \t \ ;
.
"\", !
. ,
"c:\\test\\test.cpp"

( )
":\test\test."
~ ~ ~ < ~ ~ > ~ ~ > ~ ~ - ^ ^
, , ,
'V .

:
enum ();
,
enum color ( red,

yellow, green };

color,
red, yellow green.
color .
, : red - 0, yellow - 1, green - 2. ,
. ,
enum color { red, yellow = 3, green = red + 1};

, : red - 0, yellow - 3, green - 1.


.
.
C++Builder ,
true , false , NULL .

13.3.2
, . .
.
. , 55,
- ,
i f (N > ) . . .

,
i f (N > 5 5 ) . . .

, NMax, 55,
, , .
, (. . 13.4.1),
const:
const _ = ;
:
const float Pi, = 3.14159;
,
. , , Pi,
const float Pi2 =2 * Pi; //
const f l o a t Kd = Pi/180; //

:
const maxint = 12345;

1
, int. ,
const Pi = 3.14159; Pi 3,
.

-
.
:
char 'const s t r l = "!";
char const *str2 = " !";

strl, . str2 . . , . ,

str2 = strl;

,
strl = str2;

13.4
13.4.1
,
, . .
:
___;
,
. :
i n t x l , x2;

. :
i n t xl - 1, 2 = 2;

,
, . :
i n t xl = 1, 2 - 2 * x l ;


, , , :
for ( i n t i = 0; i < 10; i++)

13.4.2
,
, . , , .
C++Builder : auto, register,
extern static.
, .
( )
, (, ,
, ..) . -

, - i
.
'
, , . . , .
, "{ }".
- .
:
. auto register
. .
, ,
.
auto, ,
. :
auto float x, ;


, auto .
.
, , :
{

int

1;

.
i ( ) . 1 . . , - .
register , , . :
register int i = 1;

,
,
. .
register. ,
, . , .
register .
extern static ,
.
.
.

: ,
1
static. extern.
- . , .
' ^^""*^""*^**^"^***^^^^*^"^^''^^^
I
?

, , , .
.

, static,
, .
, static
. ,
.
, i
:
(

static int i = 1;

i 1 i 1. 2. i 3. ,
, , , , .
, .
, .
extern . , , Unitl Unitl.cpp Unitl.h
( )
int a = 5;
, Unit2 Unit2.cpp Unit2.h

extern int ;

, . .
#include (. . 13.2.1), Unitl
.
. 13.6.

13.5
13.5.1
,
. , , , , .
, .
,
I = 5 * F(X) ;

F X, 5
I.
, . :
.
:
( )
.,

)

, ,
, . , .
, .
void.
, int.
.
~.._,.._
int ,
, , main. , .

, , ( )

_ _

, :
double FSum(double XI,double X2, i n t A)

FSum, XI, 2 ,
double, int. double. XI, 2 , ..
, .
.
. 13.5.2.
, :
void SPrint(AnsiString S)

, , - .
,
, void. :
void Fl(void)

void Fl ()


void , . .

C++
. , (.. , ). C++
. , , ,
C++.

( ),

. ,
";" . , . - ,
.
. ,
,
,
.
:
double FSum(double XI,double X2, ,int ) ;
void SPrint(AnsiString S ) ;
'
void Fl(void);

double FSum(double, double, int) ;


void SPrint(AnsiString);
void Fl () ;

.
-, ,
- . , , . -, , .

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

#include (. . 13.2.1), , .
~~^~^~-~^-~-~.-.'-.".-.--. -

- ( )
. ,
, .
, - ,
.

. , (, printf) .
"...". . :
int prf(char *format, . . . ) ;
format char
* (, ) .
void F p ( . . . ) ;
'
.
, .

extern static. extern , . , extern, (. . 13.6.1
. 1.9.5.4, . 1). static,
s t a t i c void F(void);
.

.
.
, , , , .
1
. , ! .
, . .
- , . ,
"::", ..
.
, , . ,
static ( . . 13.4.2).

.
,
,
return. ,

return


, .
:
double FSum(double XI,double X2, int A)
(
return * (XI + X2);
)

. , :
void S P r i n t ( A n s i S t r i n g
{.
i f (S != " " )
ShowMessage(S);
i

S)

. , return:
void S P r i n t ( A n s i S t r i n g S)
{
if (S == " " ) r e t u r n ;
ShowMessage(S);
}

- (. . 13.10). Abort,
EAbort, - . , Abort . '
-
. , .. . , . , n! = n (-1) (2) ... 1, , 1! = 1 0! = 1. for ( , , ).
n! = n (1)!. . factorial :
unsigned long f a c t o r i a l
{
if {n <= 1)
r e t u r n 1;
else

(unsigned long n)

return n * factorial(n - 1 ) ;
)

n 0 1, 1.
, factorial, , . , 1. noii .

13.5.2

, , , . ,
double FSum(double XI,double X2, int h)
XI, X2, .
:
Pr(Y,

X2,

5);

,
. . XI, 2, , Y, X2 5. X I , 2, . XI, 2 , .

. ,
.

.
- , , , .
, , ,
.
,
.
.
, .
,
;
,
.
:
. . , , (&);
. . ,
int Scount
int s count
ints count

count int. . ,
, (&).

.

:
void

square(int

&);

void s q u a r e ( i n t 4a)
{

a *= a;

/ /
//
//

. :
int xl = 2;
square(xl);
xl 4.

,
,
. ,
.
(. . 14.7, . 14). (&), (*).
"* ",
, , .
*, ( . 14.7, . 14).
, ,
&.
square, :
void s q u a r e ( i n t * ) ;

void square(int *a)

//

//

* *= *;
//
)
, , :
i n t xl = 2;
square(sxl);

13.5.3
const
.
: , , . : .
.
.
v 'oust.

( , const ) :
double F(const SA)
,
. : Cannot modify a const object.
, , .
: , , . .

, ,
.
.
const .
,
, , , , . , :
void'F(const char *sPtr);

, sPtr, const char * ( ).


, . () , . ,
.
,
, . , , .
.
.
:
void F( char *const sPtr);

.
. ,
,
, , . :
void F(const char *const sPtr);

13.5.4

. ,
, .

:) " = " , . , ,
, ,
V , (, ) 2.
, , ,
( , ), : F = G V ( - 2), G .
, , :
d o u b l e A r h ( d o u b l e V = 1, d o u b l e P = 0 . 5 ,
d o u b l e PH2O = 1, d o u b l e G = 9.81)
{ r e t u r n G * V * (PH2O - P ) ; )

. V
1 3 , 0.5 / 3 ( ), 2 1 / 3 ,
G 9,81 / 2 .
,
. ,

F = Arh();

F .
() .
, .
,
F = Arh(2);

, 2 3
.
F

Arh ( 2 , 2 . 6 ) ;
3

, ( 2.6 / )
2 3 . , , ,
,
, ,
( ).
,
, .

. , :
F = Arh(2,,1.1);

//

. , .

13.5.5
.
:
( , . . .)

( ),
. stdarg.h va_list : va_start,
va_arg va_end.
va_start :
void va_start(va_list ,

lastfix)

,

. lastfix
.
va_arg :
type va_arg(va_list , type)

. type . va_arg va_start va_arg. va_arg


.
va_end :
void va _end (va_list )

, . , va_arg . .
. average, Labell . , .
.
:
ffinclude <stdarg.h>
void average(AnsiString mess,...)
{
double A = 0;
int i = 0,arg;
va_list ap;
va_start(ap, mess);
while ((arg = va_arg(ap,int)) != 0)
{
i++;
A += arg;
)
Forml->Labell->Caption = mess + "N = " +IntToStr(i) +
", = "+FloatToStr(A/i);
va_end(ap);
}

, , :
average(" :

",4,2,3,5,4,0);

Labell :
: N = 5, = 3,6

average ,
( 0), N, :
void averaqo (AnsiStrinq mps:;, int. N, . . . )

double A = 0;
va l i s t ;
va s t a r t ( a p , N);
f o r ( i n t i 0; i < N; i++)
A += v a _ a r g ( a p , i n t ) ;
Forml->Labell->Caption = mess + "N = " +IntToStr(N) +
", = "+FloatToStr(A/N);
va_end(ap);
)

, , :
average("

",5,4,2,3,5,4);

13.5.6 inline
, . C++
(inline) . inline , .
(. . 13.2.2.2). , , , .
inline,
, .
inline
. .

'

~ -

inline
. inline ,
. inline , .

, ,
, R.
, :
i n l i n e d o u b l e C i r c ( d o u b l e R) { r e t u r n 6.28318 * R; )

Circ(2) 6.28318 * 2 ( ).

13.5.7
C++ ,
( ). . C++
, .
,
, ( .

->

- -

, ,
.

, , ,
char * ,
, . , , , ToS, ,
.
:
c h a r * T o S ( c h a r * S , l n t X)
{return strcat(strcat(S,"

"),IntToStr(X).c_str());}

char * ToS (char *S, double X)


{return strcat(strcat (S," "),FloatToStr(X) .cstr() );}
char * ToS(char *S, bool X)
(if (X) return strcat (S," true");
else return strcat (S," false");)

, , :
c h a r S [ 1 2 8 ] = " =>";
c h a r SI = T o S ( S , 5 ) ;

char S[128] = " = ";


char S2 = TOS(S,5.3);

char S[128] = " = " ;


c h a r S3 = T o S ( S , t r u e ) ;

,
double, . , , .
,
. , Area
R, , , :
double Area(double R) ( r e t u r n 6.28318 * R * R; }
double Area(double a, double b) ( r e t u r n a * b; )


51 = Area (1) ;
52 = A r e a ( 1 , 2 ) ;

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


.
. , , .

; .


, , , , . ,
, , .

13.5.8
.
, , . .
, , C++
. , .
template,
,
(<) (>). class.
, , . , .
.
,
( ) :
t e m p l a t e < c l a s s T>
min(T x l , 2, )
(
lmin - x l ;
if (2 < lmin)
lmin = x2;
if (x3 < lmin)
lmin = x3;
r e t u r n lmin;
}

, min. ( min) xl .
lmin.
, , :

int

i 1

1,

i2

d o u b l e rl 2 . 5 ,
A n s i S t r i n g si =
Labell~>Caption
Label2~>Caption
Label3->Caption

3,

13

2;

r2 = 1.7, r3 = 3.4," 1 " , s2 = " 2 " , s3 = " 3 " ;


= min(il,i2,i3);
= min(rl,r2,r3);
= min(s3, s2, s i ) ;

min ,
, min, C++
. . , .
,
:
int min(int xl, int x2,
(
int lmin = xl;
if (x2 < lmin)
lmin = x2;
if (x3 < lmin)
lmin = x3;
return lmin;
)

int x3)

, <.
--

.._..___,,,.

.,,_ ,_,,,


.
. class .

13.6
13.6.1 ,

, . ,
( . . 13.4.2),
, . , , .
, ( ),
.
. , , .
( , , start:)
, .
, ,
. switch (
case) goto (. . 13.8.1.2 13.8.1.3). , .

.

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

,
() . , ,
,
. , static, ,
, .
"::". , ::1 I,
I.

, (.
. 13.5.1). .
, . , , ,
.
,
, , ( ) extern.
, - ,
. , static.
.
, , , ,
, #include (. . 13.2.1)
.
, ,
. 1, . 1.9.5.4.

13.6.2
namespace using
. . , , , . , .
namespace ' using.

:
namespace _
(
,
)

:
namespace A{
int i = 1;
|
void Fl(int i)
(
Forml~>Labell->Caption => " A: i = " + IntToStr(i);
namespace B{
int

2;

'

void F l ( i n t i )
<
F o r m l - > L a b e l l - > C a p t i o n = " : i = " + I n t T o S t r ( i )

.
. i F1.
- . .

.
(::). ,
::F1(A::i);

F1 i .
, . ,
, .
using. using:
using namespace _;
,
using namespace A;
. ,
, - using
Fl(i);

F1 i .
using ,
:
using _ :: ;
,
using A::F1;
'
using ::i;

! 1

( i ) ;

F1 i .
namespace
, namespace, , using namespace, . , . ,
:
namespace {
namespace {
using namespace A;
namespace {


. . :
using namespace :: ;

13.7
13.7.1
. . , , . ,
" + " : X + Y . . , , . , -X X " ".
, , . . 13.7.15.

13.7.2
,
. :

+
*

/
%

X + Y
- Y

\ *

X /

Y
V


(
)

+7


( )

++

i ++; + + i

i; i

-X

.
(+) (-) , .
.
. , , .
.
( ) . .
, , .
. . 14, . 14.7.
(*) (/) .
(. . 14.2 . 14).
(%) .
. , ,
, :
1. , , .
2. , , .
.
(++) ()
(++) () . ,
. L-, .. . , ++( + ), ( + ) , .
, . , 1, (++), = + 1 += 1, . 13.7.3 (+=).

, . . , ,
.
, , . , .
,
int i = 1, j ;
j = i++ * i++;

i 3, j - 1. , j :
i, 1, , .. ; j, i 1 1
.
:
int i = 1, j ;
j = ++i * ++i;

: i 3, j - 9.
, j : i 2;
i 3; i , ..
j.

13.7.3 ,
Assign
C++ .

X = Y

, ,
,

X += Y

-=

- , ,

X -= Y

*=

X *= Y

/=

X /= Y

%=

X %= Y

X = Y

>>=

X = Y


&=

X &= Y

X != Y

= Y

(=)
. , " = " ,
.
, X += Y X = X + Y, .
: X %= Y X = X % Y .. (. . 13.7.2 13.7.6).

.
.
.
. , :
= ( = = 1 ) + 1 ;

. 1, - 2.
. , , (.. = 1). 1, = 1. 1, 1 + 1. 2 .

Assign (. . 17), . Assign
:
_ -assign (_) ;
:
A->Assign();
( ) .
:

. Assign
.
. ,
( ),
. , ,
. , , , - .

13.7.4

. true , , false (0) , . :

==

I ==

;=

!=

<

X < Y

>

Len > 0

<=

Cnt <= I

>=

I >= 1

, , .
<, <=, >, >= ,
.
== != .
true false,
.
: (==) (=). ,
if( = = 2)

...;


if(A = 2)

. , C++
, , , , if. 0, false. true. = 2
true , , if . .
, C++Builder
if :
Possibly incorrect assignment ( ).
, . , .
- ~~~*-.,.~.

,.

,
, .
.

13.7.5

: true false (0).

&&

&&

| |

(!) true,
. , !
== .
(&&) true,
. 0 (false), one
false. ,
, .
(||) true,
. 0 (false), false. ,
, .

13.7.6

, .. .

&

X & Y

X << 2

(~) .
&, | " , 1 2 :
1

1 & 2

1 - 2

El E2

( )
, . .

,
. IJ .

2 .
( )
, . ,
. 2.

13.7.7 ()
(,), ,
, . . void. . .
,
= 4;
b = + 5;


= 4 , = + 5 ;

:
_1, _2, .../ _
, .
, . ,
func(i,

(j = 1, j + 4) , k) ;

, . : (i, 5, ).
for (.
. 13.8.2.1) . , for :
i n t A[10],
sum
for

sum,

i;

= [0] ;
( i n t i = 1; i
sum += A [i] ;

<

10;

i++)

To :
int

[10],

for

(i = 1,

sura,

i;

sum = A [ 0 ] ;

i < 10;

sura + = A [ i ] ,

i++);

: ,
( i sum),
, ( sum i).

~~-~*~~
(,).
. , ,
.

13.7.8 (?:)
(?:) ()
C++, . :
? _1 : 2
, , ( ),
, ( ). ,
Labell->Caption =
grade > 3 ? " " : "";
grade grade, 3, grade.
,
if...else (. . 13.8.1.1). if...else. ,
if...else .
. (, , , ),
. - .

13.7.9 sizeof
sizeof ,
, . size_t (unsigned).
:
sizeof
sizeof (_)
:
sizeof *Labell;
sizeof(TLabel);
sizeof a;
sizeof (int);

,
(*Labell), (TLabel, int), ().
, , , . , , , sizeof.
, sizeof
, , .
., ,

(.. ). sizeof array/


sizcof [].
, , . sizeof
.
sizcof , , .

13.7.10 typeid
typeid type_info,
. :
typeid( )
typeid( )
, typeid , . , .

13.7.11 (&) (*)


(&) , (*) . . 14.7, . 14. . 13.5.2.

13.7.12 (::)
, (::). :
:
: :

:
:: _

,
. , ::1 I,
I. () . . 13.6.
- - , , . - .
, C++Builder,
.
. . 1, . 1.9.5.3.

13.7.13 : (.) (->)


: (.) (-"). -

, . , Prop F(), :
A.Prop
A.FO

, C++Builder,
. :
Labell->Caption
Labell->Hide ()

, , , , :
(*LabelI).Caption
, .

13.7.14 ( ) ( )
(<<) ( )
, cout cin,
, (. . 14, .
14.9.3.1). , outfile infile
.
include <fstream.h>
// outfile, "Test.dat"
* ofstream outfile("Test.dat") ;
if (!outfile)
{
ShowMessage(" ");
return;
,
}
...

//

outfile.close();
//
// infile, "Test.dat"
ifstream infile ("Test.dat");
if(!infile)
{
ShowMessage(" ");
return;
)
...

//

infile.close();

//

. . 14 . 14.9.3.1.
, .. , , .
, ,
, ,
, - , , ,

.
, , ,
.
. ,
outfile << "!";
!.
int i = 2 5;
outfile << i;

25.
<< , .. . , ,
outfile

" 2 * 2 =

"

(2

2);

2 * 2 = 4. ,
2 * 2 = outfile,

outfile (2 * 2);

.
, , . Memo,
OnClick :
char s i n [ 8 0 ] ;
ofstream outfile("Test.dat");
if(loutfile)
{
ShowMessage(" ");
return;
}
// , :

outfile << "2 * 2 - " 2 * 2;


//
outfile.close() ;

//
ifstream infile("Test.dat"} ;
if(!infile)
{
ShowMessage(" ");
return;
}
Memol->Clear ;
while(!infile.eof() )
{
infile.getline(si,80);
Memol->Lines->Add(AnsiString(si) ) ;
}
'

,
'

//
infile .close () ;

. 14, . 14.9.3.1.
, Test.dat,
outfile, << ,
. , infile,
Memol.

<<. ( ) , . , '\' endl ( end


line ). ,
outfile << "2 * 2 :\" (2 * 2) " \ " ;

outfile

"2

:"

<< e n d l

<<

( 2 * 2 )

<< e n d l ;

: 2 * 2 :, 4, .
.
. ,
int i = 25, j = 2;
o u t f i l e << i << " *

" j

< < " = " < <

(i * j)

<< e n d l ;


int i = 25, j = 2;
char s[80] = "25 * 2 = ";
outfile << s << (i * j) << endl;

: 25 * 2 = 50.
, char * .
AnsiString (. . 18)
.
char * c_str:
AnsiString sa = " AnsiString";
outfile << sa.c str() << endl;

. Editl
Edit2, , :
int i = StrToInt(Editl->Text);
int j = StrToInt (Edit2->Text);
outfile << i << (i == j ? " " : " ") << " " , j << endl;

... ... ...


....
, . , (. . 13.7.15) i, .
. ,
outfile << Memol endl;

0063F610 Memol.
char *.
, , s,
, . << .
,
(void *). :
outfile

(void * ) s << e n d l ;


<<.
, , .
endl. . 14, . 14.9.3.2.
( ) .
, , , . ,
. . ,
infile >> i >> j , -

, , infile, i j.
, .
, , . , ,
outfile i

'

'

<< endl;

.
outfile i << j endl;
.. ,
i, j .
char *. , :
char s [ 8 0 ] ;
i n f i l e >> s;

s. , ,
. ,
. 14, . 14.9.3.1.
, 0. , , ,
, :
while (inf i l e s l )

13.7.15
, , .
16 , .
. , , . ,
, .
, (,
), ,
.

, , .

, ,
, new delete, . 13.9.

->
! - + ++ & * sizeof new delete
.* - > *

* / %

< <= > >=

&

&&

?:

_ * = i= o/o=

__
+_

& =

-_

< < =

> > =

, + b * / d + (( * ) / d). , , .
, b * ,
. .
, ,
.

13.7.16
C++ , (.), (*), (::), (?:) sizeof.
= , [ ] , ( ) >
-. .
, -
, . ,
C++. ,
, .., , .
(
), , ,
operator, . , operator+ .

, ,
, . (=)
. - .
, ;
. (&)
;
. - .
.
. ,
.
.
, . , , .
,
, , C++ . ; , , .

~.,.,.-_._,,,..-..,._

,
, , .


Complex, , . , , .
class Complex {
public:
double Re;
//
double Im;
//
Complex(double = 0.0, double = 0.0); //
//
Complex operator+(const Complex &) const; //
Complex operator+() const;
//
//
Complex operator-(const Complex S) const; //
Complex operator-() const;
//
Complex &operator=(const Complex & ) ;
//
)'

//
Complex: :Complex (double R, double I)
(
Re = R;
Im = I;
}
//
Complex Complex::operator+(const Complex &X) const
(
Complex R;
K.Ro - Re + X.Re;
U . Im " Im X . I in;

'

rrl'urn R;
)
//
Complex Complex::operator-() const
{
Complex R;
R.Re - -Re;
R.Im = -Im;
return R;
}
//
Complex & Complex::operator(const Complex &R)
{
Re = R.Re;
Im = R. Im;
return * t h i s ; //
)

-: Re
, Im . 0.

Complex operator+(const Complex &) const;


. , , . + , Complex, , , A.operator+(B).

Complex operator+()

const;

, .
.

R Complex, .
Re Im, ,
. .

Re Im. ,
*this. this .
,
. .
= , Complex, A.operator=(B). ,
= = ? , .rator=(C). .rator=(B.operator=(C)). , , . ,
*this. .
, , :
Complex
A ( l , l ) ,
= -;
= + + ;
D = - ;

- ;

B(2,2),C,D;

13.8
13.8.1
13.8.1.1 if
if . , .
: if if...else. if :
if () ;
, , .
, . ( true ), if .
if . ,
= ;
i f ( > ) = ;

, =
> .
C++ ( )
( true,
false), . :
int , , ;
if( - /)
if(a - b/c) if(a == b/c),
b/c /. :
double , , ;
if(

/)

- ,
/ .
, _ , _ , , , , _ _ ,..,, ..,,.,,...,.
. . - ,
.

. :
if

(int v -

func(a))

...;

if, .
if...else :
if () ].;
else 2;

true, , . ,
else .

.
if (J == 0)
ShowMessage (" ");
else
Result = I/J;
, , ,
:
if (J == 0)
{
ShowMessage(" ");
Result = 0 ;
,
}
else
Result = I/J;
, else .
if , if else. , else if,
else.
,
if (1)
if (2)
onepaiopl;
else 2;
else if, .. 2
, , . ,
if (1)
j

if (2) 1;
else 2;
}

else if, :
if (!)
{

if (2) 1;
)
else 2;
13.8.1.2 switch
switch
.
switch :
switch (_) {
case _1 : 1;
break;
//
case _ : ;
break;
//
default : ;
//

, .. , , ,
.
, case, , . ":", ( ), ,
.
,
case, , , ,
, . , , ,
, ,
break;

switch .
. , , default. ,
default switch. , ,
.
, , .
.
, .
Key char, , . FYes, FNo,
.
s w i t c h (Key) {
case ' ' : case 'Y': { FYes(); break; )
case ' n ' : case ' N ' : { FNoO; break; }
d e f a u l t ; ShowMessage (" " | ;
}

,
,
case.
13.8.1.3 goto
goto
, .

goto . , goto
.
goto ,
. , , .

._.,.,

goto. . goto , , , . , ,
.


. ,
Lbegin:
, goto.
, goto, , . ,
, .
.
, , . switch ( case . .
13.8.1.2).
, .
goto :
goto ;
, goto , , :
goto L1;

second:
LI:

...

...

if ( . . . ) goto LI;
e l s e goto second;

, , ,
goto.

13.8.2
13.8.2.1 for
for
( , ) . . (),
. ,
.
for:
for (].; 2; ) ;
1 , ,
^ ,
.
for . ! ( , .. . . 13.7.7). -

( ) .
2 . (
true ), ,
for. , . ,
2,
. - 2 false ( ), , for.
for. ,
Data 10:
i n t Max, Sum;
= Sum = D a t a [ 0 ] ;
f o r f i n t i = 1; i < 10; i++)
{

i f ( D a t a [ i ] > Max)
Sum + = D a t a [ i ] ;

Max -

Data[i];

for i, , 1.
. ,
i, , , 9. for i 1 .
i for.
. i
.
BCC32.EXE,
, , , Vd.
for
(. . 13.7.7). . , i Sum ,
for:
i n t Sum, i,for(Sum = Data[0],i - 1; i < 10; Sum += Data[i++]};

for ,
Sum, , i.
for
i. for , .

. , , . . ,
, Editl, .
,
.

AnsiString s;
char Key = 'A';
s = Editl-XText;
for ( i n t i = s. Length ( ) ; i >0; s [ i ] = s [ i ]
E d i t l - > T e x t = s;

Key);

i , Lcngth(). i 1 .
,
for
Length(), .
Length() .
for . ,
- . ,
,
. , -
goto , . 13.8.2.4. for , .
- ,
( ) . ,
for (; i < 10;)
.
, for .
for .
for, Mat,
Matl Mat2 . . :
Mat[l,j] = XMatlU.K] Mat2[K,j].
i n t I , J , K, X;
f o r ( I = 1; I <= M; I++)
f o r ( J = 1; J <- M; J++)
(
X = 0;
;
f o r (K - 1; <== M; K++) '
X + = M a t l [ I ) [ K ] * Mat2[K][J);
Mat [ I ] [ J ] = X;
}

13.8.2.2 dc.while
do...while , , ,
. do...while:
do while

();

. .
,
. true ( ), . -

, false ().
, do...while.
, ,
. , ,
false. , ,
.. . .
- , , break , . 13.8.2.4.
do , - . , ,
.. . , , .
- , while ,
. ,
.
, .
, while (. . 13.8.2.3).
, for (. . 13.8.2.1).
, Filel.txt ,
( ), Editl. strstr. feof.
FILE *F;
char S [256] - "';
AnsiString SKey = Editl->Text;
if((F = fopenCFilel.txt", "r") ) == NULL)
{
ShowMessage(" ");
return;
}
do
fgets (S,256,F) ;
while(!feof (F)&& (strstr(S,SKey.c_str()) == NULL));
fclose(F);
if ( s t r s t r (S, SKey.c_str() ) == NULL)

, ,
strstr NULL ( ).
( ),
.
13.8.2.3 while
while
, . while:
while () ;
. , . true

( ), ,
, .
,
false ().
, while.
, , , .
,
false. , , .. . .
-
, , break, , , . 13.8.2.4.
while
, - .
, , ..
. , , . - , while , .
( ),
.

Filel.txt ,
Editl. do...while, while.
,
, .. .
, .
FILE * F ;
char S[256] =
A n s i S t r i n g SKey = E d i t l - > T e x t ;
i f ( ( F - f o p e n ( " F i l e l . t x t " , " r " ) } == NULL)
{

ShowMessage(" ");
return;
}

while (! feof (F) && (strstr (S, SKey ,c_str () ) == NULL))


fgets (S, 256, F) ;

fclose(F);
if ( s t r s t r ( S , S K e y . c _ s t r ( ) )

==NULL)

for:
for(; Ifeof (F) && (strstr (S,SKey.c_str() ) == NULL) ; .
fgets(S,256,F));

while .
13.8.2.4 : break, Continue, return,
Abort
, - . ,
, -

- for, do while.
-
(). .
for, do while , .
break. , switch. break for, do while .
,
:
while(!feof(F))
('

fgets (S,256,F) ;
if (strstr (S, SKey.c_str {) ) ! = NULL) break;

1
goto, - , .
, ,
return. break, return , , .
, , ,
- (. . 13.10).
Abort, , - .
.
Continue, , .
Continue,
. , ,
, , "*". :
while(!feof(F))
{
fgets(S,256,F);
if(S[O] != ' * ' ) continue;
i f ( s t r s t r ( S , S K e y . c _ s t r ( ) ) != NULL)
)

break;

, "*", . ,
strstr , .

13.9
. , , ,
. ,
, ..

:iapuiice . : )

, . ,
, ,
.
heap. : malloc, calloc,
realloc, free new delete.
stdlih.h alloc.h.
malloc :
void *malloc(size_t s i z e ) ;
heap size . . size = 0, NULL.
calloc :
void *calloc(size_t nitems, size_t s i z e ) ;
nitems ,
size. nitems *
size. . .
size = 0 nitems = 0, NULL.
realloc
. :
void *realloc(void *block, size_t s i z e ) ;
heap, block, size.
, block ,
malloc, calloc realloc. block
NULL, realloc , malloc.
size , ,
block, , NULL. ,
size 0 ,
, .
, realloc NULL. , . block,
.
free :
void free(void *block);
, malloc, calloc
realloc, block.
.
malloc , , - , .
include <stdio.h>
#include <alloc.h>
char *str;

// s t r - ,
str = (char *) malloc(lOO);

//
free(str) ;


calloc:
str = (char *) callocdOO, sizeof(char));
malloc calloc , , :
str = (char *) realloc(str, 20);

, :
realloc(str, 20);

, NULL (0),
. , , , NULL.
.
:
new delete.
new malloc,
, malloc. ,
C+4-Builder.
new :
<::> new <> < ()>
<::> new <> () < ()>
.
, , . (::) new, . (
)
. .
, . :
double *A - new double;

. *. :
* = 5.1;
Labell->Caption - *;


,
:
double = *new double;

.
. :
double * = new double(5.1);
double = *new double(5.5);

TEdit:
TEdit *Edit = new TEdit (this);
l)dit->Parent = Forml;

,
this Owner.
Forml. .
new
. ,
sizeof(THn).
,
new . .
,
delete .
,
bad_alloc.
catch (. . 13.10.3), ,
. ,
, ,
:
#include <iostream.h>
try
{

new
}

catchfstd::bad_alloc)
(

bad_alloc,
, .

set

new_handler()

. set_new_handler
, .
,
void Fl(void)
(
ShowMessage("He ");
exit(1);
}

, , (, OnCreate )
set_new_handler(Fl);


new,
bad_alloc, ( ).
,
.
bad_alloc, ,
set_new_handler(0);
new NULL.
, , NULL ,
new.

. .
,
double

*A -

new d o u b l e [ 1 0 0 ] ;

100 .
, : A[ind]. new ,
, .
. ,
'

double * = new double[100] [ 100];

.
, , . :
double *M = new double[n] [ 100];

, . . delete.
,
free. delete . , new, delete.
:
<::> d e l e t e <>
<::> d e l e t e [ ] <>
d e l e t e <__> [ ] ;

:
double *A = new double (5.1);
delete ;

double *A = new double[100];


delete [] A;

delete , NULL. ,
, :
d e l e t e A;
= NULL;

13.10
13.10.1
: , , ..
.
,
. .
, . - , .

(
), Application >HandleException. ;>
. . 13.1
StrToInt 1.5 .
. 13.1

()
()

._-.._,^
C++Builder ,
, . 13.1 , C++Builder, . , . , , . . 15, . 15.8.

, , . , ,
. - , - , , , .

13.10.2 VCL Exception


C++Builder
Exception, SysUtils
TObject.
Exception :

HelpContext

int

-- |
. , ,
,
F1. 0.

Message

System::AnsiString

,
; .

Message ,
. , ,
Message string .
HelpContext - . , ,
, F1.

') ^ cuoiicTuii HelpContcxl 0.


. ,
! ion("

",

4);

Message, ft , HelpContext, 4. F1 , . throw. , -


, , .
, HelpContext , * , Help file ( ) Project Options ( )
Application ().

13.10.3 try ... catch


try ... catch. :
try
(

I
catch ( TypeToCatch )
{

catch . TypeToCatch (int, char ..),


, ,
. ,
. [1].
.
try , catch. try
catch . ,
catch - : , - (, ) .. , . catch , , .. .
. Editl Edit2, float. .
: , , , ,
float. :
1loat

11
t

'

. :i I '! ' ! -4.it ( i l l - -1!1! :;: I

M j h H | . . , 4 M i , | '

n u n

'

' I I M I M .

i.

/ ,':i I '!

: ' I

M l , '

-' I ;-: t ) ;

catch(EConvertErrori)
(
Application->MessageBox(" ",
" ",_);
}
catch(EZeroDivideS)
(
Application->MessageBox(" ",
" ",_);
}
catch(EOverflowi)
{
Application->MessageBox("",
" ",_);
if (StrToFloat(Editl->Text) * StrToFloat(Edit2->Text) >= 0)
A = 3.4E38;
else A = -3.4E38;
}

(, , - ), StrToFloat EConvertError. .

( EZeroDivide). , catch , : .
, , .
catch .
, EZeroDivide ( ), EOverflow
( ), EInvalidArgument (
)
EMathError.
catch, , :
catch(EMathErrorS)
(
Application->MessageBox(" ",

" ", _);

, .
, . Message, , .
, catch
,
. .
, EMathError:
catch(EMathError& E)
(
AnsiString S = " : ";
if(E.Message == "EZeroDivide") S +- " ";
if(E.Message == "EOverflow") S += "";
if(E.Message == "EInvalidArgument") S += " ";
Application->MessageBox(S.cstr() , " ", _);

, Message .
, catch ,
:
catch(...)
(
ShowMessage("
)

.");

catch(...) catch,
01 , , .
, , , .
C++Builder . catch(...) ,
: The handler must be last
{ ).

~~_^._^____.__.______

catch(...). - , .

try...catch . try...catch,
try ,
try...catch. try...catch, .
,
try...catch ( ) ..
try...catch,
,
. .
, , ,
, .
catch, , , , try...catch.
, .
OnException Application . .
MyException.
:
void

fastcall MyException(TObject *Sender, Exception *E);

:
void
(
)

fastcall TForral::MyException(TObject *Sender, Exception *E)

//

MyException OnException. , , , OnCreate :


1ioation->OnException = MyException;

.
, .
MyException ,
catch . Exception. ,
Exception .
ShowException, :
Application->ShowException(E);
, ,
. 13.1. ,
. , . . ClassName. OnException , ,
:
void
f a s t c a l l TForml::MyException(TObject *Sender, Exception *E)
(
Ansistring S = " : ";
if (String (E->ClassName U ) -=- "EZeroDivide")
S += " ";
if(String(E->ClassName()) == "EOverflow")
S += "";
if(String(E->ClassName()) == "EInvalidArgument")
S += " ";
if(String(E->ClassName()) == "EConvertError")
S += " ";
t
Application->MessageBox(S.c_str()," ",_);
. 13.2 , .
, . 13.2,
. 13.1.
. 13.2
,
()
()

13.10.4 EAbort Abort


C++Builder EAbort, . , ,
. catch , TApplica-

llon::IhtndlcKxci>ption n , ,
. , ,
.
EAbort Abort.
:
if

(...)

Abort ;

: Abort
t , abort .
EAbort (,
Esc - ).
Abort ,
. ,
. ,
- , try...catch
:
catch(EAborti)

C++
14.1 ,

, C++Builder, :
Aggregate

Array
struct
union
class

Li

Function

Scalar

Arithmetic
Enumeration
Pointer
Reference
void

. : void, char, int, float double, short (), long (), signed ( )
unsigned ( ). , unsigned char, unsigned int, signed int ( signed ).
C++ :

unsigned char


-128 126
0 255

short
unsigned short

-32 768 32 767

enum
long
unsigned long

0 65 535
-2 147 483 648 2 147 483 647

char

4
4

-2 147 483 648 2 147 483 647


0 4 294 967 295

int

long

unsigned int

unsigned long

float

3.4 138 3.4 10 3 8

double

1.7 1308 1.7 10 3 0 8

long double
bool

10

3.4 - 3 2 1.1 4 9 3 2

true false

int8, intl6, ;int32,


int64,
. . 14.3.
, C++Builder,
C++, bool , .
. 0 false,
true.
- ,
- , , , , .
, , , , , .
, . , , .

(. . 13.4.1 13.5.1). :
double = 5.4, = 2;
int ;
void (double A ) ;

.
. , (. . 13.6).
:
typedef

, ^ . ,
typedef double Ar[10];

10 .
. :
= ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 0 ) ;

typedef , C++. C++Builder Object Pascal , C++. sysdefs.h. :


typedef
typedef
typedef
typedef

bool Boolean;
int Integer;
short Smallint;
unsigned char Byte;

Delphi (.. Object Pascal) C+ + .

Delphi

C++

Shortlnt

signed char

typedef

Smalllnt

16

short

typedcf

Longlnt

32

int

typedef

Byte

unsigned char

typedef

Word

16

unsigned short

typedef

Integer

32

int

typedef

Cardinal

32

unsigned int

typedef

Boolean

true/false

bool

typedef

ByteBool

true/false
8

unsigned char

typedef

WordBool

true/false
16

unsigned short

typedef

LongBooI

true/false
32

BOOL (WinAPI)

typedef

AnsiChar

char

typedef

WideChar

Unicode " wchar t

Char

char

typedef

AnsiString

AnsiString Delphi

AnsiString

Delphi,
n = 1..255

SmallString<n>

ShortString Delphi,
255

SmallString<255>

typedef

String

AnsiString Delphi

AnsiString

typedef

Single


32

float

typedef

Double


64

double

typedef

Extended


80

long double

typedef

Real


32

double

typedef

Pointer

32

void *

typedef

PChar

32

unsigned char *

typedef

PAnsiChar

ANSI 32

unsigned char *

typedef

Comp

64

Comp

OleVariant

variant OLE

OleVariant

String[n]

typedef

14.2
,
, C++Builder
.
: ,
mero . ,
. , , ;
, ..
,
. .
,
.
. ,
, .
.
double = 5.4,
i n t = * b;

b = 2;

10, 10.8.
* ,
, .

i n t m = 1, n - 2,"
double = m / n;

= 0. , m / n , .

i n t = 1 ;
double n = 2;
double = m / ;

= 0.5. double, ,
double double.
, :
double = 300, b = 200;
short = * b;

, , -5536, 60 000. ,
short , 32 767. 60 000, short .
, . ,
.
()

, .

i n t m = ] , n = 2;
d o u b l e = m / n;

. . ,
:
.luwLli'

(double)m / ;

,
, double. un.ii double,
, . 0.5.
, : ( . . 13.5.7, . 13), . C++Builder 4
TPoint P;
. = 5;
. = 1;
L a b e l l - > C a p t i o n = " = " + I n t T o S t r ( P . ) ;

: Ambiguity between 'fastcall Sysutils::IntToStr( int64)' and '_fastcall Sysutils::IntToStr(int)' (


IntToStr int64 int). ,
, ( )
. ,
int:
Labell->Caption

"

"

IntToStr((int).);

.
C++Builder 5
. .

14.3
.
char, short, int long
signed unsigned . .
, .

char, signed char


unsigned char
char, unsigned char
signed char
int, signed int
unsigned, unsigned int
short, short int, signed short int
unsigned short, unsigned short int
long, long int, signed long int
unsigned long, unsigned long int

, char signed
, char unsigned

signed unsigned char, shorl,


int, long. signed unsigned,
signed int unsigned int.
unsigned
signed. char. C++Builder
char signed unsigned.
,
char ch;

signed char ch;
char , :
unsigned char ch;

long short int. long short, long int


short int.
, ,
ANSI . , short, int long , .. short <= int <= long. , . ,
,
.
, C++Builder
32 , . 14.1. ,
, int long 32 .
: 0 , 1 .
, int, .
i ui,
. , .

__int8

i8

int8 = 127i8;

intl6

116

_ i n t l 6 s = 32767il6;

int32

i32

int64
unsigned

i64

int64 ui64

int32 i = 1234567832;

()
8
16
32

int64 big = 12345654324; 64


unsigned
int64 hugelnt =
1234567887654321ui64;

64

float double. 32
, 64. double long, 80 .

C++Builder 32 .
14.1. ANSI
. , ,
, sizeof (. . 13.7.9, . 13).

14.4
14.4.1
C++ . , ('\0').
.
. , , C++
. ,
.
. . 14.10.1, .
, char*.
char S[] = "";
char *Sp = "";

. 7 S '', "\ '', ', '', ""


"\0\ Sp,
, - .
1 .
, . , S[0] Sp[O]
, S[l] Sp[l] ..
. . ,

char

buff[100];

buff, 99 .
.
strcat () , strcmp ,
strcpy , strstr , strlen , strupr - .
, sprintf .
. 16, . 16.4.2. .
. buff. - ? strcpy:
strcpy(buff,", buff");
, , , , .
. , , S1 , S2. strcat:
char S l [ 2 0 ] - " 1",
s t r c a t (S1,S2);

S 2 [10]

= " 2";

, ,
. , -
.

strcat , , , , . strcat,
. .
, S
S1 S2, .
:
c h a r * S 1 = " 1 " , *S2 = " 2 " ,
strcat(strcat(strcat (S,SI),"
"),S2);

S[20];

strcat S S1,
S , , strcat ,
S, , . strcat S strcat - S2.
, , S
. S, .
strcat
s t r c p y (S,S1)

, . , ,
, ..
s t r s t r (S1,S2)

S1 S2 , , .
, .
.
S1 S2 , ,
, S3. , S1 S2 S3.
.
char

Sl[20],

S2[20],

S3[20],

S[60],

*St;

// SI, S2, S3

St = s t r s t r ( S I , S 2 ) ;
if (St)
{

*St = 0;
St += strlen(S2);
Labell->Caption = s t r c a t ( s t r c a t ( s t r c p y ( S , S i ) , S 3 ) , S t ) ;

)
else Labell->Caption = " ";
SI, S2, S3 S, , .
St. .
strstr S2 S1 St.
strstr ( false),
. , . , St, 0 . S1,
. St , strlen. St
S1 , die-

S
Label 1.
treat strepy. strcpy. S
, S1. ,
S1 . strcat
, S S3.
treat S1, . St.
, . S1
, S2 , S3 . S1 :
'', ' ' , '', ' ' , ' ', ' ' , ' ' , ' ' , ' ', ' 1 , ' ' , '' , '' , '\0'
strstr St V. , S1 :
' ' , ' ' , ' ' , ' ' ,

' , ' \ 0 ' , ' ' , ' ' , '

' , ' ' , ' .' , ' ' , ' ' , ' \ 0 '

Pt
. strcpy S S1,
:
' ' , ' ' , '

, ' ' , '

' , ' \ 0 '

strcat S S3:
' ' ,'

,'

,'

,' ','

, ' ' , '

, ' ' , ' ' , ' \ 0 '

strcat S , St,
.. S 1 , :
' , ' , ' ' ' ' , ' ', ' , " 1 , ' ' , ' 1 , ' 1 , ' ' , ' ' , ' ' , ' ' , ' ' , ' \0'
sprintf.
Editl,
, CSpinEditl TCSpinEdit,
. ..., ... .,,
: .
:
include < s t d i o . h >
c h a r S[40] ;
s p r i n t f (S, " %s,

%i

r.p.",Editl->Text,

CSpinEditl->Value);

sprintf . ( . . 16 . 16.1.2.1).
, "% ", , sprintf . Editl, %s, ,
CSpinEditl, %i, .
. . 16, . 16.4.2.
C++Builder C++ , .
. AnsiString,
,
, TStrings TStringList. . . 17.

14.4.2 AnsiString
13 C++Builder AnsiString ,
vcl/dstring.h Delphi.
. AnsiString
.
AnsiString ==, !=, >, <, >=, <=.
. ,
, , ,
, . ,
, , .
AnsiString =, += () +. []. 1. , S1 = "", S l [ l ] '', Sl[2] ' ..
AnsiString , . 17.
, AnsiString.
AnsiString C++Builder. , , Text , Caption ..
TStrings. ,
, AnsiString.
AnsiString.
() :
Labell->Caption = Editl->Text + '

' + Edit2->Text;

Labell>Caption , Editl, ,
, Edit2.
, AnsiString " + " .
strcat,
(char *), AnsiString.

S1 , S2, S3.
, , :
AnsiString SI, S2, S3;
// SI, S2, S3
i n t i = SI.Pos (S2) ;
if (i)
Labell->Caption = S I . S u b s t r i n g ( 1 , i - 1 ) + S3 +
SI.Substring(i+S2.Length(),255);
e l s e Labell->Caption = " ";

- AnsiString: Pos,
Substring, Length. ,
(.), C++Builder
(>). ,
, AnsiString .
Pos.
, ( S1),
, ( S2). , . 1. , ::<> 0.

ii(jMoim>io if...else ,
(fal.se) Pos . ,
. : S1, , S3, ,
S1, .
S1 Substring.
, ,
, , , . , Sl.SubString(l, i 1) S1,
1-1 , .. S1, S2. , Sl.SubString(i + S2.Length(), 255)
S1, S2.
Length,
( S2, ). Substring 255, , ,
. 255 , ,
S1 .

(char *), ,
AnsiString.
,
S1, ,
:
int i = SI.Pos(S2);
SI - SI . S u b S t r i n g d , i - 1 )

+ S3

+ SI.Substring(i+S2.Length(),255);

(char *) .
: S1 S2 S3. :
i n t iO =
while(i)
<

0,

Sl.Pos(S2);

SI = SI.Substring (1,i + iO - 1) + S3 +
SI.Substring (i + iO + S2-Length(), 255) ;
iO += i - 1 + S3. Length ();
i = S l . S u b S t r i n g ( i O + 1, 255) .Pos(S2) ;
}

- . . -,
, S1.
. -, S2 S1
S1, : Sl.SubString(iO + 1, 255).

, Delete Insert AnsiString.
Delete , , , , .
Insert , , , .
11.1, , :

. i n ' 1, i
w l n l e (i > iO)

S I . P o s (S2) ;

S I . D e l e t e ( i , S 2 . L e n g t h ( ) ) ; // S2
SI.Insert(S3,i);
'
// S3
iO = i + S 3 . L e n g t h ! ) ;
i = iO - 1 + S I . S u b s t r i n g ( i O , 2 5 5 ) . P o s ( S 2 ) ;
}

,
AnsiString. . 17. , AnsiString (char *). ,
AnsiString (char *), ,
(char *). API Windows
C++Builder, . ,
Application>MessageBox, ( )
(char *). PlaySound .
AnsiString (char *) c_str() , , AnsiString, . ,
S1 S2 AnsiString,
Application>MessageBox ,
Application>MessageBox :
Application->MessageBox (Si . c__str () , S2 . c _ s t r () , MB_OK) ;

(char *) AnsiString.

AnsiString(char *S)
AnsiString, ,
S, .

14.5
,
.
, . ,
C++Builder , ,
, .
, . , , Mode,
:
, , . , ,
Mode int
: 0 , 1 , 2
.
if

(Mode

= = 1 )

...

, Mode, 1,
. : Mode mRead, mEdit, mWrite.
:

if

(Mod.- -- mfcdit)

. . .

, , .
~-.
, -
. .
.
:
enum (< 1>, . . . , < >}< >;

enum {mRead,

mEdit,

mWrite} Mode;

mRead, mEdit, mWrite Mode, . , ' mRead. . :


Mode = mEdit;

, . , , : >, < .. , :
i f ( M o d e > mRead)
i f ( M o d e < mWrite)
i f ( M o d e == m E d i t )

...;

Mode switch:
switch (Mode)
case mRead:

...
break;
case mEdit:
...
break;
case mWrite: . . .

, enum, , 0, 1 .. >, <


. , (=) , , . :
enum {mRead = - 1 , mEdit, mWrite = 2} Mode;

- , 1
. mRead - 1 ,
mEdit 0, mWrite .
enum .
:
enum regim {mRead = - 1 , mEdit, mWrite = 2} Mode, Model;

Mode Model ,
regim. regim - , :
teqim Mode3;

14.6
, , ,
. , .
C++Builder , vcl/sysdefs.h.
:
Set <type, minval, maxval> , type .
int, char . minval maxval unsigned
char .
0, 255.
.
si
:
Set

'A1,

<char,

'Z'>

si;

Ch, :
Set <char,

0,

255> Ch;

UPPERCASESet s2 s3 :
typedef Set <char,
'A','Z'>
UPPERCASESet s i , s 2 ;

UPPERCASESet;

S, : red, yellow, green:


enum E ( white, red, yellow, green );
Set <E, red, green> S;

Set -
. .
( ):


Set
fastcall operator
-(const Set& rhs) const; :
rhs ( )

Set&

,
fastcall operator
-=(const Set& rhs);
; rhs ( )

Set&

fastcall operator
,
*=(const Set& rhs);
: rhs
( and )

Set

fastcall operator
*(const Set& rhs) const; : rhs ( and
)

Set

Set&

fastcall operator
,
+(const Set& rhs) const;
: rhs
( or )
fastcall operator
+=( const Set& rhs); : rhs ( or
)

Set&

fastcall operator
( c o n s t T el);
friend ostream& operator
( ostream& os, const Set& arg);

el

Set&

el
arg istream ( 0 1
)

Set&

fastcall operator
=(const Set& rhs);
rhs

fastcall operator
( c o n s t T el);
friend istream& operator
(istream& is, Set& arg);

arg ostream ( 0
1
)

bool __fastcall operator


==(const Set& rhs) const; : rhs ( )
bool
fastcall operator
!=(const Set& rhs) const ; : rhs

,
, (type, minval
maxval) . , ( +, *),
, , ,
. true , . false.
Set :

Clear

Set&

Contains

bool

fastcall Clear();

fastcall Contains(const T el)


const; el

..
* , Yes/No. HO:I

, ,
, , Y, N.
:
Set <char,

0,

''

255> T r u e K e y ;

'

'n'

'N';

, Key MHO
, Contains:
if

('TrueKey.Contains(Key))
ShowMessge(" " ) ;
else . . .

. ,
Editl , .. 0 9.
, OnKeyPress :
1

Set <char, ' , ''> Dig;


D i g < < ' 0 ' ' 1 ' ' 2 ' < < ' 3 ' '' ' 5 '
' 6 ' << ' 7 ' ' 8 ' < < ' 9 ' ;
if
(!Dig.Contains(Key))
( K e y = 0; B e e p ( ) ; }

, ,
( ) .
. 5, . 5.3.2.2.

14.7
, , .
, .
.
, ,
. :
type *ptr;

type ,
ptr . : ptr type.
,
i n t *countPtr, count;
countPtr int * (.. ) count . * countPtr.
, ,
(*). , count
, :
int *countPtr,

*count;

* .
void:
void *Pv;

. , , -
. :
Pv = countPtr;


, Ptr , , , , , .

C++Builder . , , .. . , :
TForml *Forml;
TButton *Buttonl;

,
. , NULL . 0
NULL . NULL , , .
:
int *countPtr = NULL;

~~--;---^^

NULL . .

&, . ,

int = 5;
int *yPtr, ;


y P t r = &;

yPtr.
, , *, . ,
(.. ). , ,

= VyPtr

5, .. , yPtr.

------------~.__=___-_

void, , .

C++
. . ,
.
,
. :
int

S I

I 1 . 7. . . '] 1 .

*l't;

[5] Pt.
,
Pt b
Pt = b;

Pt = Sb[0] ;

[3] *(Pt + 3).


, . , Pt[3] [3].
, ,
.
.
,
. ,
, .

. (++), (), (+ +=), ( =) .
.
1 ,
, .
. ,
Pt ,

Pt += 2;

Pt . Pt
, , 2.
, b 2 , Pt (.. , Pt) 4.
.
. , Pt
, P t l ,
P t l Pt 2 ,
. , , ,
, 4 ( 2 ).
,
. ,
, . >, <, >=, <=
. == !=
. ,
.
,
.
,
. void (.. void*), , . void
. void

iipiiciiocii ' void


.
.
.
.
, :
char *Sa[2] = (" ", ""};

2 (char *). . C++ , ,


. , . , .
. , .
. . . 13.5.2, . 13.
. 1.9.6 . 1
.

14.8
, . , (&) ,
. -
MyObject:
MyObject *P = new MyObject;

:
MyObject s Ref = *;

Ref
MyObject. . , .
. ,
,
>, .. .
Ref.x, .. .
. , Label 1, Caption
Labell->Caption = " ";
:
TLabel & ref = * L a b e l l ;
r e f . C a p t i o n = " ";


. . 13, . 13.5.2.

14.9
C++Builder ( ) :


C++
.

14.9.1 /

LoadFromFile SaveToFile, TStrings TStringList.
,
.
, , . :
TStringList, ,
AnsiString, . :
TStringList *List = new TStringList;
AnsiString SFile = "Test.txt";

He , ,
(. . 13.3.1, . 13). ,
c:\MyTest\Test.txt, c:\\MyTest\\Test.txt.
, ,
List->LoadFromFile(SFile) ;
, , ,
. ,
. :
try{
List->LoadFromFile(SFile);
}

catch(...)(
ShowMessage(" \ " " + S F i l e + " \ " ");
)

List, . Strings[int Index],


AnsiString. .
List >Strings[O] , List>Strings[l] ..
TStringList ,
. 17.
, AnsiString (. . 14.4.2 . 17).
,

List->SaveToFile(SFile);
SFile .

.. Windows, . 3.10.2, . 3,
.
, ,
- ,
TStringList. TRichEdit.
,
RTF. Lines
TStrings, LoadFromFile SaveToFile. :
Memol->Lines->LoadFromFile(SFile) ;
RichEditl->Lines->LoadFromFile(SFile) ;

Memo RichEdit . 3, .
3.2.4.
C++Builder , . . 6.

14.9.2 /
14.9.2.1
C++ (stream),
. , .
.
, , ,
() FILE, stdio.h.
fopen,
FILE.
.
fopen:
ffinclude <stdio.h>
FILE *fopen(const char *filename,

const char mode);

fopen ,
filename, . mode ,
. :

+
w
W+

" + " t , , . , rt, rb, r+t, r+b .. t, ,


fmode,
fcntl.h. _ ( ) O_BINARY . . 10, . 16.5.2.

fopen , .. "!
, , .
. . 16 . 16.5.2
.1 , .
fopen , .
, fopen .
, ( ) ,
fclose(FILE *), .
14.9.2.2
Test.txt :
#include < s t d i o . h >
FILE *F;
if ((F = f o p e n ( " T e s t . t x t " , " r t " ) } == NULL)
f
ShowMessage(" ");
return;
}
...
//
fclose(F);
//

F
Test.txt, .
(, ), .
. fclose(F).

fopenCTest.txt", "rt + ")

,
.
.
fgets:
char *fgets(char *s, int n, FILE *stream);

s , ,
. \ ( ), - 1
. .
, Memol :
char s[80];
Memol->Clear () ;
do
(
fgets(s,80,F);
if(feof(F)) break;
if (s[strlen (s)-1] = '\n') s [strlen (s)-1] = 0;
Memol->Lines->Add(s);
}
while(true);
fclose(F);
//

fgets . feof , . feof


. ,
if(sIstrlen(s)-1]

==

'\n')

s [strlen (s)-l]

- 0;

,
. , \ Memol. .

fscanf.
int

fscanf(FILE

*stream,

const

char

*format[,

address,

...]);

format ,
. . 16, .
16.1.2.2. , "%",
. ( . . 16.1.2.2, . 16):

int *arg

long *arg

int *arg

long *arg

unsigned int *arg

unsigned long *arg

e, E

float *arg

char arg[]

char *arg

. , 1 long int, double.


, , , , , .
:
int il, i2;
double r;
fscanf(F, "%d%d%le", sil, si2, &r);

, ,
fscanf , , .
(&) , .

- - . , , , fscanf.

.
:
if (fscanf(F, "%d%d%le", sil, 2, &r) !- 3)
{
ShowMessage(" ");

s ,
,
. , , , ,
, Editl
, , ,
, :
char s [80], key[10];
strcpy(key,Editl->Text.c_str());

do
{

//

f s c a n f ( F , "%s", &s);
i f ( f e o f ( F ) | | !strcmp(s,key))

break;
)
while(true);
fclose(F);
if (!stremp(s,key))
ShowMessage(" ");

s key,
strcpy . fscanf s . stremp . 0, s key . ,
.
.
. fprintf:
int fprintf(FILE 'stream, const char *format[, argument, . . . ] ) ;

fscanf, . , "%".
. ,
, "%", . fprintf
. 16, . 16.5.4. .
s (char *), ,
year, .
, , ..., ... ...
. :
FILE * F ;
if ((F = f o p e n ( " T e s t . t x t " , " w t " ) ) =- NULL)
<
ShowMessage(" " ) ;
return;
}

char S[40] ;
int year = 1960;
strcpy(s,"" ) ;
fprintf(F, "\ %s, %i r.p.\n", SS, year);
I.I,,:;,. ([') ;

. fopen . , . , . fprintf
TtKCT. ,
\; , %s, S, %i, year,
. :
[

, 1960 . .

. . 16,
. 16.5.4.
14.9.2.3
, - , .. , . ,
. .

- . , ,
: . ,
, ,
.
, . ,
- , , , .
, , . 14.9.2.1.
fwrite fread:
#include <stdio.h>
size__t fwrite (const void *ptr, size_t size, size t n, FILE *stream);
size__t fread(void *ptr, size_t size, size t n, FILE "stream);

ptr .
size , .
.
i n t i = 1, j - 2 5 , i l , j l ;
double a = 2 5e6, a l ;
char s [ 1 0 ] , s i [ 1 0 ] ;
strcpy(s,"");
FILE * F ;

//
if ( (F - fopen ("Test.dat", "wb")) NULL)
{
lihowMi':; :;.jqe (" ");
* -1 u i 11;

! wi i L(- ((,i, sizeof (int) , 1, F) ;


twrite(Sj,sizeof(int),1,F);
fwrite(sa,sizeof(double),1,F);
fwrite(s,sizeof(char),strlen(s)+1,F);
fclose (F);
//
if ( (F = f o p e n C T e s t . d a t " ,
{

"rb"))

//
//
//
/ /

i
j

== NULL)

ShowMessage(" ");
return;
}
fread(Sil,sizeof(int),1,F);
/ / i
fread(&j1,sizeof(int),1,F);
/ / j
fread(Sal,sizeof(double),1,F);
/ /
fread(si,sizeof(char),strlen(s)+1,F);
/ / s
fclose (F);

Test.dat
i j, s. ,
il, jl, al si.
, , .
.

fwrite(s,sizeof(char),strlen(s)+1,F);

//


strlen(s)+l ( ).
:
fread(si,sizeof(char),strlen(s)+1,F);

//

strlen(s)+l .
.
, , . , , , ?
.
:
f w r i t e ( s , s i z e o f ( s ) , 1 , F) ;:
fread(sl,sizeof(s),l,F);

, :
s, .

fwrite (s, sizeof (char) * 10, 1, F) ;:
fread(sl,sizeof(char)*10,1,F);

, . ,
,
.
- , ,
. :
/ /
fwrite(s,sizeof (char),strlen

(s)+l,F);

/ /

f o r f i n t i n d = 0;

i n d < 10;

ind++)

I i i-.id ( ; U i i r i c i , aizeot ( c h a r ) , 1, fc") ;


if ( u l [ i n d ]
=-- ' \ 0 ' ) b r e a k ;

t
for . ,
sl+ind. sl[ind], fread
, , .
fread fgetc, :
si l i n d ]

= f g e t c (F) ;

, ,
. , . :
//
i n t it = s t r l e n (s)+1;
f w r i t e ( S i t , s i z e o f ( i n t ) , 1 , F );
f w r i t e ( s , s i z e o f (char) , i t , F ) ;
//
f read (Sit, sizeof (int) , 1, F) ;:
f r e a d ( s i , sizeof(char) , i t , F) ;

>

. ,
, . () , . .
ftell, :
long int

ftell(FILE stream];

fseek:
int

fseek(FILE *stream,

long offset,

int whence);

offset , whence. whence :

whence

SEEK SET

SEEK CUR

SEEK_END

whence = 1, offset (
) ( ).
rewind ( 0). ,
fseek(F, 0L, 0) ;

, . , double, , i-oe
,
fseek(F,
sizeof(double)*(i-1),
1 road(so, sizeof(double),1,F) ;

0);

.
, , , , ,
10. ,
(, rb+), , ,
:
fread(Sa,sizeof(double),1,F) ;
*= 10;
fseek(F,-sizeof(double),1);
fwrite(Sa,sizeof(double),l,F);
,
10. ,
fread .
, , .
:
long i n t pos = f t e l l ( F ) ;
fread(Sa, sizeof (double) , 1, F) ;
a = 10;
fseek(F,pos,0);
fwrite(Sa, s i z e o f ( d o u b l e ) , 1 , F ) ;

//
//

ftell , , fseek .

, , , . , spers, pers persl, pers , . , ,
persl.
struct spers
{
char Name[20];
int year;
);
struct spers pers, persl;
strcpy(pers.Name,"");
pers.year = 1960;
FILE *F;
if ( (F = fopen{"Test2.dat", "wb")) == NULL)
{
ShowMessage(" ");
return;
}
fwrite (Spers, sizeof (spers) ,1,F) ;
fclose(F);
if ( (F = fopenCTest2.dat", "rb")) == NULL)
{
ShowMessage(" ");
return;
)
fread(Spersl,sizeof(spers),1,F);
fclose (F);

14.9.2.4 /,
,
FILE, . , , .

Htdin
Htdout
stderr

0
1
2

.
, , io.h. stdio.h, fcntl.h, sys\types.h
sys\stst.h.
open, :
((include <fcntl.h>
(tinclude<io.h>
int open(const char *path,

int access,

unsigned mode);

path . access . mode


.
access (|) . ( . . 16, . 16.5.1):
RDONLY
O_WRONLY
O_RDWR

O_CREAT


, 0

O_TRUNC
O_BINARY
OJTEXT

mode :
S_IWRITE

S_IREAD

S_IREAD | S_IWRITE
,
int handle;
if ((handle = open("Test.txt", O_CREAT | OJTEXT)) == -1)
(
ShowMessage(" ");
return;
, ( open - 1) .
_creat, ,
.

close:
inl close(int handle);

, handle, write read:


((include < i o . h >
i n t w r i t e ( i n t h a n d l e , v o i d *buf, u n s i g n e d l e n ) ;
i n t r e a d ( i n t h a n d l e , v o i d *buf, u n s i g n e d l e n ) ;

buf ,
len .
, , , . 14.9.2.3, i j,
s:
#include <stdio.h>
#include < s t d l i b . h >
#include <fcntl.h>
#include < s y s \ s t a t . h >
include <io.h>
include < s t r i n g . h >
i n t i = 1, j = 25, i l ,
double a = 25e6, a l ;
char s [ 1 0 ] ,
sl[10];
strcpy(s,"");

jl;

int handle;
//
if ((handle = open ("Test.txt", O_WRONLY | O^CREAT | O^BINARY)) == -1)
ShowMessage(" ");
return;
write(handle,
write(handle,
write(handle,
write(handle,
close(handle)

Si,
Sj/

sizeof (int) ) ;
sizeof(int));
sa, sizeof(double));
s, strlen(s)+1);

//
//
//
//

i
j

//
if ((handle = open("Test.txt", O_RDONLY I O_BINARY)) == -1)
ShowMessage(" ");
return;
}
read(handle, S i l , sizeof( i n t ) ) ;
r e a d ( h a n d l e , S j 1,. s i z e o f ( i n t ) ) ;
read(handle, Sal, sizeof(double));
read(handle, s i , strlen (s)+1);

/ /
/ /
//
/ /

i
j

close(handle);

, . 14.9.2.3,
, . , , . 14.9.2.3, .
, , tell lseek, . 14.9.2.3 ftell
fseek, .
dup dup2, , , ,
. . 16, . 16.5.3.

14.9.3 / C++
14.9.3.1
C++ /:
ifstream

ofstream

fstream

, , ,
( )
( ) .
, , . ,
ofstream out file("Test.dat");
if (!outf i'le)
{

ShowMessage(" ");
return;

outfile, Test.dat, , , .
- , outfile
if .
, :
ifstream i n f i l e ( " T e s t . d a t " ) ;
if ( l i n f i l e )
{

ShowMessage(" ");
return;


( ) ( ) , . 13, .
13.7.14. , ,
. ,
, :
i n t i = 1, j = 2 5 , i l , j l ;
double a = 25e6, a l ;
char s [ 4 0 ] , s i [ 4 0 ] ;
strcpy(s,"");
//
ofstream o u t f i l e C T e s t . d a t " ) ;
if(!outfile)
(
ShowMessage(" ");
return;
)
outlile << i << ' ' << j << ' ' << a << ' ' << s << endl;
// :<
n u t I i l c . I'lo.'ii- ( ) ;

//
Hstream infileCTest.dat");
if(!infile)
{
ShowMessage (" ").;
return;
]
infile il >> jl >> al si;
//
infile.close () ;

Test.dat
i j, s, ,
endl (. . 13.7.14, . 13)
. , , .
, ,
.
, , 1 25 2.5+07 . ,
,
.
. 13,
. 13.7.14. ,
,
. 14.9.3.2.
: put write.
put . ,
outfile.put(' 1 );

. put . ,
outfile.put('').put('\n');

.
write ,
, , . ,

outfile.write(s,5);

outfile 5 s.
, .
, , ,
.
read - . gcount
, .
.
( ) , . ,
. , ,
. ,
s - . ,
.
ifstream : get get line. get : get(), get(char) get(char *, int n, char delim).

get
(, )
. get EOF, .
get , :
char s[80], ;
ifstream infilefTest.dat");
if(linfile)
(
ShowMessage(" ");
return;
)
int i = 0;
while( ( = inf ile.get () ) != EOF)
<
lf(c == '\n')
{
//
s[i] = 0;
//

i = 0;
}
//

else s[i++] = ;
}

//
infile.close () ;

.
/, s. /, - , . , :
, .
, .
get() -
. , " $ " :
while (( = inf ile. get () ) != EOF)
if( == $') break;
if (

--'$)

...

- get (, )
. get , ; get , - get.
get
,
while:
while(infile.get())
- get :
s, delim (

' \ ' )
, , 1 -

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

:
char s[80] ;
ifstream infile("Test.dat") ;
if(linfile)
{
ShowMessage(" ");
return;
}
while(!infile.eof() )
(
'infile.get(s,80);
infile.get();
//
}

//
infile.close();

get . \ get
(, 80 ). ,

infile.get(s,80) ;

inf ile .get () ;

. ,
.
get , ,
. getline. get . get getline (.. );
.
getline :
while(!infile.eof())
{

infile.getline (s,80);
//

14.9.3.2
. 14.9.3.1 . 13, . 13.7.14 endl, .
, .

, ,
M m o l , OnClick :
include <fstream.h>
include <iomanip.h>
char s [ 4 0 ] ;
//
Ofstream outfile("Test.dat");
if (!outfile)
{
ShowMessage(" ");
return;
)
// ,
//
OUtfile.close();
ifstream infile ("Test.dat");
if(linfile)
{
ShowMessage(" ");
return;
)
Memol->Clear () ;
while(linfile.eof())
(
infile.getline(s,80);
Memol->Lines->Add(s);
)

//
inf ile . close () ;

dec, oct, hex setbase , , , .


. ,
. setbase . . <iomanip.h>.
.
i n t i = 31;
outfile << i << ' hex << i << ' ' oct << i << ' '
<< setbase (10) << i << endl;
31 If 37 31. 31 , ,
.
, .. , setprecision precision.
, .
,
:

for ( i n t i = 0; i < 10; i++)


o u t f i l e s e t p r e c i s i o n (i) << s q r t p . O ) << endl;

setprecision 0 9 it
3.
0 , 6. :
1.73205
2
1.7
1.73
1.732
1.7321
1.73205
1.732051
1.7320508
1.73205081

, precision:
f o r d n t i = 0; i < 10; i++)
(
outfile.precision(i);
outfile << sqrtp.O) << endl;
}

precision , ,
int i = outfile.precision();

.
setw width (..
, , , ) . , ,
. , .. .
, , .
; 0, .. , . width, , .
setfill(char)
fill.
,
25:
int j = 25;
for(int i = 0; i < 5; i++)
outfile setw(i) << j endl;

:
25
25
25
25
25

, , , .

, width:
fordnt i = 0,- i < 5; i++)
(
outfile.width(i);
outfile << j endl;
)
setfill, . ,
for(int i = 0; i < 5;.i++)
outfile ' setfill('*') setw(i) j << endl;

:
25
25
25
*25
**25

( ) .
. ,
, , ,
tab, \t.
// tab
ostreams tab (ostreams output)
return output

'\t';

, . ,
outfile '' << tab '' tab ' << endl;
, , :

14.9.3.3
ios / .
ios::skipws
ios::left
ios::right
ios:: internal




,
, ios:: dec
dec
ios::oct
, oct
ios::hex
, hex
ios::showbase
ios::showpoint

ios::uppercase

ios::showpos

" + "

ios::scientific

ios::fived

flags, setf unsetf, setw, setiosflags resetiosflags.


flags . , , (|)
long, . flags long, .
, flags
.
setf setiosflags , ,
|,
. ,
setiosflags(ios::showpos I ios::showpoint)

ios::showpos ios::showpoint.
resetiosflags unsetf , ,
. , #include <iomanip.h>.
.
, showpoint:
outfile 1. " " << 1.1 "
" <<
setiosflags(ios::showpoint) << 1. << "

" << 1.1 << endl;

:
1

1.1

1.00000

1.10000

, right, left internal:


outfile << setw(6) << -1.1 << endl
<< setw(6) << resetiosflags(ios::right)
<< setiosflags(ios::left) << -1.1 << endl
<< setw(6)/<< resetiosflags(ios::left)
<< setiosflags(ios::internal) << -1.1 << endl;
:

-l.l
-l.l
-l.l
, resetiosflags
, right,
left internal .
, showbase:
o u t f i l e << 63 << oct << " " << 63 << hex << " " << 63
<< s e t i o s f l a g s (ios::showbase) << dec << endl
63 << oct " " << 63 hex << " " << 63 << endl;

:
63 77 3f
63 077 0x3f
, setiosflags, dec, oct, hex.
, scientific fixed:
outfile << " :" << endl
0.0123 ' ' 1.236 endl << endl
<<' " scientific:" << setiosflags (ios :: scientific)
endl
0.0123 ' ' 1.23e6 endl << endl
" fixed:" << resetiosflags(ios::scientific)
setiosflags (ios::fixed) endl
0.0123 ' ' << 1.23e6 endl;
:
:
0.0123 1.23+06
scientific:
1.230000-02 1.230000+06
fixed:
0.012300 123Q000.000000
,
, , .
, showpos showpoint:
o u t f i l e << s e t p r e c i s i o n (4) << setw(3) << 60. << endl
<< s e t i o s f l a g s ( i o s : : s h o w p o s | i o s : : s h o w p o i n t ) << 60.
endl;
:
60
+60.00
setiosflags .

14.10
14.10.1
, , - . , , (
), .
, .. 1.
:
[_]
,
int A[10];
, 10 .*
A[i], i ,
, , 0-9. , [0] , [1] , [9] .

, 1 .
, 0.
.
[0] = 1;
[1] = 1;
f o r ( i n t i = 2; i < 10; i++) A[i] - A [ i - 2 ] + A [ i - l ] ;

, 2
1, .
. ,
c h a r S[10] ;

. (. .
14.4.1) , . , . , ,
1, .
.
, .
:
i n t [10] - ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 0 ) ;
char S[10] - ("abcdefghiNO");

, , . ,
i n t [10]

= (1,2,3);

, 0.
i n t [] - {0};

------
, . , - .
.

, , , .
S . . ,
:
char S[10] = ("abcdefghi");
char SI[10] = {"abc"};

10 , .
. . ,
i n t [] = {1,

2,

3,

4,

5};

.
char SI[] = ("abc"};

. , ,
:
i n t [10];
//
//
i n t Sum - [ 0 ] ;
f o r ( i n t i - 1; i < 1 0 ; i + + ) Sum += A [ i ] ;

'.

, 10 ,
, , 100,
, , ( for).
. , .
:
const Amax = 10;
int A[Amax];
//
//
int Sum = [];
for(int

i -

1;

i < Amax;

i++)

Sum += A [ i ] ;

Amax
, . ,
Amax. .
Amax ,
- .
, #define (. . 13, . 13.2.2).
fdefine Amax 10

~_---__-_.


.
.

, .
. :
const AnsiString Day[] = ("", "", "",
"", "", "",
"");

14.10.2
, .. ,
. , :
i n t A2 [10] [ 3 ] ;

,
, 10 3 .

, . ,

2[3][2] ,
(, 0).
, .
A3 4 3 2.
i n t A 3 [ 4 ] [ 3 ] [2]

{({0,1), (2,3), (4,5)),


({6,7}, ( 8 , 9 ) , {10,11}},
{{12,13},{14,15},{16,17}},
{{18,19},{20,21},{22,23}}};

i A3,
0

12

13

18

19

14

15

20

21

10

11

17

22

23

16

, [0][1][0] 2, [3][0][1] 19 ..
- ,
.

14.10.3 ,

.
. 14.7.
,
.
sizeof,
, , . ,
sizeof(A)

s i z e o f (A[0] )

.
/ ARRAYSIZE.
ARRAYSIZE()

. , F , :
void ' F l i n t

Ar[]);

:
c o n s t Amax = 1 0 ;
i n t AfAmax];
F(A);

, . , ,
[2]. C++ (. . 13, . 13.5.2).
', , , .

, . ,
.
, .
:
/
void F ( i n t A r [ ] ,

i n t N);

:
F(A, Amax) ;


, , .
:
F(A, Amax - 1) ;

, Object Pascal,
TIX . , sysdefs.h EXISTINGARRAY, .
:
F (EXISTINGARRAY (A) ) ;

EXISTINGARRAY .

sizeof.
Object Pascal, C++Builder, ,
. sysdefs.h
OPEN ARRAY, . :
OPENARRAY(TVarRec,

(_1,

_2,

...))

19.

.
, :
void F(const

int Ar[],

i n t N) ;

, , , . :
''WJjftt Sum ( c o n s t i n t A [ ] ,

i n t N)

&}

// N -
int S = A[0];
f o r ( i n t i = 1; i < N; i++) S +- A [ i ] ;
r e t u r n S;

.
^ d e f i n e Bmax 10

i n t [10] = { 1 , 2 , 3 , 4 , 5 , . 6 , 7 , 8 , 9 , 1 0 } ;
ShowMessage(" " + I n t T o S t r ( S u m ( , B m a x ) ) ) ;

.
- . ,
, .
Bmax, a Bmax 2,
0 7.

- . , :
Sum( + 2, - 2)

, . , 0 7,
, 2 9. .. , .
, , . , F2 3 3, :
void

Ffconst

int

Ar[][3]);

.
, F(A).

14.11
14.11.1
, .
. , ,
, .
. , .
:
struct TPers
AnsiString
unsigned
bool
AnsiString
);

{
Fam,Nam,Par;
Year;
Sex;
Dep;

struct .
TPers (, -) .
.
TPers. ,
. , . .
TPers . ,
.
: Fam, Nam, Par Dep , , , , . Year , Sex . ,
. , TPers
TPers.
TPers. , , , -

.
(. . 14.11.2).

; ,
. , .
TPers Pers, PersArray[10], *Ppers;
Pers TPers, PersArray 10
TPers Ppers TPers.

.
:
struct (
AnsiString Fam,Nam,Par;
1
unsigned Year;
bool
Sex;
AnsiString Dep;
}Pers, PersArray[10], *Ppers;
: (.) (->).
. :
Pers.Fam = "";
Pers.Nam = "";
Pers.Par = "";
Pers.Year = 1960;
Pers. Sex = true;
Pers.Dep = "";

. ,
Ppers = SPers;
Ppers Pers.
:
Ppers->Fam = "";
Ppers->Nam = "";
Ppers->Par "";
, , . Ppers->Year = 1960;
,' Ppers->Sex = true;
.'V Ppers->Dep = "";

14.11.2
. (. . 13, . 13.9) , , . , , . . .
NULL,
.

. 14.1

NULL

, . 14.11.1, , :
struct TPers (
AnsiString Fam,Nam,Par;
unsigned
Year;
bool
Sex;
AnsiString Dep;
TPers * pr;
);
.
, :
TPers *P0 = NULL, *Pnew, *Pold;

. . , :
//
Pnew - new TPers;
//
Pnew->Fam = "";
Pnew->Nam = "";
Pnew->Par = "";
Pnew->Year = I960;
Pnew->Sex = t r u e ;
Pnew->Dep "";
Pnew->pr = NULL;

if(PO == NULL) PO = Pnew; // PO -


else Pold->pr = Pnew;
//
Pold = Pnew;
( = NULL), (Pnew).
(Pold).
.
NULL. , .
, . :
Pnew = ;
while(Pnew != NULL)
{
ShowMessage(Pnew->Fam + " " + Pnew->Nam + " " + Pnew->Par);
Pnew = Pnew->p_r;
//
, ..
. .
, . C++Builder -

TList TStringList,
. , . 17.

14.11.3 C++
, , ,
C++, C++ (. . 14.12).
, - -. TPers.'
- Show, , :
struct TPers {
AnsiString Fam,Nam,Par;
Year;
unsigned
Sex;
bool
AnsiString Dep;
TPers * pr;
void Show()
{

ShowMessage(" \ " " + D e p + " \ " "+Fam+" "+Nam+" " +


Par+", "+IntToStr(Year)+" . . , *+
(Sex ? "" : ""));

Show : "" , 1960 .., .


- . :
Pers.Show();
Pnew->Show();

Show . 14.11.2 :
Pnew = 0;
while(Pnew != NULL)
'(
Pnew->Show();
Pnew = Pnew->pr;
)

C++ - - , .
public () private ().
- . ,
.
- -,
, (), - .

. , , . .
public .
- , private,

,
. , private
public, . ,

struct MyStr (
int x, ;
int Get ;
private:
int a, b;
void F() ;
);
Get
, b F
Get.
, C++ . . 14.12, .

14.12
14.12.1
, . , C++Builder
, C++Builder C++. ,
(. . 14.11) C++ .
, ,
.
, . .. .
:
class < > : < - ^
( ,
public:
//
<, , , >
published
//
<, >
protected:
//
<, , , >
private:
//
<, , , >
) < >;

:
class MyClass : public Classl, Class2
{
public:
MyClass(int = 0 ) ;
void SetA(int);
int GetA(void) ;
private:
int FA;
double , ;
protected:
int F(int) ;

. , C++Builder, .
( -),
( -), ,
, - .
-,
.
lass 1 Class2.
- C++Builder
, , .
, - . :
class MyClassl
, {

,
. public () ,
. .
published () ,
,
, .
private () ,
. protected () , . , . , ,
, , .

MyClass, SetA GetA. FA, ,
. , . MyClass , , ,
. . - .
- ( public).
, : public ( )
-, private . . 14.12.5.
( )
private. , . , , . ,
-, .
- () , :
> < >;

. , . 14.12.4.
- (. . 13, . 13.5.1).
, , .
C+4-Builder,
. ,
MyClass , 1 0 [ 1 0 ] ,

*;

MyClass, 10
.
, , , .
,
MyClass MC(3);

, FA 3.
, , .
, , ,' . :
class MyClass : public Classl, Class2
(
) , 10[10], *Pmc;

(. . 13, . 13.9),
new. :
MyClass *PMC = new MyClass;

MyClass *PMCl - new MyClass(3);

-
1.
, C++Builder. ,
new. , :
class MyClass2 : public TObject


MyClass2 *P2 = new MyClass2;

14.12.2 -, ,

, (. . 1 . 1.1),
. ,
, , .

.
private
. protected
, .

, - , . .
, - , .

. :
Class Myclass
{
' public:
void SetA(int);
int GetA(void);
private:
int FA;
double , ;
);

//
//

:
void MyClass::SetA(int Value)
(
if(...)
//
FA = Value;

int MyClass::GetA(void) (return FA;)


,
- . , -
(::).
, . . :
class MyClass
(
public:
MyClass(int = 0);
void SetAlint Value) (FA= Value;);
//
int GetA(void) (return FA;};
//
private:
int FA;
double , ;
};

, , inline (. . 13,
. 13.5.6, ).
: , , .

,
inline:
inline void SetA(int);

//

. inline
.

, - . .
- . , , - - .

- - -, , .
(- , ) - -. , . , friend. ,
friend void

IncFA(MyClass

*);

IncFA, , . , IncFA - :
void IncFA(MyClass *P) (P->FA+ + ;)

, . ,
friend Classl;

- Classl .
const. :
const Classl MCI(3);

, , , ,
. ,
const.
, .
, .
, .
,
const. ,
int GetA(void) const;

:
int MyClass::GetA(void) const (return FA;}


, , - , ,
const,

14.12.3 -, ,
:

' .' -.
( - .
|
|^ . , .
jC . , , ,
|.
.
,
. static. :
static int D;


, , -.
.

^ , (protected). . :
MyClass::D = 10;

- .
, . , : . -,
.
( , )
.
- , , - ( )
i n t MyClass::D - 0;


-
. ,

. ,
.

,
-:
class MyClass
{
public:
static int D;
static int GetDl(void);
private:
static int Dl;

int

MyClass::GetDl(void)

( r e t u r n Dl;}

i n t MyClass::D = 0;
i n t MyClass::D1 = 1;

: D D1. D1,
, GetDl.
(public) ( static). , .
GetDl.
static. , . ,
.
. :
i = MyClass::D;

j = MyClass::GetDl();

- . :
static const ,int MaxA = 10;
const int MinA;


, .
,
. . 14.12.4.

14.12.4
. ,
. , >
( , ) !,
, ..
. , , ;*

,
. -
.
-, .
, .
:
Class MyClass
[
public:
HjfClass ( v o i d ) ;

//

int A;

MyClass::MyClass(void)

(A = 0 ; )

MyClass ,
0.
TOt .
,.., jpytT . . Mtp, SetA, ,
. :
MyClass::MyClass(void)

{ SetA(O); }

MyClass :
MyClass ;

I :
MyClass *PMC = new MyClass;

1 , .
,
.
- .
, , . ,
MyClass ( i n t ) ;
:
M y C l a s s : : M y C l a s s ( i n t a)

SetA(a);

FA , .
MyClass (1) ;

M y C l a s s *PMC = new M y C l a s s ( 1 ) ;

t , F 1.

,

.
(. .
13, . 13.5.4). :
MyClass(int = 0);
:
MyClass::MyClass(int a) ( SetA(a); }

. ,
. ,
( 0). .
.

~~~~~~~"~~_..

, .

,
. :
const int MaxA;
, , FA.
(. . 14.12.3),
:
static const int MaxA = 10;

. , . . , ,
. ,
MyClass
const int MaxA;
const i n t MinA;
,

MyClass(int = 0);
:
MyClass: :MyClass (int a) : ( ) , MinA(l) {SetA(a);};

10,
MinA 1.

. :
MyClass(int A = 0, int MaxA = 10, int MinA = 1);

MyClass(int

0,

int

=10,

int

1);

( , ,
).

:
MyClass::MyClass(int a, int i, int j) : MaxA(i), MinA(j)
( SetA(a) ; }
, , :
M y C l a s s ;

MyClass MC(20);

// : = ,

MyClass M C ( 2 0 , 1 5 ) ;
MyClass MC(20,15,2);

// :

// :
// :

= 10, MinA = 1

= 20, = 10, MinA = 1

= 20, = 15, MinA = 1


= 20, = 15, MinA = 2

. -,

.
, (-). ,
. :
class MyClass
{

public:
-MyClass ( ) ;

//

, - -
, - .
.
.
, .

14.12.5 , ,

, - , - -, , .
( ). .
public,
protected private (. . 14.12.1). .
public , .
.

.
. , .

.


- public
protected
-

public

public - protected - private




-, ,

.

protected

private

private

' -

protected - protected - private



- '
- |
-


-
- .


-
- .


-
- .

- - (
), i
. ,
. - ,
.
, , Shape:
class Shape
public:
void Draw(void);

Circl:
class Circl : public Shape
(
public:
void Draw(void);
);
Draw,
Shape *PQl = new Shape;

PQl-?Draw();

C i r c l *PQ2 = new C i r c l ;

,'; PQ2->Draw();
PQ2->Shape: : Draw ();

((Shape *)PQ2)->Draw();

// Draw Shape
// Draw Circl
// . Draw Shape
// Draw Shape

. >.. . , Draw
propbi. ,
Circl, . * ( )
, .
- Circl Draw, .
, .
. , Shape: Circl (), Rectangle (), Square () ..
. Draw, . ,
Shape, .
1 , , .
, :
Shape *ShapeArray[10];
:

ShapeArray[0] = new C i r c l ;
ShapeArray[1] = new Rectang;
ShapeArray[2] = new Square;

'k :
for(int i = 0; i < 3; i++)
ShapeArray[i]->Draw();
.
Shape,
;(D .
",
). -<, jkax. - ,
,| (< , ,
. , Shape Draw
; ,
.

. Shape
:
virtual void Draw(void);

! ,
.
virtual. , - virtual, ,
. C++ .
( ). , .
, , :
virtual void Draw(void)=0;

Draw Shape, , . .
, ,
. . -.

14.12.6 ,
C++Builder
14.12.6.1
, C++Builder, . new.
, ^
(property), ()
. ,
, , private. ,
' F ' .
:
p r o p e r t y <> <> = (read=<MH >
write=<MH >
<
>;

read write ,
.
read , . ,
, .
Get, .
write , . , . Set, .
write ,
.

,
.dfm.
default >
. . , , .
. MyClass, TObject .
:
class MyClassl : public TObject
(

private:
int FA;
protected:
void
fastcall SetA(int); //
published:
property int A = (read = FA, write = SetA, default = true);
);

FA, SetA,
, , .
read . ,
. write SetA, . -
.
:
void
fastcall MyClassl::SetA(int Value)
{ i f ( . . . ) FA = Value;
}
published.
, ,

. public, - ,
,
. write ,
, .. .
property :
property <> <> < > =
(read=<MMH >
write=<MMH >

<
>;

, .
N :

//
class Matrix
{
float *data;
int N;
//
int M;
//
public:
Matrix(int,int) ;
-Matrix ( ) { delete! ] data; }
property float Items [int i] [int j] =
{ read=GetItems, write=SetItems
private:
float
fastcall Getltems(int i, int j ) ;
void
fastcall Setltems(int i, int j, float value);
Matrix::Matrix(int n, int m)

//

data = new float [n*m];


//
for(int i = 0; i < n*m; i++) //
data[i] = 0.;
N = n;
M = m;
)
void

fastcall Matrix::Setltems(int i, int j, float value)

// value (i,j)
if ( (i<l) I I (i>N) I I (j<l) I I (j >M) )
ShowMessage(" (" + IntToStr(i)
11
, " + IntToStr (j ) + ") ") ;
else data[(i-l) * M + j - 1] = v a l u e ;

float
{

fastcall Matrix: .-Getltems (int i, int j)

// (i,j)

if ( (i<l) I I (i>N) | I (j<l) | | (j>M))


ShowMessage(" (" + I n t T o S t r ( i ) +
", " + I n t T o S t r (j ) + ") ") ;
else return d a ta [ ( i-l) * M + j - 1];

Matrix. *
Items, .

property: float Items [int i] [int j].
i j .
: [int] [int].
.
Getltems ,
.
1, , , , .
Setltems value -
, .
, ,
, :
Matrix (4,5);

4 x 5 . I t e m s . :
x.Items[2][3] = 1.5;
float = x . I t e m s [ 2 ] [ 3 ] ;

1,5 3- 2- ,
.
" .
. 8, . 8.3.3.
14.12.6.2
, .
C++Builder ,
TObject ( this), TNotifyEvent. ++. OnClick ,
TObject *Sender.
, . :
private:

TNotifyEvent FMyEvent;
published:
property TNotifyEvent MyEvent = (read= FMyEvent, write= FMyEvent};
,
* . , , ,
true, . ,
, ,
, , . :
if(FMyEvent)

OnMyEvent(this);

OnMyEvent, ,
. ,
On.
, , .
- , . - , Windows, ( . 7,
. 7.4.3) .
- this,
TNotifyEvent
. closure. :
typedef void
fastcall ( closure *TMyEvent)
(System::TOBject *Sender, bools MyParam);
class T : public TObject
{

private
TMyEvent I'MyEvent;
published
property TMyEvent FMyEvent = (read= FMyEvent, write= FMyEvent};

. 8,
. 8.3.5.
- .
, , .., , .

14.12.7
C++ ,
(generic) . ,
,
.
,
. ,
, , , , .
(. . 13.5.8,
. 13).
template <class > class

, . :
template <class T> class Matrix

Matrix . .
, ,
. 14.12.6.1.
//
template <class T> class Matrix
{

*data;

int N;
//
int M;
//
public:
Matrix(int,int);
-Matrix( ) ( delete! ] data; )
property T Item [int i] [int j] =
{ cead=GetItem, write=SetItem ) ;
private:
T
fastcall Getltem(int i, int j ) ;
void
fastcall Setltem(int i, int j, T value);
};
//
template <class T> Matrix<T>::Matrix(int n, int m)
{
data = new T[n*m];
for (int i = 0; i < n*m;
data[i] = 0;
N = n;
M = m;

template <class T> void


fastcall
Matrix<T>::SetItera(int i, int j, T value)
(
// value (i,j)
if ((i<l) I I (i>N) I I (j<l) I I (j>M))
ShowMessage (" (" + IntToStr(i) +
", " + IntToStr (j) + " ) " ) ;
else data[(i - 1 ) * M + j - 1] = value;

template <class T> T


(
//

;,

fastcall
Matrix<T>::GetItem(int i,

int j)


(i,j)
if ((i<l) | I (i>N) I I (j<l) I I (j>M))
ShowMessage(" (" + IntToStr(i)
"," + IntToStr (j) + ")") ;
else return data[(i - 1) * M + j - 1] ;

. 14.12.6.1, ,
float, .
14.12.6.1, .
.
: , , ..
. 14.12.6.1
- .
, , , :
Matrix<float> x ( 4 , 5 ) ;

4 x 5 . . 14.12.6.1 ,
, . ( float) , .

, . 14.12.5.1, Items. :
. I t e m s [ 2 ] [ 3 ] = 1.5;
float = .Items[2][3];

1,5 3- 2- ,
.

IS

C++Builder
:> C++Builder, |iMi< . [1].

15.1
,
. Drag&Doc,
(. . 2.1.8). .
-
.
,
, . View | Toolbars.
, . , : Standard, View, Debug, Custom, Component Palette, Desktops, Internet,
C.ORBA. - (,
Custom, ,
). -
. .
, ,
Customize, ,
- . , . 15.1. Toolbars , Reset .
Reset,
, . ,
- ,
, C++Builder.
Commands . 15.1 (Categories)
(Commands), .
.
, .
1 Options . 15.1 Show tooltips , Show shoricul keys on tooltips
.
, . 15.1 , 1.).

. 15.1

ill
Toolbars Commands ] Options |
Categories:
Commands:
Component
CQRBA
Database
Debug

.
~

Separator

r Redo

File
Help
Internet
Project
Run
Search

SB Paste
X Delete
Select AH

To add command buttons, drag and drop commands onto a toolbar.


To remove command buttons, drag them off of a Toolbar.
Dose

Help

15.2

Properties . Component | Configure Palette.
Tools | Environment Options
Palette (. 15.2).
. 15.2

Environment Options

| OaisE** | 0 ! CBu*Ji Diect | Internet 1


Preferences} Designer j Obiect Inspector Palette j Ubraiv i E nvionmern Variables J
KaslNet

_*j

QRepoit
Samples
ActiveX
COM*
Indy Clients '
Indy Servers
IndyMisc
0f(ice2k
Templates

InterBase Adrrun
ActiveX

[A]
Z.

9
jPackage
TDpenD
a
oilg

TDpenP
ciL
treiDidcsd
lt60
TSaYeP
ciu
te
tD
dictd
jIO
fi
TFonD
ta
rbo dc
s
dleO
i TCoa
frD
d
o
ilg dc
sd
tlSO
TPrnD
tao
ils dc
sd
tl6O
Qename...

Move Up

MoveD

.
Pages Add, (.>
. 15.2 , ActiveX
), Rename, , Delete, .1
( ), Move Up .
Move Down, . , >
, '
.
. ;
, Components .
: Name, Package Page. m
,
, , .

. Delaull Pages. , 41 , C++Builder .


Components ,
Hide -
( Hide Delete, . 15.2, -
). Move Up Move Down,
.

15.3 Tools
Tools , .
C++Builder, . |> Tools | Configure Tool. , . 15.3 .
Tools, ( Delete), (
), ( Edit). , ,
.
)

15.3
Tools ()
()
f

Database Desktop
Visual ** Proiect Conversion Utility
QodeGuard Contiguistion
Image Editoi
Package Collection Editor
MLt

conflicting shortcut keys

JB
l CIcCn
i soe
l
Erogiam

JD \Program Files\Boiland4nierBase\bmMElConsole.e

Caned

fb XPiogramFiles(Borland\lnterBate\bin

Macros
$COL
$R0W
$CURTOKEN
$PATH
$NAME
5NAME0NLY

Cursor cou
l mn in topmost editor
Cmsoifew in topmost editoi
j
Word el cursor in topmosl editoi
Director portion of parameter
File name of parameter
File name of paa
i meter without extension zl

Insert

Add .
, . 15.3 (
[11131 . ).
Proyrnm
. Wnikinq .

. , Browse.
, , .
Title .
, .
. Parameters , .
, Macros ( . 15.3 ). :
$1

. , 50, C + + B u i l d e r 50 .

$ROW

. , 10,
C + + B u i l d e r 10.

$CURTOKEN (),
. , Label, C++Builder Label.
$

, . $ ( ) .
. , $ P A T H ( $ E D N A M E )
, .

$NAME

, . $NAME().
. , $ N A M E ( $ E D N A M E )
,
.

,
. $(). . ,
$ E X T ( $ E D N A M E ) ,
.

$EDNAME

, . : " C : \ P R O J 1 \ U N I T 1 . C P P " .

$EXENAME


. : " C : \ P R O J 1 \ U N I T 1 . E X E " .

$PARAMS

,
Run | Parameters.

$PROMPT

, .
$ P R O M P T ( ) .
, .

SSAVE

, .

SSAVEALL

$TDW

T u r b o Debugger:
, , , ,
. , Tools.

. 15.3 ,
Insert Parameters.

15.4

Properties . Tools | Editor Options.
(. 15.4) ,
: General, Display, Key Mapping, Color.
. 15.4
General

. -

Ceneral ] Dsi play ] Key Mappn


i gs] Colors} Codelmightj
- Edmx opbom ~-~

P uto dent mode


F
U
n
d
o
a
K
e
s
i
a
e
j

'
*

*
*
5
W Wart mode
BRIEF regUaj ewressero
(7 Uselabchaacter
" <-istail blocks
r samw
fipunalfi
P1 Backspace
F Cutset through labs
P" grot*> undo
Cureof beyond 0F
Editor SpeedSetong

*;

P Overgnta blocks
Qaide tick Ira
I? (( at cursor
* force cut and copy enabled
p' Usnlaxhi**ghl

Default keymappmg

Block isdenl 2

^j

jj
Undo.M- (32767

jj

lab ops 3

ZJ

Syntax extenaons. cppxxcjpp h hh cxx.h>

-
t

ifl 7^ Jill

Cancel

tit*

General . 15.4. Editor Options ( ) , :


Auta indent mode Enter
.
Insert mode
, . Insert.
Use tab character .
, . Smart Tab, .

Smart lab

. Use Tab Character, .

Optimal fill

Backspace
unindents

Backspace
.

Cursor through
tabs

Group undo

Alt-Backspace
Edit | Undo , .

Cursor beyond
EOF

Undo after save

Keep trailing
blanks

, .

BRIEF regular
expressions

Brief.

Persistent blocks


, .

Overwrite blacks

. Persistent Blocks,
.

Double click line

-
. ,
.

Find text at cursor , ,


Search Find .
Force cut and
copy enabled
Use syntax
highlighting

Edit | Cut Edit ,


.
.
Colors.

. , Editor SpeedSetting ( ) : Default Keymapping ( ), IDE Classic ( ),


BRIEF emulation ( BRIEF), Epsilon emulation (
Epsilon), Visual Studio Emulation ( Visual Studio), Visual Basic
emulation ( Visual Basic).

:
Block indent

. 2, 16.

Undo limit

, . 32,767 (32).

Tab slops

, .
, .

Syntax extensions , . ., ., .,
.hpp, .h, .hh, .cxx .hxx.
Display . 15.5. .
. 15.5
Display

Veraonlnta
Pascal
form

|
|

Packages

Inker

Tasro

Advanced Linker

AppJcaOon

Compiler

Code optimization

CORBA
]

CodeBuaid

Diectonej/Condilionals

Advanced Conpler

C.

i I Ple-compited headers '


! None.

1
1

Speed
I" Selected

e pre-comprled headers
'* ' - ' " ' ti I (J Cachepie-compiedheaders
' filename:

Warning None

Slq; aei

' fill
1

Selecled

Debuggmo

P7 Ooburjinformatran
1

Cofflpinj
duplicate strings

W Line nutter information

Stacfcftamei

' (7 0*81

fieatenumtsjesasW

P Show general metsafles

Bleasa
De(a<*

| [
[

EnlendedetiornfiaUcin]
Help

Display and file options :


Brief cursor shapes

BRIEF.

Create backup file


.
, "-".

Preserve line ends

Show tab character ()

" " . Use tab


character General.

Zoom to full screen

. ,

.

Sort popup pages menu

Show space character (.)

, :

Visible right margin .


Right margin


. 80 . 1024.

Visible gutter


, .

Gutter width

. - 30.

Editor font

, .
Courier. , .

Size

,
.

Sample

Key Mappings Key mapping modules


. Color ()
.

15.5 Code Insight


Code Insight , (. . 2.7.1),
Tools | Editor Options Code Insight (. 15.6).
. 15.6
Code Insight

switch*
swrtche

switch statement
switch statement (with default)

j3

""*'
*

M::._.
"",.".

Code Insight:
Cade Completion

, , , .

Code Parameters

, , .

Tooltip Expression
Evaluation
.
Tooltip Symbol Insight ,
.
.
, . , , C++Builder, Code Completion. , ,
, , . , Ctrl-.
Toaltip Symbol Insight,
C++Builder . ,
, .
Delay Code
Insight. ,
. , .
Code Templates
C++, Code Insight.
,
. Edit . , ,
. Delete
. Add
. , , do...while ( C++Builder ). Add,
(. 15.7),
Shortcut Name ( dowhile) Description.
( . 15.6).
. 15.7

Shortcut NamejdotvMe

I
K Cancelj
O

jdo () Me [)

, . , , ,
. .

15.6
C++Builder 6 .
Tools | Environment Options
Object Inspector (. 15.8).

. 15.8
Object Inspector
Environment Options

TypeLbtary ( CtatsbrJwo. ! CORBA j Direct | Internet ]


Preferences | Designer Qbiect Inspector j Palette ] Litary | Enyionment Variable! j

ijDefauK colors and setings


Colas
Categories
^] Edit Background
EoVVakje
Instance List Classname
Instance List Name
Name
Readonly
Value

Options
p Show instance ist
p Show cjassname in instance list
P Show status bar
, I* 8 "* background and
P Itfegtal herclu (when not docked)
p Show lead properties

' ^ SMnd*M!
, P Show on evert* caee

|O cB
l tnFac
Help

SpeedSettings : Custom colors and settings (), Default


colors and settings ( ), C++Builder 5 emulation ( C++Builder 5), Visual
Studio emulation ( Visual Studio). , .
,
, Default.
Colors, , , . :
Background

Categories

Edit Background

Edit Value

Instance List
Cl.assname

Instance List Name


Name

Readonly

References

SubProperties

, ,

Value

,
.
Options
:

Show instance class

Show classname in instance list

,
, .

Shaw status bar

, ,
.

Render background grid

, ().

Integral height
(when not dacked)

, .
,
(), ..
.

Show read only properties .


References
, .
Expand inline
" + " , . Show on events page
.

15.7
C++Builder 6 ,
,
.
, Tools | Environment Options
Internet (. 15.9).
. 15.9
Internet Environment Options

Preference j Detign) Object Imoectm | Palette | Uiy | Envrionment Vetublet I


|

11 j

CORBA j

tBuildei Direct

Manet

,-Internet pe Types
Exteneiqni
hlml;htm;asp

Qelete
Script Debugging
l7tlubfc>Dbu>r

HTML Extension
<T html

.htB

-Sample Ifoage File

OK

Cancel

Ueb

Internet File Types ,


. HTML
.html .htm, XML .xml, .xsl, .xsd, .wml.
Delete , New Edit .
, . 15.10.
Description . Extensions
. Edit action
, , , Tools |
External Editor External Editor
Internet (. . 15.1, ), htm Editor . Edit
Open. , ,
Internet Explorer, FrontPage,
Open Internet Explorer , Edit FrontPage.
. 15.10
,

fiesaiption: (HTML
Eigensioro; jhtml.htm;asp
Editfiction: jOpen
17 Syntax Highlight
R Show HTML. Custom View
Show XML Custom View

L.

OK

Caned

Help

. 15.10 :
Syntax Highlight

Shaw HTML Custom View


HTML.
Shaw XML Custom View


XML.

. 15.9. Enable Debugging


, . , .
HTML File Extension ,
Web HTML.
Sample Image File , , .

15.8
Tools | Debugger Options.
, . 15.11.
. 15.11
General

Genetal j Event Log | language Exceptions) OS Exceptions)

<- General-
i Map IP32 keystrokes on tun
i M * k b i ) ! i ! lead-only 1

P Reaianfl&jditorlocalmenuoniun I

] P Inspectors stay on top

" Qetxjg spawned processes


" Enable -pfocess suppat

! sable mAple ejaluatot*


tnspectot Defaults

-"

' 17 Shoginhented
, SorthjiQeme
j-Palhs
1

' b " 3 s r i M l > Search Pai

17 Integrated debuggn
ig

OK j Cancel

.
Inlegroted debugging, . , .
General, . 15.11, ,
:
Map TD32 keystrokes an
run

TD32 .

Mark buffers reod-anly on run.

Mark buffers read-only on


run

.
,
, - ( )
.
.

Inspectors sloy an top

,
.

Disable multiple evaluatars

C++
Pascal. , C++.

Allow side effects in new


watches

(,
) (. . 2.8.4).

Rearrange editor locol


menu an run


, , .
.

Debug spawned processes , . , , .


Enoble COM cross-process support
.
Event Log (. ).
InspectorDefaults
(. . 2.8.8). Show inherited
, ,
. , , . Sort by name . Show fully qualified names
.
(.
. 2.8.8).
Debug Symbols Search Path ,
, : .tds, .rsm, .dcp. , . ,
..
Event Log (. 15.12) . , ,
, View | Debug Windows | Event Log
Ctrl-All-E (. . 2.8.9).
Event Log, General, :
Clear lag on run .
Unlimited Length .
Length

.
, Unlimited.

. 15.12
Event Log

Genoa! Svent Ug j Language Enrapture | OS Exceptions)


Serl
P tearlogonwn'
P Unhnited length

> Message"' - ' i* B'eakponl messages


* ' ~ frocess messages
Iftesd messages
length. |7
t 17 Qutpul message
J? Qisfday process Wo with event
! P isflndow messages

W Integrated dobugeng

lp

Disploy process info with event , .


Messages , :
Breakpoint messages -
- .
Process messages

Thread Messages

( ) .

Output messages

, OutputDebugString
(. . 2.8.9).

Window messages

Windows.

, , Breakpoint messages Output


messages. OutputDebugString , .
Language Exceptions (. 15.13) . Stap an Delphi
Exceptions Stap On C++ Exceptions ( Delphi C++)
, . , , .
Stop on Delphi Exceptions Stop On C++ Exceptions , , ,
Exception Types to Ignore, . , , , . 15.13, . Add
. ,
EMathError,
, ..
Remove .
. 15.13
Language Exceptions

1| Even! Log. language | OS Excepfcnt |


Exception Types to (snore " ' -- ~~ i .
M Delphi EAbort Exceptions
W Microsoft DAO Exceptions
"?% Visfiroker Internal Exceptions
[* CORBA System Exceptions
i2 CORBA User Exceptions

P lO|>nOlphiEKMf*nnt

P Stop on Exceptions

OS Exceptions (. 15.14) .
.
, Add. Remove
, ,
. C+4-Builder 1 Remove
.
. 15.14
OS Exceptions

Geraal| EvwKUej Language OS Exceptions |

Exception.
Access Vteon (OxCGOOOOfi)
In Page Error |DxC0000006]
Invalid Handle IOXCOOOOOCB)
NoMem(xv(0*C0000017)
llegallnstiiion(OxCOOO)1D)
Noncontinuable Exception f0xC0OO0O25]
Invalid Dispositron !0xC0O0OO26)
Allay Bounds Exceeded (0xCO0OD08C)
Float Denamal Dpetation (0xC0OD0O8D)

Inleotateddebuggmg

Help

Hondled by , :
Debugger , User program .
On resume , C++Builder
(Run handled), (Run unhandled). Debugger , Run
Handled . . 15.14
Float Divide By Zero. ,
,
, . , , . +-(-Builder, .

15.9
15.9.1 ,

C+4-Builder , . Project
Options .
,
, , , , Project | Run F9. C+4-Builder :
1. , .
2. ., .pas, .asm, .re, .

.
();1 .
C+4-Builder . i C+4-Builder
. I , .
, , #include, . . , C+4-Builder
, .
ILINK32 .il? . , .
,
.
. . .
,
.
1. Build All. ,
, .
2.
,
. .? , Don't Generate State Files Linker. .
. , ,
. Don't Generate State Files .
3.

-
C+4-Builder.

, Release Compiler
(. 15.15). Integrated debugger Debugger Options, Tools | Debugger Options.
, , , .

4.

C++Builder 5, (. . 2.3.3).
!.;>1. ,
<> .

5.

6.
7.

, , .
, VCL, . Linker Use debug libraries.
, Compiler Code optimization .
4864 .

15.9.2
Project | Options
Project Options: Compiler, Advanced Compiler, Pascol, Linker, Tasm.
, Full debug Release Compiler
(. 15.15). Compiler, Advanced Compiler, Pascol, Linker, Tasm. , Full debug, ,
,
. , ,
, . 15.9.1. Release , .
.
, , . , , , Default (., , . 15.15).
,
.
. 15.15
Compiler

, Version Into | Packages | Tasm | CQRBA | CodeSuard |


Pascal | Lnker j Advanced Linker ) Directouei/Conotenals j
Form J Appfcatk.il Compjei j Advanced Coropter | Ct* j
i Codeopttftizetan
, i Pre-compHed headers
\ej&
IcNons
Speed

| I Use pre-owpJed headers


ache precompiled headers
filename.

|$(BCB)\lib\vc6u.csm
Stop, after
CornpiwlQ
~"
MetgeduplbatestFngs
P Staqbhames
" Ttealenumtiipesesrits

pOebugging; 17 Debug rtamaton


W line information
p mfineeipanstons

* ^KWfleWfalmesdges

'gtfuHdebuaj Batee
default

" Extended ftffoi irrfotmatk )


P

3K

Cancel

Help

15.9.3
Compiler (. 15.15). C++. Full debug Release .
. Code
Optimization Compiler
. None, , . , , -
.
Speed :
Inline intrinsic functions ( inline) Oi. , .
, .
Induction variables ( ) Ov. ,
.
Optimize common subexpressions ( )
Og.
,
. , .
Selected Optimization
, . Pentium
scheduling OS,
Pentium. Defaults .
Warnings ,
. ( )
. None . Selected Warnings
, , .
Debugging . Debug information
.obj . Line number
.obj . Disable inline
expansions inline .
.
.
Debugging . ,
,
Linker Include Debug Information.
.obj ,
, . .

Pre-compiled heoders
. , . 15.9.1,
,
. .
None
. Use pre-compiled headers
( ...\lib\vcl.csm). Coche pre-compiled
headers ( ) . ,
. File Nome
. ,
C++Builder, $().
Stop After
, . ,
.
Compiling ,
C+4-Builder. Merge duplicole strings
, , . , ,
.
Stack frames ( ) ,
. , ,
,
. .
.
Treat enum types as ints enum
.
Show general messages , ,
.
. - .
Extended error information . " + " , .
. ( Advanced Compiler), , C++
, VCL ( C++), Object Pascal,
Object Pascal, , , Delphi 6 ( Pascal),
( Tosm). . [1].

15.9.4

Linker (. 5.16) Advanced Linker. , , .. .obj, .lib, .res .
.dll. ILINK32.
, .

. 15.16
Linker

VnstonMo | Packages | Tasm | CDRSA | CodeGuatd


|
Pascal

Appfcaton ) Compiler | Advanced Cmipder { Ct.


Lmkei j Advanced Unkei | DectoN/Con*crak

f/ Use dynamci BTL

Use debug toaws


" . ' -*V " >' *4^',-,.."...'.,
17 Don't generate state fifes

Mm stacks size, j 0x00002000


Mas s>** * JOKOOI 00000

MaxgtHxs: j(j
Map*
Off
Segments

-^j
-

I Delated
!
f~ Sh^wmangied names

Min heap sae. (0x00001000


Mflx heap size |
Image fcase jtMKMOOOOO
Subsystem major {4

*-j

Subsystem mnof JO

~j

OefaJt

Linker . Linking, .
Use dynamic RTL RTL DLL. ,
RTL .
,
RTL DLL.
. , , Use dynamic RTL.
Use debug libraries vcld.lib
VCL, .
, .
Use Packages Packages. Use debug libraries .
,
VCL.
Generate import library DLL .
.lib ( DLL) .bpi
( ). . , , .lib. .bpi.
Generate Jib file .
.lib, .bpi. ,
, DLL.
Don't generate state files .il? (. . 15.9.1), , , . .il? , Final output Directories/Conditionals.
errors ,
. 255.
.

Advanced Linker . [1].

15.9.5 Directories/Conditionals
Directories/Conditionals . 15.17. , . , . . .
. 15.17
Directories/Conditionals

Forme | Application j Compe


lir j Advanced Compe
lir f O*
Vnaonlrfo ] Packages j |
Pascal | l*er | Advanced Inker

- Directories - - - - - ;

COflBA I CodeGuard
*
- -

Include path. |D \Progtam Rles\Borland\CBuildet6\Pro|eas. j - j J


tberyparil |D \Proeiam Ffes\8aland\CBuilder6\Proiects ^J A

fiebup source path j$(BCB]\saurceWci

i IntermediatesutpiA (
;

Emaloutput. P

gPMJB output |
Condtion* ondiliorlderns; jDebug.Var-1

3 J

31

Unit fees: |

Help

Directories . Include
path , ,
.
Library path , ,
.
Debug source path ,
. ,
, .
Intermediate output ,
: .obj .asm.
Final output , ., .bpl, .dll. , , ..
BPI/LIB output DLL .bpi .lib. , , .. Linker Generate import library Generate
Jib file. BPI/LIB output ,
, Library Environment Options,
Tools | Environment Options.
, , , .
. 127 ,

. ,
C++Builder $().
.
. ,
, . 15.18.
Delete .
, . , .
Windows , .
. 15.18, Replace
Add.
, .
, . 15.17,
.
. 15.18

I Ordered isl Inclitte p*hs


DAProgiamFfes\Borland\CBuildM6\Piqecls
F \Tests\Smpte
$(BCB include Wcl
FATests

Greyedteimsdenoe
tn
ivad
il path.
|$(BCBn
)\iculde

Dee
lteInvad
il atht

Conditionals Directories/Conditionals (. 15.17) , #ifdef, #if . ,


, , #ifdef, Conditionals.
, , , #if, " = " .
. . 15.17 Debug, Var 1.

#ifdef Debug
#endif

#if Var==l
#endif

Aliases Directaries/Condifionals
Object Pascal, . :
< >-=< >.

15.10
Tools | Environment
Options. . 15.19 Preferences
.
. 15.19
Preferences
Environment Options

Type Lb
i rary j CtestExptotef j CORBA ] C**Bu*fef Driect ] Internet
PrefencM j Desg
i ner} QbtecUrapecta | Palete | L-Jxwy | Enwonment Veables
; Auto*ave opto
i ns - ' Cpfrpfng and fuwwg
i
" Editofite*

, j P Showsompilerptogiess

! P Proieqtde^top

[ j Bemoncompjehon
| | * Cache headers on sMup

Oodmfl

| ' Wflfn on package tebuld


P Hide tjgstgnere on tun
f fiuckgrowdcofrpilation

Help

Preferences .
Compiling and running , . Show Compiler Progress
. on completion
. Cache headers on startup ,
(. . 15.9.1). Warn on
package rebuild ,
. Hide designers on run
: , .
Minimize on run C++Builder. Background Compilation ( Run) .
Autosave options ,
C-t-t-Builder. Editor Files (
) ,
C++Builder
. ,
- , . ,
,
.
Project desktop ( ),
C++Builder ,
C++Builder. ,
.
Shared Repository , bcb.dro.
bin.

Designer C++Builder 6 (. 15.20) ,


. C++Builder
Form designer Preferences.
. 15.20
Designer Environment Options

Type Library I ClassEiftoter ] CORBA j OtBuUwDied I Internet


Preferences Designer] Object Inspector | Palette j Ltotary ] Envrionment Variables

, Giid opto
i ns
P Dsipal y flfid
P Sn^to^id
Grd
i szie
Module creation options

Options '
Show component captions
V Show design hjnts
P Show extended control hints

1 P J^iew forms as text


f/ Auto create forms & data modules

Display grid .
Snap fo grid , '
. .
Grid size x Grid size . 2 128.
Show component captions .
Show desiner hints , .
New forms as text , ( ) .dfm. , ,
.
C++Builder.
AutoCreate forms & data modules , ( ) (Auto Create), (Available Forms). Forms .

, C++,
C++Builderf API Windows
570 , C++, ++ilder, API Windows. , .

, . [1] [3].

16.1
16.1.1
,
, , Key OnKeyDown OnKeyUp.
, . . . 5, . 5.3.2.2.

F1

112

0x70

VK

F2

113

0x71

VK_F2

F10

121

0x79

VK

32

0x20

VK SPACE

F1

FIO

Backspace

0x8

VK BACK

Tab

0x9

VK_TAB

Enter

13

OxOD

VK_RETURN

Shift

16

0x10

VK_SHIFT

Ctrl

17

0x11

VK CONTROL

Alt

18

0x12

VK_MENU

Caps Lock

20

0x14

VK_CAPITAL

Esc

27

OxlB

VK_ESCAPE

Insert

45

0x2D

VK_INSERT

PogeUp

33

0x21

VK_PRIOR

PageDown

34

0x22

VK NEXT

End

35

0x23

VK_END

Home

36

0x24

VK_H0ME

<

37

0x25

VK_LEFT

38

0x26

VK_UP

39

0x27

VK_RIGHT

40

0x28

VK_D0WN

Delete

46

02

VK_DELETE

PrinfScreen

44

02

VK_SNAPSHOT

ScrollLock

145

0x91

VK_SCROLL

Pause

0x13

VK_PAUSE

NumLock

19
144

0x90

VK_NUMLOCK

o,)

48

0x30

0"

1, !

49

0x31

'1'

3, #

51

0x33

3'

4,$
5, %

52

0x34

'4'

53

0x35

'5'

6, "

54

0x36

'6'

7, &

55

0x37

'7'

8,*

56

0x38

8"

9, (
a, A

57

0x39

9'

65

0x41

'A"

b,

66

0x42

B'

90
05
z, Z
NumLock
0
96
0x60
VK_NUMPADO
1
97
0x61
VK_NUMPAD1
2

98

0x62

VK_NUMPAD2

99

0x63

VK_NUMPAD3

100

0x64

VK_NUMPAD4

101

0x65

VK_NUMPAD5

102

0x66

VK_NUMPAD6

103

0x67

VK_NUMPAD7

8
9

104
105

0x68

VK_NUMPAD8

0x69

VK NUMPAD9

Z'

'- -

106

VK_MULTIPLY

107

VK_ADD

109

0x6D

VK SUBTRACT

110

VK_DECIMAL

111

0x6F

VK_DIVIDE

16.1.2 ,

16.1.2.1
, (printf,
cprintf, sprintf .), , .

.
% :
%[flags] [width] [ . p r e c i s i o n ] [F|K|h|11L]type

.
type , . :
[flags]

, , , , (, )

[width]

[.precision]

[F|N|h|l|L]

, :
N
F

1
L

(near)
(far)
short int
long
long double

type.

i . H I

.in

.HI

signed integer
signed integer
HOci.Mepiriiioe unsigned integer

unsigned integer
unsigned int ( , , ,
d, e, f)

, , , , , D, E, F

X
f
e
E

e
G

: [-]dddd.dddd
() : [-]d.dddd
e[+/-]ddd
, ,
f ;
|

, g,


,
%

n
int , ,

P

;

XXXX:YYYY, YYYY ( )

flags .

, . , ,
.

(+) ()

, (+). () . +,
.

, , X 0, , .
, , f, g, G . , g, G
.

width . , (*). ,
.
width .
, .
:
, , .
, ( , ) .
, , .
, .

On

.
precision
. (.)
width. , width, ,
(*). ,
.
precision :
d, i, , , , X
, , f

1
6

g. G
s

precision:
.0

d, i, , u, x .
, , f

. , , ( )
.
precision .

d, i, , , , , .
, ,
, .
X
, .
, , f

, .
.

. G

, .

:
%f

%g

%#G

110000,000000

1,100000+05

110000

110000,

-1,1+08

-1000+08

-110000000,000000

1,100000+08

0,000110

1,100000-04

0,00011

0,000110000

0,000000

1,100000-07

1,1-07

10000-07

12,000000

1,200000+01

12

12,0000

0,000000

0,000000+00

0,00000

12
-12

%6i

%-6i

12
-12

%+6i

+ 12
-12

%06i

000012
-00012

%f

123456789,000000

0,123457

%.5f

123456789,00000

0,12346

% .4f

123456789,0000

0,1235

%.3f

123456789,000

0,123

%e

l,234568e+08

l,234568e-01

%.5e

l,23457e+08

l,23457e-01

% .4e

l,2346e+08

l,2346e-01

%.3e

l,235e+08

l,235e-01

%g

l,23457e+08

0,123457

%.5g

l,2346e+08

0,12346

% .4g

l,235e+08

0,1235

% .3g

l,23e+08

%.2g

l,2e+08

0,123
0,12


. 16.5.4, .
16.1.2.2
,
(scanf, fscanf, sscanf .). :
( , \t, \
( %)

,
,
().
,
,
.
, .
% :
%,[*] [width] [FIN] [h|l|L] type

.
type , , .
:
[*]

. ,
.

[width]

.
, ,
.

[F|N]

, :

[h|l|L]

(near)
N
(far)
F
, :
h

short int

long int, type , double,


type

long double

type.

int

*)

II


long (long *arg)

g. G

float (float *arg)


float (float *arg)
float (float *arg)
int (int *arg)
long (long *arg)

, int (int *arg)


, long (long *arg)


unsigned int (unsigned


int *arg)

unsigned long (unsigned


long *arg)
int (int *arg)

int (int *arg)

(char
arg[])
char (char *arg) ,
(,
% 5),
W (char arg[W])

%
%

n
int (int *arg)


, ,

:
YYYY:ZZZZ ZZZZ

(far* near*)

.
16.5.4, .
16.1.2.3 Format
Format,
FormatBuf, FmtStr, StrFmt, StrLFmt .
. , .
% :
"%"

[index

":"]

["-"]

[width]

["."

prec]

type

type , , . :
[index ":"]


index. 0. , %0: .

-"]

. [""] .

[width]


. , ( , [""]) .

["." ]

, ( ). (.), width.

index, width
(*). ,
.
type.

.
["." ],

. ,

.

d.ddd...E+ddd.

.
["." ],
,
( 15 ).
.


ddd.ddd.... ["."
],
( 2 ).


, , . ["."
], ( 15).
, , . ,

0.00001.
.

, , : d,ddd,ddd.ddd....

, . CurrencyString, CurrencyFormat, NegCurrFormat, ThousandSeparator, DecimalSeparator, CurrencyDecimals, Currency Format International Windows. 4 ["."
], CurrencyDecimals.


XXXX:YYYY, YYYY
, .

,
PChar

.
["." ], .
, .

.
["." ],
. ,
.

, .
DecimalSeparator ThousandSeparator.

%f

%g

110000.

110000,00

10000000000000+005

110000

-110000000,00

-10000000000000+008

-110000000

1.1+08

%f

%e

%g

0.00011

0,00

1,100O00000O0000E-0O4

0,00011

l.le-07

0,00

100000-07

1-7

12.

12,00

1,20000000000000E+001

12

0,00

0,00O00OOO000O00E+OO0

0.

:
/ 1.1E-4

12.

0.00

% .2f

0,00

12,00

0,000

% .3f

0,000

12,000

0,0000

% .4f

0,0001

12,0000

0.0E+000

%.2e

1.1E-007

1.2E+001

O.OE+000

% .

10-007

1.20E+001

0.00E+000

% .4e

100-007

1.200E+001

0.000E+000

% .2g

1-7

12

% .3g

1-7

12

% .4g

1-7

12

16.1.2.4 TFloatFormat TFIoatValue



TFloatFormat TFIoatValue , FloatToText, FloatToStrF, FloatToDecimal,
TextToFloat.

include <SysUtils.hpp>
enum TFloatFormat ( ffGeneral, ffExponent,.ffFixed, ffNumber,
ffCurrency );
enum TFIoatValue ( fvExtended, fvCurrency );

TFIoatValue . fvExtended , fvCurrency


Currency.
TFloatFormat FloatToText, FloatToStrF, FloatToDecimal, TextToFloat. :
ffGeneral

. ,
. ,
.
, Precision 0.00001. ,
Dif{itH 0 4.

ffExponent

.
d.ddd...E+dddd. , , Precision.
" + " "-" . Digits 0 4.

ffFixed

.
ddd.ddd.... . Digits, 0
18. Precision, .

ffNumher

.
d,ddd,ddd.ddd.... ffFixed .

ff Currency

. , . Currency String, Currency Format, NegCurrFormat,


ThousandSeparator, DecimalSeparator, Currency Format Internotional
Windows. Digits, 0 18.

,
DecimalSeparator ThousandSeparator.
16.1.2.5 FormatFloat
, , FormatFloat, FloatToTextFmt, FormatFloat AnsiString
.
:
0

. ,
"0", . "0".

. ,
" # " , . .
. "."
. "." .
, , DecimalSeparator, Number Format International
Windows.

.
",",
. "," , . ,
, usandSeparator, Number Format
International Windows.
+, -,
+,

. + , , + , .
"0" ( ),
.
"+" "+", , " + " "".
"" "", .

''/ ""

, , , .
,
, .

"" "0" ,
.
,
"" " # " .
,
.
,
"0" " # " ,
.
, . ,
. ,
, . , , , .
(..
, .
, 15 . ffGeneral TFIoatFormat (. . 16,1.2.4). ,
18
.

1234

-1234

1234

-1234

0.00

1234,00

-1234,00

0,50

0,00

1234

-1234

,5

#,##0.00

1 234,00

-1 234,00

0,50

#,##0.00;(#,##0.00)

1 234,00

(1 234,00)

0,50

0,00
0,00

0.5

#,##0.00;;

1 234,00

-1 234,00

0,50

.00+0

1,234+03

-1.234+03

5,000-01

0.000+00

#.###-0

1.234

-1.234

5-1

16.1.3 ,
,
#include <errno.h>

16.1.3.1 _doserrno, errno _sys_nerr ,

_doserrno tot
. _doserrno
, ,
, UNIX.
, , _sys_errlist, . _sys_nerr,
( stdio.h)
stder.
_sys_errlist[errno], _sys_errlist[_sys_nerr].
0.
, .. . ,
0.
16.1.3.2
, ,
_sys_errlist.

_sys_errlist

E2BIG

20

Arg list too long

EACCES
EAGAIN
EBADF

Permission denied
42

Resource temporarily unavailable


Bad file number

_sys_crrlist

EUUSY

44

Resource busy

ECHILD

24

No child process

ECONTR

Memory blocks destroyed

ECURDIR

16

Attempt to remove CurDir

EDEADLOCK

36

Locking violation

EDOM

33

Math argument

EEXIST

35

File already exists

EFAULT

14

Unknown error

EFBIG

27

UNIX MSDOS

EINTR

39

Interrupted function call

EINVACC

12

Invalid access code

EINVAL

19

Invalid argument

EINVDAT

13

Invalid data

EINVDRV

15

Invalid drive specified

EINVENV

10

Invalid environment

EINVFMT

11

Invalid format

EINVFNC

Invalid function number

EINVMEM

Invalid memory block address

40

Input/output error

EISDIR

46

UNIX MSDOS

EMFILE

Too many open files

EMLINK

31

UNIX MSDOS

ENFILE

23

Too many open files

ENMFILE

18

No more files

ENODEV

15

No such device

ENOENT

No such file or directory

ENOEXEC

21

Exec format error

ENOFILE

File not found

ENOMEM

Not enough core

ENOPATH

Path not found

ENOSPC

28

No space left on device

ENOTBLK

43

UNIX MSDOS

ENOTDIR

45

UNIX MSDOS

ENOTSAM

17

Not same device

ENOTTY

25

UNIX MSDOS

ENX1O

41

No such device or address

_sys_errlist

EPERM

37

Operation not permitted

EPIPE

32

Broken pipe

ERANGE

34

Result too large

EROFS

30

Read-only file system

ESPIPE

29

Illegal seek

ESRCH

38

UNIX MSDOS

ETXTBSY

26

UNIX MSDOS

EUCLEAN

47

UNIX MSDOS

EXDEV

22

Cross-device link

EZERO

Error 0

. ,
strcpy(_sys errlist[ENOENT]/" ");

No such file or directory.


-, , I/O checking
Pascal . C++Builder EInOutError.

2
3

100

(EOF)

101

106

16.1.3.3 EDOM, ERANGE


EDOM ERANGE
. , , , :
i f ( e i r t i o == EDOM)

16.1.3.4 matherr matherrl

include <mach.h>
int
matherr(struct ^exception *e) ;
nH
mjrherrl(struct
exception! * e ) ;

_matherr _matherrl ( long double) , ( ..). , , , ,


0. signal.
_matherr _matherrl
, .
, .
. _matherr _matherrl , 0.
.
:
struct _exception |
int
type;
char 'name;
double argl, arg2,

retval;

};

struct _exceptionl (
int
type;
char "name;
long double argl, arg2, retval;
};

type . name
, , . argl
arg2 , (
, argl). retval . .
, type, :
DOMAIN
SING
OVERFLOW

; ,
log(-l)
; ,
pow(0, -2)
,
DBL_MAX ( LDBL_MAX); , ()

UNDERFLOW

,
DBL_MIN ( LDBL_MIN); , (-)

TLOSS

; , sin(10e70)

DBL_MAX, DBL_MIN,
LDBL_MAX LDBL_MIN float.h.

,
DOMAIN sqrt ( ),
, :

inL _matherr
if

(struct _exception *a)

(a->type == DOMAIN)
if (!strcmp(a->name,"sqrt")) (
a->retval - sqrt (-(a->argl));
return 1;

return

0;

16.1.3.5 assert

include <assert.h>
void assert(int test);

assert . test ( ), assert


stderr :
Assertion failed: t e s t , f i l e < >, line < >
assert abort.

((include <assert.h>

define

NDEBUG

assert . - , ,
NDEBUG.

16.2
16.2.1 ,

_1_1

1/n

0.318309886183790671538

M_1_SQRTPI

1 /

0.564189583547756286948

M_2_PI

2/n

0.636619772367581343076

M_2_SQRTPI

2 / 7i

1.12837916709551257390

M_E

2.71828182845904523536

M_LN10

1(10)
10

2.30258509299404568402

M_LN2

1(2) 2 0.693147180559945309417

M LOG10E

log!o(e)

M_LOG2E

Iog2(e) 2 1.44269504088896340736

M_PI

3.14159265358979323846

MJPI_2

/2

1.57079632679489661923

0.434294481903251827651

M_PI_4

/4

0.785398163397448309616

M_SQRT_2

2, 2

0.707106781186547524401

M_SQRT2

1.41421356237309504880

16.2.2

Jrotl

unsigned long _Irotl(


val
unsigned long val, count
int count)

stdlib.h

_Irotr

unsigned long _Irotr(


val
unsigned long val, count
int count)

stdlib.h

_rotl

value stdlib.h
unsigned short _rotl(
unsigned short value, count
int count)

_rotr

unsigned short _rotr(


value stdlib.h
unsigned short value, count
int count)

abs

int abs(int x)

stdlib.h

cabs

math.h

cabsl

double cabs(struct complex z)


struct complex {
double x, y;
};
long double cabsl(
struct _complexlz)
struct _complex {
long double x, y;
};

math.h

ceil

double ceil(double x)

: , X

math.h

Ceil

int Ceil(Extended X);

: , X

Math.hpp

ceill

long double ceill(long double x) : , X

math.h

div

div_t div(int numer, int denom)


typedef struct {
numer / denom
int quot;
//
int rem;
//
} div_t;

math.h

exp

double exp(double x)

math.h

cxpl

loiitf doublu cxpl(long double x)

math.h

fabs

double fabs(double x)

math.h

fabsl

long double fabsl(long double x)

math.h

floor

double floor(double x)

: ,

math.h

Floor

int Floor(Extended X);

: - Math.hpp
, X

floorl

long double floorl(long double x) : - math.h


,

fmod

double fmod(double x, double y)

math.h

fmodl

long double fmodl(


long double x, long double y)

math.h

frexp

double frexp(double x,
int ^exponent)


()
exponent

math.h

Frexp

X
void Frexp(Extended X,
Extended &Mantissa, Mantissa Exponent
int &Exponent)

frexpl

long double frexpl(


long double x,
int *exponent)


()
exponent

math.h

IntPower

Extended IntPower(
Extended Base,
int Exponent)

Base
Exponent

Math.hpp

labs

long labs(long int x)

stdlib.h

Math.hpp

Idexp

double ldexp(double x, int exp) 2 "

Ldexp

Extended Ldexp(Extended X,
int P)

ldexpl

long double IdexpU


2*
long double x,
int exp)

math.h

Idiv

typedef struct {
long int quot;
//
long int rem;
//
) !div_t;
ldiv_t Idiv(long int numer,
long int denom)

:
numer / denom;
quot
rem

math.h,
stdlib.h

LnXPl

Extended LnXPl(Extended X)


( + 1)

Math.hpp

log

double log(double x)

math.h

loglO

double IoglO(double x)

math.h

LoglO

Extended LoglO(Extended X)

Math.hpp

loglOI

long double Iogl01(



long double x)

- 2

math.h
Math.hpp

math.h


Extended Log2(Extended X)
Log2

logl
LogN

2 Math.hpp
math.h
long double Iogl(long double x)
Extended LogN(
X Math.hpp
Extended Base, Base
Extended X)

max

max(a, b)

- stdlib.h

b

min

min(a, b)

stdlib.h

b

modf

double modf(double x,
double *ipart)


math.h
ipart

modfl

long double modfl(


long double x,
long double *ipart)
double poly(double x,
int degree,
double coeffsfl)


math.h
ipart

poly
Poly
polyl

de- math.h
gree
coeffs
Math.hpp
X
Extended PoIy(Extended X,
const double * Coefficients, Coefficients_Swe const int Coefficients_Size) Coefficients
long double polyl(
de- Math.h
long double x,
gree
int degree,
coeffs .
long double coeffs[])
double pow(double x, double y)
Extended Power(
Base
Exponent
Extended Base,
Extended Exponent)

math.h

powl

long double powl(


long double x,
long double y)

math.h

sqrt

double sqrt(double x)

pow

Power

sqrtl


long double sqrtl(long double x)

Math.hpp

math.h
math.h

,
math.h Math.hpp C++Builder .

include <math.h>
#include <Math.hpp>
exp, expl. ldexp, ldexpl ERANGE.

log, ioglO, loglOl, logl ERANGE, EDOM.


pow powl EDOM, < 0 , = 0 <= 0.
ERANGE.
sqrt sqrtl EDOM, < 0.
Math.hpp
math.h, Extended.

16.2.3

acos
acosl
ArcCos
ArcCosh
Arc Sin
ArcSinh
ArcTan2
ArcTanh
asin
asinl
atan
atan2
atan21
atanl
cos

cosh
Cosh
coshl
cosl

double acos(doublo x)
long double acosl(
long donble x)
Extended ArcCos(Extended X)
Extended ArcCosh(
Extended X)
Extended ArcSin(Extended X)
Extended ArcSinh(
Extended X)
Extended ArcTan2(
Extended Y,
Extended X)
Extended ArcTanh(
Extended X)

math.h


(Y / X)

Math.hpp

Math.hpp

double asin(double x)

math.h

long double asinl(


long double x)
double atan(double x)
double atan2(double y,
double x
long double atan21(
long double y,
long double x)
long double atanl(
long double x)
double cos(double x)
double cosh(double x)
Extended Cosh(Extended X)
long double coshl(
long double x)
long double cosl(
long double x)

math.h

math.h
math.h

math.h

math.h

math.h
math.h
Math.hpp
math.h

math.h

math.h

Math.hpp
Math.hpp
Math.h
Math.hpp

Math.hpp
Extended Cotan(Extended X)
Math.hpp
CycIeToRad Extended CycIeToRad(
Extended Cycles) Cycles: 2 Cycles
Cotan

DegToRad

Extended DegToRad(
Extended Degrees)
Degrees: Degrees 1 180

hypot

double hypot(double x,
double y)

Hypot
hypotl

Math.hpp

math.h

Extended Hypot(Extended X, - Math.hpp
Extended Y) X Y
long double hypotl(
math.h
long double x,
long double y)

RadToCycle Extended RadToCycle(


- Math.hpp
Extended Radians)
Radians:
Radians / (2)
RadToDeg Extended RadToDcg(
- Math.hpp
Extended Radians) Radians:
Radians 180 / .
SinCos

double sin(double x)
void SinCos(Extended Theta, Sin Extended &Sin, Cos Theta
Extended &Cos)

math.h
Math.hpp

Sinh

Extended Sinh(Extended X)

Math.hpp

sinh

double sinh(double x)

math.h

sinhl


long double sinhl(
long double x)

math.h

sinl

math.h

Tan

long double sinl(

long double x)

Extended Tan(Extended X)

tan
Tanh

double tan(double x)
Extended Tanh(Extcnded X)

tanh

double tanh(double x)

tanhl

long double tanhl(


math.h
long double x)

tanl

long double tanl(

long double x)

sin

Math.hpp

math.h

Math.hpp
math.h

math.h


,
math.h Math.hpp C++Builder .

((include <math.h>
include <Math.hpp>

.
, , DegToRad CycleToRad. ,
double Rad = DegToRad(90);

Rad 90 . Rad
double Rad = CycleToRad(0.25) ;
( ). 90 :
double S - sin(DegToRad(90));

:
acos acosl [0, ], asm, asinl, atan, atan2, atan21, atanl [-/2, /2]. .
RadToDeg RadToCycle. ,
double A = atan (T);
double Al = RadToDeg(atan(T)) ;
double A2 - RadToCycle ( a t a n ( T ) ) ;

(), (1) (2).


acos, acosl, asin, asinl,
[-1, +1], (EDOM).
cosh, coshl, sinh, sinhl,
,
(ERANGE).

16.2.4

_lrand

long _lrand(void)
, 0 2 3 1 - 1

stdlib.h

rand

int rand(void)
, 0 RAND_MAX

stdlib.h

RandG

Extended RandG(Extended Mean, Extended StdDev)


, ; Mean ,
StdDev

Math.hpp

random

int random(int num)


, 0 num - 1

stdlib.h


randomize

/
void randomize(void)
( RandG)

Randomize void Randomize(void)


RandG
srand

Math.hpp

void srand(unsigned seed)


j stdlib.h
( RandG) seed

rand , 0 RAND_MAX
(0x7FFFU - 32767). 2 3 2 = 4 294 967 296.
. -
,
( )
randomize srand.
, 0
N, % . ,
randO % 101

0 100,
( r a n d ! ) % 201) - 100

-100 100.
rand . ,
10. * rand() / RAND_MAX

,
0 10.
_lrand rand, 2 6 4 0 2 3 1 - 1.
random , num.
. ,
, , 0 100,

random(101);

, , %.
RandG , ( ) Mean
StdDev.
, Math.hpp C++Builder
.
include <Math.hpp>


, . ,
. , ..
. . RandG.

randomize. - (,
OnCreate )
randomize ( ) ;


.
srand randomize ,
, seed.
RandG Randomize, randomize.
, RandSeed,
System.hpp.

16.2.5
,
Data, Data_Size.

MaxIntValue

int MaxIntValue(const int * Data, const int Data_Size) Math.hpp



Math.hpp
double MaxValue(const double * Data,
const int Data_Size)

MaxValue

Mean

Extended Mean(const double * Data,


const int Data_Size)
( )

Math.hpp

MeanAndStdDev

void MeanAndStdDev(const double * Data,


const int Data_Size,
Extended &Mean,
Extended &StdDev)
Mean StdDev

Math.hpp

Minlnt Value

int MinIntValue(const int * Data, const int Data_Size)


Math.hpp

MinValue

double MinValue(const double * Data,


const int Data_Size)

Math.hpp

MomentSkewKurtosis

void MomentSkewKurtosis(const double * Data,


Math.hpp
const int Data Size, Extended &M1,
Extended &M2, Extended &M3,
Extended &M4, Extended &Skew,
Extended &Kurtosis)
Ml, M2, , 4, Skew, Kurtosis

Norm

Extended Norm(const double * Data,


const int Data_Size)
:

Math.hpp


PopnStdDev

PopnVariance

StdDev

Sum

Sumlnt

Math.hpp

Extended PopnStdDev(const double * Data,


const int Data_Size)

Math.hpp
Extended PopnVariance(const double * Data,
const int Data_Size)
(. Variance)
Extended StdDev(const double * Data,
Math.hpp
const int Data_Size)

Math.hpp
Extended Sum(const doable * Data,
const int Data_Size)

int Sumlnt(const int * Data, const int Data_Size)

Math.hpp

SumOfSquares Extended SumOfSquares(const double * Data,


Math.hpp
const int Data_Size)

SumsAndSqu- void SumsAndSquares(const double * Data,
Math.hpp
ares
const int Data Size, Extended &Sum,
Extended &SumOfSquares)
Sum SumOfSquares
TotalVariance

Extended TotalVariance(const double * Data,


const int Data_Size)

Math.hpp

Variance

Extended Variance(const double * Data,


Math.hpp
const int Data_Size)
(. PopnVariance)

Math.hpp C++Builder .
include <Math.hpp>

MeanAndStdDev (
) . , Mean
StdDev. (> 107) .
, MeanAndStdDev StdDev .
, PopnStdDev, ( - 1), . ,
Variance PopnVariance.

,
, :
double 001] ;
long double M, StdD,StdD2,Ml,M2,M3,M4,Skew,Kurtosis;
//
for(int i - 0; i < 1001;
RandG(20, 4) ;
double = Variance(A,1000);
MeanAndStdDev(A,1000, M, StdD);
StdD2 = PopnStdDev(A,1000);
MomentSkewKurtosis(A,1000,M1,M2,M3,M4,Skew,Kurtosis) ;

16.3
16.3.1
16.3.1.1 char *
/
_atoi64
int64 _atoi64(const char *s)
s

_atold

long double _atold(const char *s)


s

math.h

_i64toa

char *_i64toa( int64 value, char *strP, int radix)


value ; radix ( 2 36)

stdlib.h

_itow

wchar_t *_itow(int value, wchar_t *string, int radix)


value string radix
char *_ltoa(long value, char *string, int radix)
value ; radix ( 2 36)
long double _strtold(const char *s, char **endptr)
s
char *_ui64toa(unsigned ini64 value,
char *strP, int radix)
value ; radix ( 2 36)
wchar_t *_ultow(unsigned long value,
wchar_t *string, int radix)
value string radix
long double _wcstold(const wchar_t *s, wchar_t **endptr)
s

stdlib.h

Jtoa
_strtold
_ui64toa

_ultow

_wcstold

stdlib.h

stdlib.h
stdlib.h
stdlib.h

stdlib.h

stdlib.h

_wtof

double _wtof(const wchar_t *s)


s

math.h

_wtoi

int _wtoi(const wchar_t *s)


s

stdlib.h

_wtoi64

int64 _wtoi64(const wchar_t *s)


s

stdlib.h

_wtol

long _wtol(const wchar_t *s)


s

stdlib.h

_wtold

long double _wtold(const wchar_t *s)


s

math.h

atof

double atof(const char *s)


s

stdlib.h,
math.h

atoi

int atoi(const char *s)


s

stdlib.h

atol

long atol(const char *s)


s

stdlib.h

ecvt

char *ecvt(double value, int ndig, int *dec, int *sign)


value
ndig; dec , sign

stdlib.h

fcvt

char *fcvt(double value, int ndig, int *dec, int *sign)


value
ndig; dec , sign

stdlib.h

gcvt

char *gcvt(double value, int ndec, char *buf)


value buf ndec

stdlib.h

itoa

char *itoa(int value, char *string, int radix)


value string radix

stdlib.h

strtod

double strtod(const char *s, char **endptr)


s

stdlib.h

strtol

long strtol(const char *s, char **endptr, int radix)


s

stdlib.h

strtoul

unsigned long strtoul(const char *s, char **endptr, int radix)


s unsigned long radix

stdlib.h

ultoa

char *ultoa(unsigned long value, char * string, int radix)


value string radix

stdlib.h

wcstod

double wcstod(const wchar_t *s, wchar_t **endptr


s

stdlib.h

wcstol

long wcstol(const wchar_t *s, wchar_t **endptr, int radix) stdlib.h


s

wcstoul

unsigned long wcstoul(const wchar_t *s,


stdlib.h
wchar_t **endptr, int radix)
unsigned long radix


, . ,
, .
, 0.
atof strtod +INF -INF,
, +NAN -NAN,
.
strtod, strtol, _strtold, strtoul, wcstod, wcstol, wcstoul
endptr NULL. , ;
double = strtod(Editl->Text.c_str(),NULL) ;

, Editl, . endptr:
char *endptr;
double = strtod(Editl->Text. str(),Sendptr);

*endptr , .
.
,
HUGE_VAL ( double)
LHUGEJVAL ( long double).

AnsiString (. . 16.4.2.3 . 17).
char * c_str(), .
16.3.1.2 ,
SysUtils.hpp

CurrToStr

System::AnsiString CurrToStr(System::Currency Value)


Value Currency

CurrToStrF

System-AnsiString CurrToStrF(System::Currency Value,


TFloatFormat Format, int Digits)
Curreucy TFloatFormat (. . 16.1.2.4)

FIoatToDecimal

void FloatToDecimal(TFloatRec &Result, const void *Value,


TFIoatValue ValueType, int Precision, int Decimals)
Value ValueType (. TFIoatValue . 16.1.2.4)
TFloatRec

FloatToStr

System-AnsiString FIoatToStr(Extended Value)


Value

FloatToStrF

System::AnsiString FIoatToStrF(Extended Value,


TFloatFormat Format, int Precision, int Digits)
Value TFloatFormat
(. . 16.1.2.4)

FloatToText

int FIoatToText(char * Buffer, const void *VaIue,


TFloatValue ValueType, TFloatFormat Format,
int Precision, int Digits)
Value ValueType Buffer TFloatFormat (. . 16.1.2.4)
int FloatToTextFmt(char * Buffer, const void *Value,
TFloatValue ValueType, char * Format)
Value ValueType (. TFloatValue . 16.1.2.4)
Buffer FormatFloat (. .

FloatToTextFmt

FmtStr

void FmtStr(System::AnsiString &ResuIt,


const System::AnsiString Format,
const System-TVarRec * Args, const int Args_Size)
Args Args_Size - 1
Result Format (. . 16.1.2.3)

Format

System::AnsiString Format(const Systern::AnsiString Format,


const System::TVarRec* Args, const int Args_Size)
Args Args_Size - 1
Format (. . 16.1.2.3)
Cardinal FormatBuf(void *Buffer, Cardinal BufLen,
const void *Format, Cardinal FmtLen,
const System::TVarRec * Args, const int Args_Size)
Args Args_Size - 1
Buffer BufLen Format (. .
16.1.2.3) FmtLen
System::AnsiString FormatCurr(const System::AnsiString Format,
System::Currency Value)
Currency
FormatFloat (. . 16.1.2.5)

FormatBuf

Formate urr

FormatFloat

GetFormatSettings

System::AnsiString FormatFIoat(const System::AnsiString


Format, Extended Value)
Value
FormatFloat (. . 16.1.2.5)
void GetFormatSettings(void)
,

IntToHex

System::AnsiString IntToHex(int Value, int Digits)


Value Digits

IntToStr

System::AnsiString IntToStr(int Value)


Value
char * StrFmt(char * Buffer, char * Format,
const Systcm::TVarRec * Args, const int Args_Size)
Args Args_Size -1

StrFmt

it lluifcr no F o r m a t (. . 10.1.2.3)

StrLFmt

char * StrLFmt(char * Buffer, Cardinal MaxLen, char * Format,


const System::TVarRec* Args, const int Args_Size)
Args Args_Size -1
Buffer MaxLen Format (. .
16.1.2.3)

StrToCurr

System::Currency StrToCurr(const System::AnsiString S)


S Currency

StrToFloat

Extended StrToFloat(const System::AnsiString S)


S

StrToInt

int StrToInt(const System::AnsiString S)


S

StrToIntDef

int StrToIntDef(const System::AnsiString S, int Default)


S , Default

TextToFloat

bool TextToFloat(char * Buffer, void *Value,


TFloatValue ValueType)
Buffer Value ValueType (. TFloatValue
. 16.1.2.4)

, SysUtils.hpp, ValueType, fvExtended


Extended, fvCurrency Currency. TFIoatFormat,
. 16.1.2.4, FormatFloat, . 16.1.2.5,
, Format, . 16.1.2.3.
Args Args_Size - 1 . Args_Size Args TVarRec. , . 16.1.2.3.
Format:
A n s i S t r i n g s ,TVarRec Args[3]

(11,

%g

%f

F o r m a t ("%d

- l . l e + 0 8 ,
%0:10d

%lOg

0.00011);
%10.5f",

Arcjs,

2);

s, , Args,
. , 3, Format
2 , 1
. , , ,
, 1.
s
%d, %g, %f, ( ). %0:10d 0,
.
10, 5.


EXISTINGARRAY (. . 16.7.4):
s - Format ("%d %g %f %0:10d %10g %10 . 5f" ,EXISTINGARRA* (Args) ) ;

,
Format OPEN ARRAY
(. . 16.7.4):
s = F o r m a t ( " % d %g %f fc0:10d % 1 0 g % 1 0 . 5 f " ,
OPENARRAY(TVarRec,( 1 1 , - l . l e + 0 8 ,

0.00011)));

EConvertError. StrToIntDef,
.
FloatToDecimal Extended Currency ,
. Extended Precision 1 18.
Currency Precision , 19
.
Decimals . . , Precision Decimals . , Decimals
9999.
TFloatRec,
:
Exponent

. 1, Exponent , . NAN ( ), Exponent -32768. INF INF ( ), Exponent = 32767.

Negative

true,
false.

Digits

, 18 ( Extended) 19 ( Currency) .
. . ,
NAN INF, Digits .'

FloatToDecimal:
struct TFloatRec Result;
Extended Value = . . . ;
FloatToDecimal(Result, SValue,fvExtended,18, 999);
Value :
Value

Exponent

Negative

Digits

123.4567890123456789

false

123456789012345681

1234567890123156789

19

false

123456789012345679

true

123456789012345671

-0.001 2345671234 56789

16.3.2

asctime

/
char *asctime(const struct tm *tblock)
tm

time.h

ctime

char *ctime(const time_t *time)


time.h
time, time,

Date

System::TDateTime Date(void)

DateTimeToFileDate

SysUtils.hpp
int DateTimeToFileDate(
System::TDateTime DateTime)
DateTime DOS

SysUtils.hpp

DateTimeToStr System-AnsiString DateTimeToStr(


SysUtils.hpp
System::TDateTime DateTime)
DateTime
DateTimeToString

void DateTimeToString(
SysUtils.hpp
System::AnsiString &Result,
const System::AnsiString Format,
System::TDateTime DateTime)
DateTime Result Format

DateTimeToSystemTime

void DateTimeToSystemTime(
SysUtils.hpp
System::TDateTime DateTime,
_SYSTEMTIME &SystemTime)
DateTime TSystemTime,
API Windows
TTimeStamp DateTimeToTimeStamp(
SysUtils.hpp
System::TDateTime DateTime)
DateTime TTimeStamp

DateTimeToTimeStamp
DateToStr

System::AnsiString DateToStr(
SysUtils.hpp
System::TDateTime Date)
Date

DayOfWeek

int DayOfWeek(System::TDateTime Date)


Date ( 1 7,
1 )

SysUtils.hpp

DecodeTime

void DecodeTime(System::TDateTime Time,


Word &Hour, Word &Min,
Word &Sec, Word &MSec)
Time Hour, Min, Sec, MSec

SysUtils.hpp

EncodeDate

SysUtils.hpp
TDateTime EncodeDate(Word Year,
Word Month, Word Day)
Year, Month Day
n TDateTime


EncodeTime

FormatDateTime

getdatc

/
TDateTime EncodeTime(Word Hour, Word Min,
Word Sec, Word MSec)
Hour, Min,
Sec MSec TDateTime

SysUtils hpp

System::AnsiString FormatDateTime(
SysUtils .hpp
const System::AnsiString Format,
System::TDateTime DateTime)
DateTime Format
void getdate(struet date *datep)
dos.h
datep

gettime

void gettime(struct time *timep)


timcp

dos.h

gmtime

struct tm *gmtime(const time_t *timer)


timer,
time, tm

time.h

IncMonth

SysUtils.hpp
System::TDateTime IncMonth(
const System:: TDateTime Date,
int NumberOfMonths)
Date, NumberOfMonths

IsLeapYear

bool IsLeapYear(Word Year)


true, Year

Iocaltime

struct tm *localtime(const time_t *timcr)


time.h
timer, time, tnl

mktime

time_t mktime(struct tm *t)


time.h
tm
time t

MSccsToTimeStamp

TTinieStamp MSecsToTimeStamp(
SysUtils hpp
System::Comp MSecs)
MSecs TTinieStamp
SysUtils hpp
System::TDateTime Now(void)

Now

SysUtils.hpp

setdate

void setdate(struct date *datep)


datep ( )

dos.h

settime

void settime(struct time *timep)


timep

dos.h

stime

int stime(time_t *tp)


tp

time.h

SysUtils.hpp
System::TDateTime StrToDate(
const System::AnsiString S)
S TDateTime
SysUtils.hpp
StrToDateTime System::TDateTime StrToDateTime(
const System::AnsiString S)
S TDateTime
SysUtils.hpp
System::TDateTime StrToTime(
StrToTime
const System::AnsiString S)
S TDateTime
SysUtils.hpp
SystemTimeTo- System::TDateTime SystemTimeToDateTime(
DateTime
const _SYSTBMTIMB &SystemTime)
TSystemTime, API Windows, TDateTime
StrToDate

time

time.h
time_t time(time_t *timer)
timer
( timer NULL)

Time

System::TDateTime Time(void)

TimeStampToDateTime

SysUtils.hpp
System::TDateTime TimeStampToDateTime(
const TTimeStamp &TimeStamp)
TTimeStamp TDateTime
SysUtils.hpp
System::Comp TimeStampToMSecs(
const TTimeStamp &TimeStamp)
64-
SysUtils.hpp
System::AnsiString TimeToStr(
System::TDateTime Time)

TimeStampToMSecs

TimeToStr

SysUtils.hpp

TDateTime, , , 0 12/30/1899, 24- , 12 . .. .


:
TDateTime

2.75

12/30/1899, 00
1/1/1900, 18

-1.25

12/29/1899, 6

35065

1/1/1996, 00

TTimeStamp. :
struct TTimeStamp
int Time;
int Date;

) ;
Date (.. 1 1 1). , TDateTime TTimeStamp . Time , 0 .
TDateTime .
, TDateTime.
TTimeStamp TDateTime
TimeStampToDateTime, DateTimeToTimeStamp. TimeStampToMSees 64-
, Date
Time.
, DOS.
, File Age, FileGetDate, FileSetDate, Time TSearchRec,. FindFirst FindNext. TDateTime DateTimeToFileDate.
, TSystemTime,
_SYSTEMTIME. API Windows.
TDateTime DateTimeToSystemTime, SystemTimeToDateTime.
DateTimeToString FormatDateTime , :

, ShortDateFormat, , LongTimeFormat. DateTime


0, .

(1-31).

dd

(01-31).

ddd

(-) ShortDayNames.

dddd

( )
LongDayNames.

ddddd

, ShortDateFormat.

dddddd

, LongDateFormat.

(1-12). m
h hh, .

mm

(01-12). mm
h hh, .

mmm

(-) ShortMonthNamcs.

(-) LongMonthNames.

(00-99).

(0000-9999).

(0-23).

hh

(00-23).

(0-59).

nn

(00-59).

(0-59).

ss

(00-59).

ShortTimeFormat.

tt

LongTimeFormat.

am/pm

12- am . , ^
.

a/p

12- .
, .

ampm

12- , TimeAMString TimePMString.

, DateSeparator.
, TimeScparator.

xx'/"xx" , , , ,
.
:

""

14.04.02 8:34:14

"d/m/yy h:n"

14.4.02 8:34

": d mmmm ., - dddd"

: 14 2002 ., -

,
DateToStr, TimeToStr, DateTimeToStr, .
StrToDate, StrToDateTime, StrToTime
, TDateTime.
StrToDate .
, , DatcSeparator. , ShortDateFormat. : m/d/y, d/m/y
y/m/d. , (m/d

d/m) . ( 0 99),
.
StrToTime ,
, ,
TimeSeparator: hh:mm:ss. . StrToDateTime , .
EConvertError.
dos.h date:
struct date(
int da year;
//
char da_day;
//
char da mon;
// (1 - }
};

, . .
D date :
include <dos.h>
struct date D;
getdate(&D);
: D.da_year, D.da_mon,
D.da_day.

:
struct time I
unsigned
unsigned
unsigned
unsigned

char
char
char
char

ti_min;
ti_hour;
ti_hund;
ti_sec;

//
//
//
//

};
time , 0
1 1970 . , , , ..,
ctime . :
Mon Nov 21 11:31:54 1983\\0
, .
, time,
gmtime ( ) localtime ( ) tm:
struct
int
int
int
int
int
int
int
int
int
I;

tm (
tm sectm mi n;
tm hour;
tnf mday;
tm' mon;
tm" year;
tm" wday;
tm yday;
tm isdst;

//
//
// (0 - 23)
// (1
// (0 - 111

-31)

// ( 1900)
// (0 - ; 0 -
// (0 - 365)
// 12-

asctimc. , :

time_t t = tirae(NULL);
s t r u c t tm * t t = l o c a l t i m e ( S t ) ;
char s [ 8 0 ] ;
strcpy(s, asctirae(tt));

tm, , time gmtimc, s. , , ctime .. .

16.3.3

Bounds

Windows::TRect Bounds(int ALeft, int ATop, Classes.hpp


int AWidth, int AHeight)
ALeft
AWidth AHeight TRect

CurrToFMTBCD bool CurrToFMTBCD(System::Currency Curr, DBCommon.hpp


Bde::FMTBcd &BCD, int Precision,
int Decimals)
Curr Bde::FMTBcd
FMTBCDToCurr bool FMTBCDToCurr(
DBCommon.hpp
const Bde::FMTBcd &BCD,
System::Currency &Curr)
BCD Currency
Point

TPoint Point(int AX, int AY)


AY TPoint

Rect

Windows::TRect Rcct(int ALeft, int ATop,


Classes.hpp
int ARight, int ABottom)
ALeft, ATop, ARight, ABottom
TRect

Classes.hpp

CurrToFMTBCD FMTBCDToCurr Currency Bde::FMTBcd,


BCD .
Bounds Rect TRect,
. .
. 17. Rect TRect , , ALeft, ATop, ARight, ABottom. Bounds TRect ALeft , AWidth AHeight.
C++Builder , ,
, BoundsRect, ClientRect . , Memol Panell, , 10 (
), 40 (,
):
Mfimnl-^BoundsRect

Rect(10,40,Panell->ClientWidth-10,
Panell->ClientHeiqht-10);

:
Memol->BoundsRect = Bounds (10,40,Panell->ClientWidth-20, )
Panell->ClientHeight-50) ;
Point TPoint,

. , . 17. TPoint TRect,
.
, Rect Point, a
TRect TPoint:
TRect R, Rl, R 3 ;
R = Rect (10, 100, 20,200) ;
Rl = R;
TPoint PI, P 2 ;
PI = Point(10, 100) ,
P2 = Point(10, 200) ,
R3 = TRect (PI, P2) ;
TRect R2(PI,

P2);

R.Left = 1 5 ;
i n t W = R. Width () ;
i f ( R l != R) . . .

16,4
16.4.1
/

ctype.h

_tolower

int _tolower(int ch)



( )

_toupper

ctype.h
int _toupper(int ch)

( )

isalnum

int isalnum(int )

ctype.h

isalpha

int isalpha(int )

int isascii(int )

int iscntrl(int )

int isdigit(int )

ctype.h

isascii
iscntrl
isdiglt
isgraph


ctype.h
ASCII
ctype.h

ctype.h

iiil U|(rapli(int )
MiiNjior ( )

ctype.h


islower

/
|
int islower(int c)
ctype.h

isprint

int isprint(int )
( )

ctype.h

ispunct

int ispunct(int )
( , , , )

ctype.h

isspace

int isspace(int )
(, , )

ctype.h

isupper

int isupper(int c)

ctype.h

iswalnum

int iswalnum(wint_t )

ctype.h

iswalpha

int iswalpha(wint_t )

ctype.h

iswascii

int iswascii(wint_t )
ASCII

ctype.h

iswcntrl

int iswcntrl (wint_t )


ctype.h

iswdigit

int iswdigit(wint_t c)

ctype.h

iswgraph

int iswgraph(wint_t )
( )

ctype.h

iswlower

int iswlower(wint_t )

ctype.h

iswprint

int iswprint(wint_t )
( )

ctype.h

iswpunet

int iswpunct(wint_t c)
( , , , )

ctype.h

iswspace | int iswspace(wint_t )


(, , )

ctype.h

iswupper

int iswupper(wmt_t )

ctype.h

iswxdigit

int iswxdigit(wint_t )

ctype.h

isxdigit

int isxdlgit(int c)

toascii

int toascii(int )
ASCII (
, 7 ) 0 127)

ctype.h

tolower

int tolower(int ch)


,

ctype.h

toupper

int toupper(int ch)


,

ctype.h

towlower

int towlower(wint_t ch)


,

ctype.h

towupper int towupper(wint_t ch)


,

ctype.h

ctype.h

, ,
, .
(. . 16.4.2.2 16.4.2.3): , . ,

Key = A n s i U p p e r C a s e ( K e y ) [ 1 ] ;

Key char .

16.4.2
16.4.2.1
/

""~"

mem.h

memccpy

void *memccpy(void *dest, const void *src, int c, size_t n)


src dest,
; dest

memchr

mem.h
void *memchr(const void *s, int c, size_t n)
s; , NULL
mem.h
int memcmp(const void *sl, const void *s2, size_t n)
n si s2; < 0
s i < s2, = 0 s i = s2, > 0 s i > s2
mem.h
void *memcpy(void *dest, const void *src, size_t n)
n src dest; src dest |> (. memmove); dest

memcmp

memcpy

1|

memicmp int memicmp(const void *sl, const void *s2, size_t n)


mem.h
, ( ),
si s2; < 0 si < s2, = 0 si = s2, > 0
si > s2
memmovc void *memmove(void *dest, const void *src, size_t n)
mem.h
src dest; src dest (. memcpy); dest
memsct

void *memset(void *s, int c, size_t n)


s ; s

mem.h

aetmem

void setmem(void *dest, unsigned length, char value)


dest length value

mem.h

, , , .
16.4.2.2

AnsiStrComp

int AnsiStrComp(char * SI, char * S2)


SysUtils.hpp
S I H S2 ; < 0 Sl< S2, = 0 Sl= S2, > 0 Sl> S2
SysUtils.hpp
int AnsiStrIComp(char * SI, char * S2)
S I H S2 ; < 0 Sl< S2, = 0 Sl= S2, > 0 Sl> S2
int AnsiStrLComp(char * SI, char * S2,
SysUtils.hpp
Cardinal MaxLen)
MaxLen S I H S2; < 0 Sl< S2, = 0 Sl= S2, > 0 Sl> S2

AnsiStrIComp
AnsiStrLComp

AnsiStrLlComp

int AnsiStrLIComp(char * SI, char * S2,


SysUtils.hpp
Cardinal MaxLen)
MaxLen 1 S2
; < 0 Sl< S2, = 0
Sl= S2, > 0 Sl> S2

AnsiStrLower

char * AnsiStrLower(char * Str)


,
.

SysUtils.hpp

AnsiStrPos char * AnsiStrPos(char * Str, char * SubStr)


SubStr
Str NULL

SysUtils.hpp

AnsiStrRScan

SysUtils.hpp

char * AnsiStrRScan(char * Str, char Chr)


Chr Str NULL

AnsiStrScan

char * AnsiStrScan(char * Str, char Chr)



Chr Str NULL

SysUtils.hpp

AnsiStrUpper

char * AnsiStrUpper(char * Str)


,

SysUtils.hpp

CompareStr

SysUtils.hpp
int CompareStr(const System::AnsiString SI,
const System::AnsiString S2)
Sin S2 ; < 0 S l < S2, = 0 S l = S2, > 0 S l > S2

CompareText

SysUtils.hpp
int CompareText(const System::AnsiString SI,
const System::AnsiString S2)
Sin S2 ; < 0 S l < S2, = 0 Sl= S2, > 0 Sl> S2

Line Start

char * LineStart(char * Buffer, char * BufPos)



Buffer, BufPos

SysUtils.hpp

StrAlloc

char * StrAlloc(Cardinal Size)


Size - 1 ;
StrDispose

SysUtils.hpp

StrBufSize

Cardinal StrBufSize(char * Str)


,
StrAlloc
Str

SysUtils.hpp

strcat

char *strcat(char *dest, const char *src)


string.h
src dest;

StrCat

char * StrCat(char * Dest, char * Source)


Source Dest;

SysUtils.hpp

strchr

char *strchr(const char * s, int c)


s,
NULL

string.h

strcmp

int strcmp(const char *sl, const char *s2)


string.h
si s2; < 0 si < s2,
= 0 s i = s2, > 0 s i > s2

strcmpi

int strcmpi(const char *sl, const char *s2)


To , stricmp: si s2
( ); < 0
si < s2, = 0 s i = s2, > 0 si > s2

string.h

I StrComp

int StrComp(char * Strl, char * Str2)

SysUtils.hpp

S I H S2 ( AnsiStrComp); < 0 Sl< S2, = 0 S I - S2, > 0 Sl> S2


StrCopy

char * StrCopy(char * Dest, char * Source)

SysUtils.hpp

Source Dest Dest


strcpy

char *strcpy(char *dest, const char *src)

string.h

src dest; dest


strcspn

size_t strcspn(const char *sl, const char *s2)

string.h

si, s2
strdup

char *strdup(const char *s)


s;

string.h

StrECopy

char * StrECopy(char * Dest, char * Source)


Source Dest
Dest

SysUtils.hpp

StrEnd

char * StrEnd(char * Str)

SysUtils.hpp


Str
strerror

char *strerror(int errnum)


string.h
errnum

stricmp

string.h
int stricmp(const char *sl, const char *s2)
To , strcmpi: si s2 ( ); < 0 si < s2,
= 0 si = s2, > 0 si > s2

StrlComp

int StrIComp(char * Strl, char * Str2)

SysUtils.hpp

S I H S2 ( AnsiStrlComp);
< 0 Sl< S2, = 0 Sl= S2, > Opi^Sl> S2
StrLCat

char * StrLCat(char * Dest, char * Source,


SysUtils.hpp
Cardinal MaxLen)
MaxLen Source Dest Dest

StrLComp

int StrLComp(char * Strl, char * Str2,


SysUtils.hpp
Cardinal MaxLen)
MaxLen S I H S2 (
AnsiStrLComp); < 0 Sl< S2, = 0
Sl= S2, > 0 Sl> S2

StrLCopy

SysUtils.hpp
char * StrLCopy(char * Dest, char * Source,
Cardinal MaxLen)
MaxLen Sonrce Dest Dest

strlen

size_t strlen(const char *s)


s,

StrLen

SysUtils.hpp
Cardinal StrLen(char * Str)
Str,

string.h

SysUtils.hpp
StrLIComp int StrLIComp(char * Strl, char * Str2,
Cardinal MaxLen)
MaxLen S I H S2
(
AnsiStrLIComp); < 0 S l < S2, = 0
S l = S2, > 0 S l > S2
StrLower

char * StrLower(char * Str)


SysUtils.hpp
,
( AnsiStrLower)

strlwr

char *strlwr(char *s)


s ( )

StrMove

SysUtils.hpp
char * StrMove(char * Dest, char * Source,
Cardinal Count)
Count Source Dest Dest; Source Dest

strncat

char *strncat(char *dest, const char *src,


string.h
size_t maxlen)
maxlen src dest ; dest

strncmp

int strncmp(const char *sl, const char *s2,


string.h
size__t maxlen)
maxlen si s2; < 0 s i < s2, = 0 si = s2, > 0 si > s2

strncmpi

int strncmpi(const char *sl, const char *s2, size_t nX string.h


To , strhicmp: maxlen
si s2 ( ); < 0 si < s2, = 0 si = s2, > 0 si > s2

etrncpy

stdio.h
char *strncpy(char *dest, const char *src,
size_t maxlen)
maxlen src dest; .- dest

string.h

StrNew

char * StrNew(char * Str)


Str

SysUtils.hpp

strnicmp

string.h
int strnicmp(const char *sl, const char *s2,
size_t maxlen)
To , stmcmpi: maxlen
si s2 ( ); < 0 si < s2, = 0 si = s2, > 0 si > s2

strnset

char *strnset(char *s, int ch, size_t n)


ch s

strpbrk

string.h
char *strpbrk(const char *sl, const char *s2)
si s2 NULL
SysUtils.hpp
char * StrPCopy(char * Dest,
const System: :AnsiString Source)
Source Dest Dest

StrPCopy

StrPLCopy char * StrPLCopy(char * Dest,


const System::AnsiString Source, Cardinal MaxLen)
MaxLen Source Dest
Dest

string.h

SysUtils.hpp

StrPos

char * StrPos(char * Strl, char * Str2)


SysUtils.hpp
Str2 Strl
NULL

Strrchr

char *strrchr(const char *s, int c)


s
NULL

strrev

char *strrev(char *s)


string.h
() s

char * StrRScan(char * Str, char Chr)


SysUtils.hpp
Chr Str
NULL

StrRScan

string.h

StrScan

char * StrScan(char * Str, char Chr)


Chr Str
NULL

SysUtils.hpp

strset

char *strset(char *s, int ch);


s ch

string.h

strspn

size_t strspn(const char *sl, const char *s2)


si, s2 ( )

string.h


strstr
strtok

StrUpper

strupr

/
char *strstr(const char *sl, const char *s2)
s2
si NULL
char *strtok(char *sl, const char *s2)
s2
si si;
char * StrUpper(char * Str)
,
( AnsiStrUpper);
char *strupr(char *s)
s ( )

string.h
string.h

SysUtils.hpp

string.h

string.h, (strcmpi, stricmp,


Btrlwr, strncmpi, strnicmp, strupr), , . SysUtils.hpp.
.
, , , . .
strcat , , , .
,
. strcat, . strcpy , ,
,
. strstr . strcat,
strcpy, strstr strlen . 14, . 14.4.1.
strtok, .
si
, s2. , , .. si .
si.
strtok, NULL. si ( s2
), s2,
. , .
.
char s [ 8 0 ] , *;
= s t r t o M s , " , .") ;
if (p) Memol->Llnes->Add(p);
while(p)
(
- - ,,k ( N U L L ,

if

tin

"

, . ; ") ;

M<nn<;l ->I.ine.i->Add (p) ;

s -: , , .
Memol. ,
s , .,
Memol :

strtok ,
:

LineStart Buffer
BufPos \. ,
, .
BufPos , 1 , .. \ ,
Buffer. ,
char *Buf = " \ \ ",
* = StrEnd(Buf);
do .
(
P=LineStart(Buf, P-l) ;
) while(P != Buf);

, , Buf.
16.4.2.3 AnsiString

System::AnsiString AdjustLineBreaks(
SysUtils.hpp
AdjustLineBreaks
const System::AnsiString S)
S CR/LF
Unix
Ansiint AnsiCompareStr(const System::AnsiString SI,
SysUtils.hpp
const System::AnsiString S2)
CompareStr
S I H S2 ; < 0 Sl< S2, = 0 S l = S2, > 0 Sl> S2
AnsiCompareText

int AnsiCompareText(const System::AnsiString SI, SysUtils.hpp


const System::AnsiString S2)
S I H S2 ; < 0 Sl< S2, = 0 Sl= S2, > 0 Sl> S2

AnsiExtractQuotedStr

System::AnsiS tring AnsiExtractQuotedStr(


SysUtils.hpp
char * &Src, char Quote)
Src
, Quote,

|
SysUtils.hpp

AnsiLower- System::AnsiString AnsiLowerCase(


const System::AnsiString S)
Case
S, ( )
SysUtils.hpp
int AnsiPos(const System::AnsiString Substr,
AnsiPos
const System::AnsiString S)
Substr S
0
SysUtils.hpp
AnsiSystem::AnsiString AnsiQuotedStr(
QuotedStr
const System::AnsiString S, char Quote)
S
, Quote,

SysUtils.hpp
AnsiUpper- System::AnsiString AnsiUpperCase(
const System::AnsiString S)
Case
S, . ( )
IsDelimiter bool IsDelimiter(const System::AnsiString Delimiters, SysUtils.hpp
const System::AnsiString S, int Index)
, Index
S ,
Delimiters
SysUtils.hpp
IsPathbool IsPathDelimiter(const System::AnsiString S,
Delimiter
int Index);
, Index
S '\',

int LastDelimiter(
SysUtils.hpp
LastDelimiter
const System::AnsiString Delimiters,
const System::AnsiString S)

S , Delimiters
LowerCase

QuotedStr

System::AnsiString LowerCase(
SysUtils.hpp
const System::AnsiString S)
S, ( AnsiLowerCase)
SysUtils.hpp
System::AnsiString QuotedStr(
const System::AnsiString S)
S

(
AnsiQuotedStr)


StringReplace

SysUtils.hpp
System::AnsiString StringReplace(
const System:.-AnsiString S,
const System::AnsiString OldPattern,
const System::AnsiString NewPattern,
TRepIaceFlags Flags)
S OldPattern
NewPattern; Flags

Trim

System::AnsiString Trim(const System::AnsiString S) SysUtils.hpp


S

TrimLeft

SysUtils.hpp
System::AnsiString TrimLeft(
const System::AnsiString S)
S

TrimRight

System::AnsiString TrimRight(
SysUtils.hpp
const System::AnsiString S)
S

Uppercase

SysUtils.hpp
System::AnsiString UpperCase(
const System::AnsiString S)
S, ( AnsiUpperCase)
System::AnsiString WrapText(
SysUtils.hpp
const System::AnsiString Line,
const System::AnsiString BreakStr,
const TSysCharSet &BreakChars,
int MaxCol)
Line,
MaxCol BreakStr
BreakChars

WrapText

, , . 17 AnsiString. AnsiString.
, AnsiString, ,
, , char *.
.
IsDelimiter IsPathDelimiter 1 ( C++Builder). 1 , 2 ..
IsDelimiter
- . ,
AnsiString S, Delimiters;
Delimiters = " ' " ;
S =
f o r ( i n t i = 1; i <= S t r L e n ( S . c s t r ( ) ) ;

i++)

i L (I:; Delimiter (Delimiters, S, i) )


S [ i ] = ;

S .
Delimiters . . , :
AnsiString S, Delimiters;
Delimiters = "12345689";
S = ...;
f o r d n t i = 1; i <= StrLen (S.c_str () ) ; i++)
if(IsDelimiter(Delimiters,S,i))
S[i] -= 1;

, 0, 1.
StringReplace S OldPattern
NewPattern. Flags rfRepIaceAH,
OldPattern. Flags
rflgnoreCase, . ,
SI = StringReplace(S, OldPattern, NewPattern,
TReplaceFlags()<<rfReplaceAll);
SI S OldPattern
NewPattern.
WrapText Line . , BreakStr. MaxCol .
BreakStr ,
BreakChars.
, MaxCol.
BreakChars ,
MaxCol. ,
TSysCharSet b c h a r s ;
b c h a r s << ' ' << ' . ' << ', ' << ' ; , ' << ' + ' ' - ' ;
A n s i S t r i n g S, S I ;
S = ...;
SI = WrapText(S, " \ n \ r " , b c h a r s , 10);

SI S, 10 ,
. S : ,
+ ., :
" "
" "
" "
" ,"
"
" "
"- "
" +"
" -."

, 11 , ,
.. .
,
. .

16.5
16.5.1 ,
, dos.h:
FA RDONLY

FA HIDDEN

FA_SYSTEM

FA LABEL

FA DIREC

FA_ARCH

. 16.5.6.
(|).
( fcntl.h):
O_RDONLY

O_WRONLY

RDWR

O_CREAT

O_TRUNC

, 0

O_BINARY
O_TEXT

O_NOINHERIT
0 NDELAY

, UNIX

O_APPEND

O_CREA

, ,
, mode, ,

O_EXCL

O_CREA , ,
,

mode (
sysXstat.h):
S_IWRITE

S_IREAD

S_IREAD | S_IWRITE

( share.h):
. (, SH_COMPAT | SH_DENWR). ,
, SH_DENWR

(
SH_DENYNO
SH DENYNONE )
SH_DENYNONE .
, SH_COMPAT
, SHJDENYRD

SH DENYRW

SH_COMPAT

(|).
SHMDENYRD, SH_DENYNO 1.
, ( SysUtils.hpp):

fmOpenRead
fmOpenWrite
fmOpenRead Write
fmShareCompat
fmShareExclusive

$0000
$0001
$0002
$0000
$0010

fmShareDeny Write $0020


fmShareDenyRead
$0030
finShareDenyNone
$0040




FCB



C++ (stream),
.
C++Builder .
, ()
FILE, stdio.h, . (handle) ,
.

:

stdin
stdout
stdcrr

1
2

.
, ,
Windows.

16.5.2 ,
FILE
, FILE, .

_fdopen

/
stdio.h
FILE *_fdopen(int handle, char * mode)
handle, mode, FILE NULL

_fileno

int _fileno(FILE *stream)


stream
int _flushall(void)
, ;

_fluahall

stdio.h
stdio.h

_fsopen

stdio.h,
FILE *_fsopen(const char ^filename, const char *mode,
f'xare.h
int shflag)
filename , shflag mode;
FILE NULL

fclose

int fclose(FILE stream)


stream

stdio.h

fflush

int fflush(FILE *stream)


stream,
; 0 EOF

stdio.h

fopen

FILE *fopen(const char ^filename, const char *mode)


filename mode
FILE NULL

stdio.h

freopen

stdio.h
FILE *freopen(const char *filename, const char *mode,
FILE *stream)
stream filename mode FILE NULL
stdio.h
void setbuf(FILE *stream, char *buf)
buf stream

setbuf

setvbuf

int setvbuf(FILE *stream, char *buf, int type, size_t size)


buf size stream

stdio.h

tmpfile

FILE *tmpfile(void)

FILE NULL

stdio.h

fopen, filename. mode , . :

; ,

W+

;
,

+ t , , . , rt, rb, r+t, r+b .. t, ,


_fmode,
fcntl.h. _ ( ) O_BINARY .
, fopen
FILE. , NULL. :
FILE * F ;
if ((F = f o p e n ( " T e s t . t x t " , " r t " ) ) == NULL)
1
ShowMessage(" ");
return;

, , .
.
fseek rewind, . 16.5.4. , :
() () fseek rewind
in' MHIU.IM fscck rewind
-

_fsopen filename , shflag mode. , shflag, . . 16.5.1. mode


fopen.
DOS SHARE.EXE.
freopen stream
filename mode. fopen ,
stream . , ,
. ,
FILE *F = freopenCoutput.txt",

"wt",

stdout);

stdout output. txU. stdout .


_fdopen , ( . . 16.5.3), FILE. ,
FILE * stream = fdopen(handle,

"w");

handle stream.
,
FILE, _fileno.
Test.txt .
FILE *stream;
i n t handle;
stream = fopen ("Test. i x t " ,
handle - _tileno(stream);
fclose(stream);

''v'M;

//
//
/ /

, ..
, , .
, ,
fflush _flushall. , . ,
, .
.
.
setbuf setvbuf.
setbuf buf NULL,
. ,
, . buf
,
stream .
BUFSIZ, stdio.h. :
char outbuf[BUFSIZ];
setbuf(F, outbuf);

setbuf
fseek (. . 16.5.4),
. setbuf
.
setvbuf
. buf = NULL
.1 malloc
1- size. .

.
UINTJVfAX, limits.h.
type :
IOFBF

. , . ,
.

IOLBF

. ,
, , .

, .

IONBF

/. buf size .

setvbuf .
, fopen freopen, fclose. .
setbuf setvbuf buf NULL, .
tmpfile
(w+b) FILE. NULL.
, .
, FILE,
. . 14, . 14.9.2.

16.53 ,

.

_creat

int _creat(const char *path, int mode)



mode; -1
int _rtl_close(int handle)
handle

io.h,
sys\stat.h

_rtl_close

io.h

_rtl_creat

int _rtl_creat(const char *path, int attrib)


io.h, dos.h

path attrib; -1

_rtl_open

int _rtl_open(const char ^filename, int oflags)


io.h, dos.h
filename oflags; -1

/
int _sopen(char *path, int access, int shflag [,
_sopen
int mode])
path , access, shflag, mode; 1
close
int close(int handle)
handle
creatnew
int creatnew(const char *path, int attrib)
_rtl_creat, ,

creattemp int creattemp(char *path, int attrib)


attrib path
dop
int dup(int handle)
handle
dup2
int dup2(int oldhandle, int newhandle)
newhandle oldhandle
void FileClose(int Handle)
FileClose
Handle
FileCreate int FileCreate(const System::AnsiString FileName)
FileName -1
int FileOpen(const System::AnsiString FileName,
FileOpen
int Mode)
FileName Mode -1
int lock(int handle, long offset, long length)
lock
handle length ,
offset
int locking(int handle, int cmd, long length)
locking
handle length
,

setmode
int setmode(int handle, int amode)
amode
handle:
O_BINARY , OJTEXT
unsigned umask(unsigned mode)
umask
/ mode, open creat:
S_IWRITE, S_IREAD SJREAD | S_IWRITE;

fcntl.h,
sys\stat.h,
share.h, io.h,
stdio.h
io.h
io.h, dos.h

io.h, dos.h

io.h
io.h

SysUtils.hpp
SysUtils.hpp

SysUtils.hpp

io.h

io.h,
sys\locking.h

io.h

io.h

unlock

int unlock(int handle, long offset, long length)


handle length , offset,

io.h

_creat mode. path . , _fmode _


O_BINARY. ,
0.
, _creat , .
, , mode,
, sys\stat.h .
16.5.1.
.
- 1 , (. . 16.1.3.1) EACCES, ENOENT, EMFILE.
_creat _rtl_creat. _creat, attrib (|) : FA_RDONLY , FA_HIDDEN , FA_SYSTEM ( . . 16-5.1).
creatnew _rtl_creat , ,
1 , .
_rtl_open filename
oflags. .
16.5.1.
. 1,
(. . 16.1.3.1) EINVACC, EACCES,
ENOENT, EMFILE.
_sopen path , access, shflag, mode. access _...
, . 16.5.1. O_CREA,
mode (. . 16.5.1). shflag . . 16.5.1.
. - 1 , (. . 16.1.3.1) EINVACC, EACCES, ENOENT, EMFILE.
creattemp attrib path. , _fmode (O_TEXT O_BINARY). attrib
FA_HIDDEN,
FA_RDONLY FA_SYSTEM (. . 16.5.1).
, HANDLE_MAX.
close, _rtl_close FileClose , crcat, creatnew, creattemp, dup, dup2, open, _rtl_creat, _rtl_open, FileOpen.
:>
Clrl-/. , .

0. -1 (. . 16.1.3.1) EBADF.
, , , :
int hout = cpon("output.txt", O_CREAT I O^WRONLY,S_IWRITE);
close(hout);
,
int handle;
if ((handle = open ("Test.txt", O_CREAT I 0 TEXT)) == -1)
{
ShowMessage(" ");
return;
close (handle);

, ( open
-1) .
FileOpen, FileCreate FileClose , . FileOpen Mode,.3aflaBaeMOM fmShare (. . 16.5.1).
FileRead.
FileWrite, FileSeek, . 16.5.4.


lock, unlock, locking.
DOS SHARE.EXF.
locking cmd:
LK_LOCK

. , , , 10 .

LK RLCK
LK NBLCK

, LK_LOCK.
. ,
.

LK NBRLCK , LK NBLCK.
LK UNLCK

0.
- 1 , (. . 16.1.3.1) EACCES
EBADF, EDEADLOCK ,
10 ( cmd LK_LOCK LK_RLCK), EINVAL cmd SHARE.EXE.
dup dup2 .
dup () handle.
,
, ( , , ) i
. (,
. .
dup2 -, dup newhandlc

'i oldhandle. dup dup2 , ,


. ,
i n t h o u t = open ( " o u t p u t . t x t " , _ I O_WP.OMLY, S_IWRITE) ;
dup2(hout,1) ;
"
~

stdout ( 1
. . 16.5.1) output.txt.

16.5.4 /

_fgetchar

int _fgetchar(void)
stdin

stdio.h

_fputchar int _fputchar(int )


stdout, , fputc(c,
stdout); EOF

stdio.h

_getw

int _getw(FILE *stream)


stream

stdio.h

cgets

char *cgets(char *str)


conio.h

clearerr

void clearerr(FILE *stream)



stream

stdio.h

cprintf

int cprintf(const char *format [, argument, ...]


argument no
format (. . 16.1.2.1)

conio.h

cputs

int cputs(const char *str)


conio.h
;

cscanf

conio.h
int cscanf(char *format [, address, ...])
argument format;
EOF

eof

int eof (int handle)


io.h
0 (),
handle

feof

int feof(FILE *stream)


0 ()
stream

stdio.h

ferror

int ferror(FILE *stream)


/ stream
0

stdio.li

fgctc

int fgctc(FILE *stream)


stdio.h
;) stream

(!<- /
i


i'Kftpos
int l'fjctpos(FILE *stream, fpbs_t *pos)
pos stream;

fgets
char *fgets(ehar *s, int n, FILE *stream)
s stream
FileRead int FileRead(int Handle, void *Buffer, int Count)
Handle,
FileOpen FileCreate, Count
Buffer; -1

stdio.h

stdio.h

SysUtils.hpp

SysUtils.hpp
int FHeSeek(int Handle, int Offset, int Origin)
Handle,
FileOpen FileCreate,
Offset Origin; 0

FileWrite int FileWrite(int Handle, const void Buffer, int Count) SysUtils.hpp
Handle,
FileOpen FileCreate, Count
Buffer;
-1
FileSeek

fprintf

fputc
fputs

fread

fscanf

fseek

int fprintf(FILE stream, const char *format [,


stdio.h
argument, ...])
stream argument
format; EOF
int fputc(int , FILE *stream)
stdio.h
stream
int fputs(const char *s, FILE *stream)
s stream; EOF

stdio.h

size_t fread(void *ptr, size_t size, size_t n,


stdio.h
FILE *stream)
stream ptr n size ;
(n * size)
int fscanf(FILE *stream, const char *format [,
stdio.h
address, ...])
stream
argument format; EOF
int fseek(FILE *stream, long offset, int fromwhere)
stdio.h
stream offset
! fromwhere; 0
|

ftell
fwrite

getc

stdio.h
int Cs(4po!(Fll.K *lrruin, const fpos_t *pos)
. stream pos
stdio.h
long int ftcll(FILK *stroain)
stream

(' / -

size_t fwrite(const void *ptr, size_t size, size_t n,


stdio.h
FILE *stream)
ptr stream n size ;

(n * size)

int getc(FILE *stream)


stream

stdio.h

getch

int getch(void)

conio.h

getchar

int getchar(void)
stdin; , getc(stdin)

stdio.h

getche

int getche(void)

conio.h

getpass

char *getpass(const char *prompt)



prompt;

conio.h

gets

char *gets(char *&)


stdin
int kbhit(void)
;

stdio.h

kbhit

conio.h

lseek

long lseek(int handle, long offset, int fromwhere)


io.h
handle
offset fromwhere;

perror

void perror(const char *s)


s

printf

int printf(const char *format [, argument, ...])


stdio.h
stdout argument format (. . 16.1.2.1)

puto
piilch

] int putc(int , FILE *stream)


stream
int putch(int )

stdio.h

stdio.h
conio.h

:]


putchar

int putchar(int c)
, stdout;
putc(c,stdout)

stdiu.h

puts

int puts(const char *s)


s stdout

stdio.h

puttext

int puttext(int left, int top, int right, int bottom,


void *source)
source
left, top, right, bottom

conio.h

putw

int _putw(int w, FILE *stream)


stream w

stdio.h

read

int read(int handle, void *buf, unsigned len)


handle buf
len

io.h

scanf

int scanf(const char *format [, address, ...])


stdin
argument format (. .
16.1.2.2)

stdio.h

sprintf

int sprintf(char *buffer, const char *format [,


conio.h
argument, ...])
buffer argument
format (. . 16.1.2.1)

sscanf

int sscanf(const char *buffer, const char *format


[, address, ...])
buffer
argument format

tell

long tell(int handle)


io.h

handle

ungetc

int ungetc(int , FILE *stream)


ch stream,

ungetch

int ungetch(int ch)


conio.h
ch ,

vfprintf

int vfprintf(FILE *stream, const char *format,


stdio.h
va_list arglist)
stream arglist no
format (. . 16.1.2.1)

conio.h

stdio.h

/
vfm auf
int vfscanf(FILE *stream, const char *format,
va_list arglist)
stream arglist format (. . 16.1.2.2)
vprintf
int vprintf(const char *format, va_list arglist)
stdout arglist format (. . 16.1.2.1)
int vscanf(const char *format, va_list arglist)
vscanf
stdin arglist format (. . 16.1.2.2)
vsprintf

vsscanf

write

stdio.h

stdarg.h

stdarg.h

stdarg.h
int vsprintf(char *buffer, const char *format,
va_list arglist)
buffer arglist no
format (. . 16.1.2.1)
stdarg.h
int vsscanf(const char *buffer, const char *format,
va_list arglist)
buffer arglist format (. . 16.1.2.2)
io.h
int write(int handle, void *buf, unsigned len)
handle buf
len

scanf
printf .
printf, sprintf, vfprintf, vprintf, vsprintf . . 16.1.2.1.
EOF .
fscanf, scanf, cscanf, sscanf, vfscanf, vscanf, vsscanf
. . 16.1.2.2. .
, ,
EOF. , ,
, . :
FILE * F ;
if ( ( F = f o p e n ( " T e s t 2 . t x t " , " r t " ) ) == NULL)
(
ShowMessage(" ");
return;

int. il, i2;


Hnuble r;
it (fscanf(F, "%d%d%le", Sil, Si2, Sr)
:;howMessage (" ");

3)

vt'printf vfseanf va_list, stdarg.h (. . 16.7.4).


, .
:
include
#include
FILE

<stdio,h>
<stdarg.h>

*fp;

void p r ( c h a r

^format,

...)

fp = tmpf i l e () ;
if (fp -= NULL)
(
ShowMessage(" ");
exi t (1) ;
)
v a _ l i s t ;
int arg;
v a _ s t a r t ( a p , format);
arg = v f p r i n t f t f p , format, ap) ;
va end (ap) ;
}

, , :
pr("%d

id

Id",

10,

20,

30);

getchar, _fgetchar, cgets, cprintf, _fputchar, putch, puttext, getch,


getche, cputs, getpass, cscanf, kbhit, ungetc, ungetch, vprintf, vscanf Win32.
Win32
scanf, gets stdin,
printf, putchar, puts stdout.
getchar, _fgetchar, getc, fgetc , .
getchar, _fgetchar, getc, gets, fgets, fgetc, fputc EOF.
getc, fgetc, getchar .
getc 1, .
_getw , . () . putw, puts .
EOF. EOF
,
feof ferror.
gets ,
, .
fgets , ,
.
puttext, ,
, source, left, top, right, bottom. (1,1). 2 ,
, . 0 .

(seek Iscuk offset fromwhere. TCKCTOIIOI-O offset 0 - , ftell.


froinwherc, ,
offset. (! :
SKKK_SET
SEKK_CUR
SEEK END

|
1

0 .
FileRead, FileWrite FileSeek ,
FileOpen FileCreate.

16.5.5

_mktemp

/
char *_mktemp(char *template)
, template ,

ChangeFile- System::AnsiString ChangeFileExt(
Ext
const System::AhsiString FileName,
const System::AnsiString Extension)
FileName
Extension;
ExpandFile- System::AnsiString ExpandFileName(
const System::AnsiString FileName)
Name
FileName,
;
ExpandUNC- System::AnsiString ExpandUNCFileName(
FileName
const System::AnsiString FileName)
FileName,
UNC: "\\<servername> \<sharename>",
ExtractFile- System::AnsiString ExtractFileDir(
Dir
const System::AnsiString FileName)
FileName
ExtractFile- System::AnsiString ExtractFileDrive(
Drive
const System::AnsiString FileName)
FileName (,
":") UNC: "\\<servername>\<sharename>",

dir.h

SysUtils.hpp

SysUtils.hpp

SysUtils.hpp

SysUtils.hpp
SysUtils.hpp

ExtractFileExt

SysUtils.hpp
System::AnsiString ExtractFileExt(
const Systein::AnsiString FileName)
FileName

ExtractFileName

SysUtils.hpp
System::AnsiString ExtractFileName(
const System::AnsiString FileNanie)
, FileName,
..

ExtractFilePath

System::AnsiString ExtractFilePath(
SysUtils.hpp
const System::AnsiString FileName) n
, FileName,
,

ExtractRelativePath

System::AnsiString ExtractRelativePath(
const System-AnsiString BaseName,
const System::AnsiString DestName)
DestName
BaseName, "..\"
ExtractShort- System::AnsiString ExtractShortPathName(
const System::AnsiString FileName)
PathName
FileName, 8.3
MatchesMask bool MatchesMask(
const System::AnsiString Filename,
const System::AnsiString Mask)
Filename Mask
System::AnsiString MinimizeName(
Minimizeconst System:: AnsiString Filename,
Name
Graphics::TCanvas * Canvas, int MaxLen)
Filename,
, Canvas MaxLen
void ProcessPath(const System::AnsiString EditText,
ProcessPath
char &Drive, System::AnsiString &DirPart,
System::AnsiString &FilePart)
EditText Drive, DirPart FilePart
char *tmpnam(char *s)
tmpnam
,

SysUtils.hpp

SysUtils.hpp

Masks.hpp

filectrl.hpp

filectrl.hpp

stdio.h

( tmpnam _mktemp) AnsiString


(. . 17), FileName.
. FileName , ExtractFile... .

,
. :
" : \\ Prog FilesWBcb . "
ExtractFileDir ,
CreateDir, GetCurrentDir, RemoveDir, SetCurrcntDir
(. . 16.5.6).
ExtractShortPathName FileName, 8.3. ,
: \Program Files\Borland\CBuilder\Bin\Bcb. <?

:\Progra-l\Borland\CBuilder\Bin\Bcb.exe

MatchesMask Filename Mask.


- , , "*" "?" . . [ ]. <>-<>. ,
"-". "!", , .
:.1 . MatchesMask true,
llcnaiiie , false, . ,
[ .1 -b] : \ \ t e s t \ \ * . *"

, : :
Bi test.
MinimizeName Filename, , Canvas MaxLen . . ,
-ll->Caption = MiniraizeName (" : W P r o g r a m F i l e s W B c b . e x e " ,
Labell->Canvas, 100);

[>||>1|( Labell :
...\Bcb.exe
'1' tmpnam _mktemp ,
. .
tmpnam _ = 65 535 v . s NULL,
ii.in;iTb L_tmpnam ( ! .i stdio.h). NULL, tmpnam |||- .
Kevin , tmpnam
II mktemp, I' ill. .

S 6
>> in.
Idcwd

char * _getdcwd(int drive, char *buffer, int buflen) direct.h


buffer buflen
drive (0 , 1
..); buffer NULL;
buffer - NULL


rmdir

/
int _rmdir(const char *path)
path (,
); 0 -1

"

dir.h

rtl chmod

io.h, dos.h
int _rtl_chmod(const char *path, int func [,
int attrib])
func = 0 , func = 1
attrib

unlink

int _unlink(const char "filename)


filename;
-1

waccess

int _waccess(const wchar_t *filename, int amode) io.h


, filename ; amode

wrtl chmod

int _wrtl_chmod(const wchar_t *path, int func, ...) io.h, dos.h


func = 0 , func = 1
attrib

io.h

access

int access(const char *filename, int amode)


, filename ; amode

io.h

chdir

int chdir(const char *path)


path ; 0 -1

dir.h

chmod

int chmod(const char *path, int amode)


amode path;
0 - 1 ; amode
S_IWRITE S_IREAD

io.h

chsize

int chsize(int handle, long size)


io.h
handle,
, size ;
-1

CreateDir

bool CreateDir(const System::AnsiString Dir)


Dir true

SysUtils.hpp

DeleteFile

bool DeleteFile(const System::AnsiString FileName)


FileName
true

SysUtils.hpp

DirectoryExists

bool DirectoryExists(
const System;:AnsiString Name)
, Name

SysUtils.hpp


DiskFrec

DiskSizc

FilcAge

FileDateToDateTime

FileExists
FileGetAttr
FileGetDate

filelength

FileSearch

FileSetAttr

FileSetDate

FindClose

/ Oiiu<int DUkFrw(Iiytr Drive)


)>
Drive 1, Drive (Drive --=0
, 1 , 2 ..)
int DiskSize(Byte Drive)
Drive - 1 ,
Drive (Drive =0
, 1 , 2 ..)
int FileAge(const System::AnsiString FileName)
FileName
- 1 ,
System::TDateTime
FileDateToDateTime(int FileDate)
TDateTime
FileDate, DOS
bool FileExists(const Systcm::AnsiString FileName)
, FileName
int FiIeGetAttr(const System::AnsiString FileName)
FileName
int FileGetDate(int Handle)

Handle 1,
long filelength(int handle)

handle; -1
System::AnsiString FileScarch(
const System:: AnsiString Name,
const System::AnsiString DirList)
DirList Name;
int FileSetAttr(const System::AnsiString FileName,
int Attr)
FileName Attr;
0
int FileSetDate(int Handle, int Age)
Age
Handle; 0
void FindClose(TSearchRec &F)
FindFirst FindNext F

SysUlilM.hpp

SysUtils.hpp

SysUtils.hpp

SysUtils.hpp

SysUtils.hpp
SysUtils.hpp
SysUtils.hpp

io.h

SysUtils.hpp

SysUtils.hpp

SysUtils.hpp

SysUtils.hpp


FindFirst

int FindFirst(const System::AnsiString Path,


SysUtils.hpp
int Attr, TSearchRec &F)
Path Attr; F;

findfirst

int findfirst(const char _FAR * path,


dir.h
struct ffblk _FAR * ffblk, int attrib)
path - .

attrib;
ffblk;
0 -1

FindNext

SysUtils.hpp
int FindNext(TSearchRec &F)
,
FindFirst F; F;
0

findnext

int findnext(struct ffblk _FAR * ffblk)


dir.h
,
findfirst
ffblk; 0
-1

fnmerge

void fnmerge(char *path, const char *drive,


dir.h
const char *dir, const char *name,
const char *ext)
path : drive, dir,
name ext

fnsplit

int fnsplit(const char *path, char *drive,


dir.h
char *dir, char *name, char *ext)
path : drive, dir,
name ext

ForceDirectories

FileCtrl.hpp
void ForceDirectories(System::AnsiString Dir)
Dir ,

fstat

int fstat(int handle, struct stat *statbuf)


statbuf handle; 0 - 1

gctcurdir

int getcurdir(int drive, char *directory)


dir.h
directory drive
( , 1 ..) "\"

GetCurrentDir

System::AnsiString GetCurrentDir()

sys\stat.h

SysUtils.hpp

gctcwd

rhir n4rwd(< luir *buf, int buflon)


Bo:iH|>uiitacT buf
buflcn , ; buf
NULL; buf = NULL

dir.h

getdisk

int getdisk(void)
: 0 , 1 ..

dir.h

gett'time

int getftime(int handle, struct ftime *ftimep)


handle
ftimep; 0 -1

io.h

GetSystemDirectory

UINT GetSystemDirectory(LPTSTR IpBuffer,


UINT uSize)
API Windows, IpBuffer
uSize Windows

GetWindowsDirectory

UINT GetWindowsDirectory(LPTSTR IpBuffer,


UINT uSize)
API Windows, IpBuffer
uSize Windows
int isatty(int handle)
io.h
, handle : , , ,

isatty

mkdir

int mkdir(const char *path)


path; 0
-1

dir.h

remove

int remove(const char *filename)


, filename; 0 -1

stdio.h

BemoveDir

bool RemoveDir(const System-AnsiString Dir)


Dir

SysUtils.hpp

rename

stdiu.h
int rename(const char *oldname,
const char *newname)
oldname,
newname; ; 0
1

RcnameFile

bool RenameFile(const System::AnsiString OldName, SysUtils.hpp


const System::AnsiString NewName)
OldName, NewName; NewName OldName, false

searchpath

char *searcbpatb(const char *file)


file , PATH;
NULL

dir.h

SetCurrentDir

bool SetCurrentDir(const System::AnsiString Dir) SysUtils.hpp


Dir

setdisk

int setdisk(int drive)


drive:
0 , 1 ..;

setftime

io.h
int setftime(int handle, struct ftime *ftimep)
handle ftimep; 0
- 1

stat

int stat(const char *path, struct stat *statbuf)


statbuf path; 0 -1

dir.h

sys\stat.h

fstat stat stat


. :
st mode

st dev

st rdev

, st_dev

st nlink

st size

st atime

( Windows) ( DOS)

st mtime

, st_atime

st ctime

, st_atime

st_mode
.
:
S IFCHR
S_IFREG

:
S IWRITE
S IREAD

HPKS NTFS Kt_alifno,


st mtime st ctitnc:
St._atime

St._mtime

St.ctime

MB

stat:
I include <stdio.h>
I i n c l u d e <time.h>
I include <sys\stat.h>
.cruet s t a t s t a t b u f ;
I1LE ' s t r e a m ;
f ( ( s t r e a m - fopen ("TEST. .TXT",
I

"r4t"))

== MULL)

ShowMessage(" ");
return;
tat("TEST.TXT",
jlose(stream);

Sstatbuf);

/ /

/ :
if ( s t a t b u f . s t _ m o d e & S_IFCHR)
Memol->Lines->Add(" " ! ;
if ( s t a t b u f . s t _ m o d e & S_1FREG)
Memol->Lines->Add(" " ) ;
:f ( s t a t b u f . s t _ m o d e S S_IREAD)
Memol->LLnes->Add(" " ) ;
if ( s t a t b u f . s t _ m o d e & S_IWRITE)
Memol->Lines->Add(" " ) ;
>mol->Lines->Add(" " +
AnsiString((char)('A'+statbuf-st_dev))!;
lr-mol->Lines->Add( " : " +
intToStr(statbuf.stsize));
"mol->Lines->Add (" " +
AnsiString(ctime(sstatbuf.st_ctime)));

' remove _unlink . i.i i. .


. cbmod
I! hmod.
access _waccess , 1>\ filename. ,
i . , , , | , .
amode , :



,

DOS, OS/2 Windows .


amode 00 04 . DOS
. 06 02 .
filename , , , .
0, .
1, :
ENOENT
EACCES

FindFirst, FindNext FindClose , .


TSearchRec:
struct TSearchRec
int Time;
int Si2e;
int Attr;
System::AnsiString Name;
int ExcludeAttr;
int FindHandle;
_WIN32JFIND_DATAA FinclData;

//
//
//
//

//

Attr .
:

falieadOnly

$00000001

fallidden

$00000002

faSysFile

$00000004

faVolumelD

$00000008

faDirectory

$00000010"

faArchive

$00000020

faAnyFile

$0000003F

FindFirst.
Path , Attr ,
.
. , 0, F
TSearchRec . FindNext F ,
, . , , , FindClose, .
, Memol:
TSearchRec sr;
Memol->Clear () ;

i f ( f i n d l - ' i i s t ( " . ' " , ! . w \ n , ' i i ! i ' I t . l D i ] i - i ' l H I ;, a x , li)


I
Memol->Li in.' - / . i m u e i " , : " U n t T o S u ( s r . ! . ' i ; e ) ) ;
w h i l e (FindNux(.(r> =-- 0)
!iemol->Lines->Add (sr .Name+", -. " + lntToStr (sr . Size) ) ;
i

FindClose(sr);

, , i findfirst findnext.
|| ffblk:
struct ffblk (
long
long
unsigned long
unsigned short
unsigned shoxt
char

f preserved;
ff_fsize;
ff_attrib;
ff_ftime;
ff fdate;
ff_name[256];

//
//'
//
//
//

ff_attrih FA_..., dos.h . 16.5.1. ff_ftime ff_fdate


. ff_ftime 0-4 , .5-10 , 11-15 . ff_fdate 0-4
, 5-8 , 9-15 , 1980.
, findfirst findnext, FindFirst FindNext.
FileSearch DirList Name.
IMrList , . ( , ). , .
searchpath file , PATH. NULL.
FileExists , .
fnmerge path : drive, dir, name ext.
drive:\path\name.ext.
(dir, path, name, ext) NULL. . fnsplit : .
DirectoryExists , Name. Name
, . Name .
CreateDir ForeeDirectories
Dir. ForeeDireetories
, , , . ,
ForeeDirectories (": WTeslWTestl") ;

Testl, Test, . , , DirectoryExists.


getcurdir GetCurrentDir
.
API Windows GetSystemDirectory, , Windows. ,
, , . -

- || . ' , GetWindowsDirectory,
Windows. Windows,
.ini ..
. .
, ,
, ,
.
.
ipBuffer GetSystemDirectory GetWindowsDirectory ,
.
"\". .
uSize . _.
lpBuffer
, . ,
uSize, .
,
. , GetLastError (.
. 16.7.5).
. Windows WINDOWS\
SYSTEM :, -
char s[_);
GetSystemDirectory(s,MAX_ PATH);

s : C:\WINDOWS\SYSTEM. , , , , .
FileGetAttr, FileSetAttr, _rtl_chmod (. . 16.5.1). . FileGetAttr _rtl_chmod
.
_rtl_chmod
(. . 16.5.1). func = 0
path, func = 1 path attrib.
, ,
SFile, :
_rtl_chraod(SFile,

I,

FA_HIDDEN);

FileGetAttr _rtl_chmod .
,
SFile, :
int attrib = _rtl_chmod(SFile, 0 ) ;
rtl_chmod(SFile,~1, dttrib I FA HIDDEN);


Memol SFile:
int a t t r i b - _rtl_chmod (SFile, 0) ;
if ( a t t r i b == -1)
{

Memcl->Lines->Add(" " + intToStr(errno));


return ,

if (atlrit,. 5, FA RDONLY)
Memol->Lines~>Add(SFile
if Jattxib & FA_HIDDEN) .
Memcl->Lines->Add(SFile
if (attrib S FA^SYSTEM)
Memol->Lines->Add(SFile
if (attrib S FA_DIREC)
Memol->Lines->Add(SFile
if (attrib S FA_ARCH)
Memol->Lines->Add(SFile

+ " - ");
*- " - ");
+ " - ");
+ " - ");
+ " - ");

FileAge, FileGetDate FileSetDate


DOS. Time
TSearchRec, FindFirst FindNext.
TDateTime
FileDateToDateTime. . . 16.3.2, .
getftime , handle ( fileno), ftime, ftimep. setftime : , ftimep. .
EACCES. , . .
0. - 1 , ;
EACCES
EBADF
EINVFNC

ftime :
1

struct ftime {
unsigned ft_tsec:
unsigned ft_min: 6;
unsigned f t h o u r :
unsigned ft_day:
unsigned ft__month:: 4;
unsigned ft_year: 7;
in

//
//
//
//
//'
// - I960

};

Test.txt,
1 ( , 1)
:
FILE 'stream;
std:;ftime ft;
char buffer[80];
if ((stream - open ( "TEST . TXT", "r+t")) =--- NULL)

I
I

ShowMessage(" ");
return;

getftime(fiieno(stream), Sft);
//
s-printf (buffer, " : %u/%u/%u",
ft.ft_day, ft.ft_month, ft.ft_year+1980);
ShowMessage(buffer);
ft.ft_day--;
'/
:;etf time (fileno (stream) , Sft);
<'/
tclose(stream);

16.6
16.6.1
/

process.h

_c_exit

void _c_exit(void)
, exit, no
,

_cexit

void _cexit(void)
, exit,
,
,

_exit

void _exit(int status)


stdlib.h
, exit
, ; status

stdlib.h
void ahort(void)

stdlib.h
int atexit(void (_USERENTRY * func)(void))
func; 0

abort
atexit

process.h

exit

stdlib.h
void exit(int status)
, , , atexit ; status

raise

int raise(int sig)


sig; 0

signal.h

atexit . exit _cexit.



, ,
.. ,
atexit (Exitl);
, :
void

Exitl(void)

32 .
,

i , ..
, i ' .
i exit . exit. , III11. , , |.| ,
ti'\it . status exit
.
I ( ,
exit, .

xit

+
+

ivvit

(exit

|+

+
-

exit

j+

abort .4IGABRT. ,
abort Abnormal program termination
bldurr _exit 3.

16.6.2 exec...
spawn...
/

cwait

int cwait(int *statloc, int pid, int action);


, statloc ,
ID -1

process.h

excel

int execl(char *path, char *argO, *argl, ..., *argn, NULL) process.h
path
argO - argn

cxcclc

int execle(char *path, char *argO, *argl, ...t *argn, NULL, process.h
char **env
path
argO - argn env

exeelp

int execlp(char *path, char *argO,*argl, ..., *argn, NULL) process.h


path
argO - argn, PATH

execlpe

int execlpe(char *path, char *argO, *argl, ..., *argn,


NULL, char **env)
path
argO - argn, PATH env

process.h

/
execv
int execv(char *path, char *argv[])
path
argv[]

process.h

execve

int execve(char *path, char *argv[]; char **env)

path
argv[] env

process, h

cxecvp

int execvp(char *path, char *argv[])


path
argv[], PATH

process.h

execvpe

int execvpe(char *path, char *argv[], char **env)


path
argv[], PATH env

process.h

spawnl

int spawnl(int mode, char *path, char *argO, argl, ..., argn, process.h,
NULL)
stdio.h
mode path
argO - argn

spawnle

int spawnle(int mode, char *path, char *argO, argl, ..., argn, process.h,
NULL, char *envp[])
stdio.h
mode path
argO - argn envp

spawnlp

int spawnlp(int mode, char *path, char *argO, argl, ..., argn, process.h,
NULL)
stdio.h
mode path
argO - argn, PATH

spawnlpe

int spawnlpe(int mode, char *path, char *argO, argl, ...,


argn, NULL, char *envp[])
mode path
argO - argn, PATH envp

process.h,
stdio.h

spawnv

int spawnv(int mode, char *path, char *argv[])


mode path
argvf]

process.h,
stdio.h

spawnve

int spawnve(int mode, char *path, char *argv[],


char *envp[])
mode path
argv[] envp

process.h,
stdio.h

spawnvp

int spawnvp(int mode, char *path, char *argv[])


mode path
argv[], PATH

process.h,
stdio.h

spawnvpe int spawnvpe(int mode, char *path, char *argv[],


process.h,
char *envp[])
stdio.h
mode path argvf]. PATH envp

IJTPltrin

wail

/
stdlib.h
int systDm(const char *command)
command

process.h
int wait(int *statloe)
, statloc , ID -1

exec... path, . . , .
exec... ,
:
I

argO, argl
argn. , .

argvf] argO, argl, ..., argn. , .

, PATH. path , ,
, PATH.
, .
env, .
, .

exec...
(argO), path. , . (
, ) 128 .
1 . . NULL,
.
v , , .
NULL, , .
env , .

< > = <>

env = NULL, , ,
.

, , . ,
( ).
, , . 16.5.2 16.5.3.
path, exec..., . path
, , . , , . , . . ,
.com .
(
path). , , PATH.
0 ,
- 1 . (. .
16.1.3.1) EACCES ,
EMFILE , ENOENT
, ENOEXEC , ENOMEM .
.
if(execl ("F1.","Fl.exe", NULL))
ShowMessage(" Fl.exe ");


Fl.exe. .
execl -1 ShowMessage. , , Fl.exe
.

execlp ( " n c " , " n c " , NULL);

Norton Commander ( .),


PATH.

char * prog = "command.com",execlp[prog,prog, NULL); ,


DOS, command.com PATH.

e x e c l p ( " W i n W o r d " , " W i n w o r d " , " F . d o c " , NULL) )

Word F.doc.
Word :
char *arg[5] = ("WinWord"); //
arg[l] = "Fl.doc";
arg[2] - " F 2 . d o c " ;
execvp(arg[0],arg);

arg
Winword, NULL. 1 2
Word . NULL.
execvp Winword
.
, spawn..., , : cwait wait.

wait
. , .
statloc wait NULL, , .
:
0-7
8-15

.
. , exit
return main.
main return, .

:
0-7

1
2
3

8-15

wait . 1,
EINTR , ECHILD .
cwait wait, .
statloc, : pid action. pid 0, , . pid . .
action : WAIT_CHILD
, WAIT_GRANDCHILD
,
, .
spawn....
exec..., mode, .
:
P_WAIT

,
.

P_NOWAIT

. ID , cwait wait, . 16- Windows DOS.

PJSTOWAITO P_NOWAIT, ID ,
cwait wait .

P_NOWAITO,
,
.
OVERLAY . ,
exec...
P DETACH

.
if(spawnlp(P_WAIT,"arj","arj","e doc.arj
al.txt",
ShowMessage(" a r j "),else

NULL))

Memol-XUear () ;
Meraol->Lines->LoadFromFile("al.txt") ;
DeleteFile("al,txt");
}
arj, doc.arj al.txt. , arj , Memol .
, , . , :
if(spawnlp(P_WAIT,"arj","arj","e","doc.arj", " a l . t x t " , NULL))
, ,
exec..., . spawn... , P_WAIT,
, . , P_NOWAIT, cwait wait:
int

I D = s p a w n l p ( P _ NOWAIT,"arj", " a r j " , " e d o c . a r j


NULL) ;
i f (ID -== - 1 )
ShowMessage(" a r j " ) ;

al.txt",

else
{

if (wait (NULL) != ID)


ShowMessage (" '") ;
else
1
Memol->Clear(3;
Memol~>Lines->LoadFromFile("al.txt") ;
DeleteFile("al.txt");

spawnlp _ NOWAIT, . wait, . , , .


system command . command , DOS (batch) . , -

. DOS, Windows
. system 0
-1 . :
// DOS dir
// dir.txt
systemfdir dir.txt");
-'/'

DOS

tnkdir,

c ; \ \ t t t

systemC'mkdir c:\\ttt");

,,

/' / Norton Commander


system("nc");

16.6.3 API Windows



. 7, .
7.2. API Windows.
16.6.3.1
32,
. ( Windows 95,
98, 2000 NT ):

,

.
ERROR_FILE_NOT_
FOUND

ERROR_PATH_NOT
FOUND

SE_ERR_
ACCESSDENIED

,
.

.

SE ERR OOM

ERROR_BAD_
FORMAT

Windows.
.
Windows,
. .

10
11

12

13

MS-DOS
4.0.

f """ "

14

15

, Windows.

16

, ,
.

19

.
, .

20

DLL, .

21

32- Windows.

26

SE_ERR_SHARE

27

SE ERR
AS SOCINCOMPLETE

,
.

28

SE_ERR_DDETIMEOUT DDE - .

29

SE_ERR_DDEFAIL

DDE

30

SE_ERR_DDEBUSY

DDE , DDE.

31

SE_ERR_NOASSOC

,
, , .

32

SE ERR
DLLNOTFOUND

DLL.

16.6.3.2 ShellExecute

ShelLAPI

HINSTANCE ShellExecute (
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd

//
//
//
/'/
/'/
//

ShellExecute Windows.
,
. , ,
.doc, Word. , ,

flit'.doc Word
file.doc. ShellExocute . , .
:
~"

hwnd

, .

lpOperation

,
. open () print ().
Windows 95, 98 NT : explore
() . lpOperation NULL, open.

lpFile

,
.

lpParameters ,
, FileName . lpFile
, , NULL.
lpDirectory

,
.

nShowCmd

, .
:
SW_HIDE

SWJMINIMIZE

()
Z-

SW_MAXIMIZE

()

SW_RESTORE

.
, ( ,
SW_SHOWNORMAL)

SW_SHOW

SW SHOWDEFAULT

Windows 95, 98, 2000 NT.



SW_ STARTUPINFO,
CreateProcess , . ShowWindow
,

SW SHOWMAXIMIZED
SW SHOWMINIMIZED

()

SW SHOWMINNOACTIVE

(
). ,

SW_SHOWNA


.
,

. ,

SW SHOWNOACTIVATE
SW SHOWNORMAL

( )

.
, ( ,
SW_RESTORE)

DDE . 32,
. . 16.6.3.1.
ShellExecute . 5.6.3 7.2.2.
16.6.3.3 FindExecutable
,
ShellAPI

HINSTANCE FindExecutale(
LPCTSTR lpFile,
/'/' v
LPCTSTR lpDirectory,
//
LPTSTR lpResult
//

FindExecutable .,
, lpFile. lpDirectory . . lpResult
, , lpFile.
FindExecutable ,
32. , .
. 16.6.3.1.

char APchar[254J;
Fi.dExecu table("Doc.dec",NULL, APchar);
Lab'rll->Capt ion => APchar;

, Label 1 ,
.doc, :
C:\M3OFFICE\WINWORD\WINWORD.EXE

16.6.3.4 WinExec

UINT WinExec(
LPCSTR lpCmdLine, //
UINT uCmdShow
//'
);

WinExec .
lpCmdLine , , , .
, Windows
:
1. , .
2. .
3. Windows, GetSystemDirectory.
4. Windows, GetWindowsDirectory.
5. PATH.
uCmdShow
Windows. . . 16.6.3.2.
Windows, PIF ..
; .

WinExec , 31. ,
. . 16.6.3.1.
WinExec Windows. WIN32, Win32
CreateProcess ( . -f+Builder ).
Win32 WinExec , GetMessage
1'. , , , i'iiHOM WinExec, GetMessage.
ShellExecute 7.2.3.

.7
16.7.1

_nisi/c

size_t _msize(void *block)


block,
malloc, calloc,
realtor; 32-

malloc .h

_new_handler

typedef void (*pvf)();


new.h
pvf _new_handler
, new
void *alloca(size_t size)
malloc. h
size ; NULL
void * AllocMem(Cardinal Size)
SysUtils.hpp
Size
(void *) ;
FreeMem

alloca

AllocMem

calloe

free

GetMemoryManager

malloc

realloe

set_new_
handler

void *calloc(size_t nitems, sizc_t size)


stdlib.h
nitems size ;
NULL
void free(void *block)
stdlib.h
block,
calloe, malloc, realloe
void GetMemoryManager(
System, hpp
TMemoryManager &MemMgr)
MemMgr
,
void *malloc(size_t size)
stdlib.h alloc.h
size; NULL
void *realloc(void *block, size_t size)
stdlib.h
block,
malloc, calloe, realloe,
size;
NULL
typedef void (new * new_handler)();
new.h
new_handler set_new_handler(
new_handler my_handler)
my_handler,
new

SetMemoryManager

void SetMemoryManager(
System.hpp
const TMemoryManager &MemMgr)
MemMgr ,

SysFreeMem

extern PACKAGE int SysFreeMem(void * P) System.hpp


ShareMem.hpp
,


Syt<GetMem

SysReallocMem

THeapStatus

! < /
xtr>rn PACKAGE void * SysGctMem(int Size)
Size,
; NULL
extern PACKAGE void * SysReallocMem(
void * P, int Size)

Size, ;
NULL
System::THeapStatus GetHeapStatus(void)
heap
THeapStatus

System.hpp
ShareMem.hpp

System.hpp
ShareMem.hpp

System.hpp
ShareMem.hpp

,
System.hpp ShareMem.hpp, System.hpp ,
, ShareMem.hpp
, , .
heap. : malloc, calloc,
realloc, free new delete (. . 13, . 13.9).
malloc heop size . .
size = 0, NULL.
calloc nitems , size. nitems * size. .

. size = 0
nitems = 0, NULL.
realloc . heap, block, size. , block , malloc, calloc realloc. block
NULL, realloc , malloc.
size , ,
block, , NULL. ,
size 0 ,
, .

, realloc NULL. , . block,


.
free , malloc,
calloc realloc, block.
.
malloc , , - - , ..

t i i n ; 1 U(ii_- -.stdi . h>

include <alloc.h>
char *str;

// str - ,

str =

(char *)

malloc(100);

//
free (str) ;


calloc:
str = (char *) calloc(100, sizeof(char));

malloc calloc , , :
str =

(char *)

realloc(str,

20);

, :
realloc(str,

20);

, NULL (0),
. , , , NULL.
.
_new_handler , new. . . ,
.
, _new_handler, set_new_handler. set_new_handler(O) . . :
( )
bad_alloc
bad_alloc
abort exit
set_new_handler .
. ,
:
pvf set_new_handler(pvf p) ;
THeapStatus
THeapStatus, :
TotalAddrSpace

,
. .

TotalUncommitted

TotalAddrSpace, .

TotalCommitted

TotalAddrSpace,
. TotalUncommitted + TotalCommitted = TotalAddrSpace.

To till Allocated
TotalFree

FrocSmall
FrecBig

Unused
Overhead
HeapErrorCode

.
, .

, OS . TotalAddrSpace.
,
.
,
.

.
, . : Unused + FreeBig +
FreeSmall = TotalFree.
, .
.

TotalAddrSpace, TotalUncommitted TotalCommitted , . Total Allocated TotalFree ( heap).


TotalAUocated TotalFree.
SetMemoryManager ,
, . MemMgr TMemoryManage.
TMemoryManage :
,
Size
( malloc). Size GetMem
. GetMem
, NULL.
, , FreeMem
, ( free).
FreeMem NULL. FreeMem
, 0. .
RealiocMem , , , Size
( realloc). , -
RealiocMem, NULL, Size
0. RealiocMem
, ,
.. . , , , utioiii.
N1)1.1., (n
i 11. .

GetMem

, SetMemoryManager, , , .. GetMemoryManager Manager, .


.

16.7.2
16.7.2.1 ShowMessage ShowMessageFmt

, - ,
: , , , .
, , ..
.
ShowMessage,
. :
void ShowMessage(const System::AnsiString Msg)

Msg. .
ShowMessageFmt,
. :
void ShowMessageFmt(const System::AnsiString Msg,
const System::TVarRec *Params, const i n t Params_Size)

Msg (. .
16.1.2.3), Params Params_Size , Msg, .
O P E N A R R A Y ( C M . . 16.7.4).
ShowMessageFmt :
ShowMessageFmt(Msg,OPENARRAY(TVarRec,(argl,arg2,...)));
1

.
ShowMessage(" .");
ShowMessageFmt(" %d %d ",
OPENARRAY(TVarRec,

(N1,N2)));

. 16.1 , (),
() N1 = 5, N2 = 7.
. 16.1
,
ShowMessage (a)
ShowMessageFmt (6)

16.7.2.2 MessageDIg, MessageDlgPos CreateMessageDialog


. 16.7.2.1 , , , . , - -

. MessageDlg. :
i n t MessageDlg(const System::AnsiString Msg,
TMsgDlgType DlgType,
TMsgDlgButtons Buttons, i n t HelpCtx)

MessageDlg . Msg.
DlgType.
:

mtConfirmation

,
(. . 16.2 )

mtlnformation

, i (.
. 16.2 )

mtError

, - (.
. 16.2 )

mtWarning

,
(. . 16.2 )

mtCustom

. -
(. . 16.2 )

. 16.2
)

^ ^ ?
,

MessageDlg

AButtons , .
TMsgDlgBtns AButtons ,
. :

mbYes

Yes

mbNo

No

mbOK

OK

mbCancel

Cancel

mbHelp

Help

mbAbort

Abort

mbRetry

Retry

mblgnore

Ignore

mbAll

Buttons " " , Buttons . ,


Windows.
, , ,
:
'

mbYesN oCancel

Yes, No Cancel

mbOkCancel

Concel

mbAbort Retrylgnore

Abort, Reiry Ignore

TMsgDlgButtons Buttons.
HelpCtx ,
.
F1. , MessageDlg HelpCtx.
MessageDlg , . :
mrNone mr Abort
mrOk
mrRetry
mrCancel mrIgnore

tnrYes
mrNo
mrAll

MessageDlg. :
if(MessageDlg(" ?",
mtConf irmation, TMsgDlgButtons () << mbYes<< mbtlo,
0) == mrYes)
MessageDlg(" ", mtlnformation,
TMsgDlgButtons() << mbOK, 0 ) ;
Close () ;
MessageDlg mtConfirmati (. . 16.2 ). Yes, mtlnformation
(. . 16.2 ).
(.
. 16.2 16.2 ):

r.rch ( . . . i

MessageDUj (" . " , m t E r r o r ,


TMsgDlgButtons() mbOK, 0) ;
M e s s a g e D l g ( " . " , mtWarning,
TMsgDlgButtonsU mbOK, 0) ;

,
(. . 16.2 ). Yes, -Post; No, Cancel;
Concel, .
switch (MessageDlg(" . ?", mtCustom,
mbYeslioCancel, 0) )
t
c a s e mrYes: T a b ! e l - > P o s t ( ) ;
break;
c a s e mrNo ; T a b l e l - > C a n c e l ( ) ;
break;
Cc4s<? mrCancel : C l o s e ( } ;

MessageDlgPos, MessageDlg,
.
:
int MessageDlgPos(const System::AnsiString Msg,
TMsgDlgType DlgType, TMsgDlgButtons Buttons,
int HelpCtx, int X, int Y)

MessageDlgPos
. X Y. MessageDlg. ,
MessageDlgPos(" .", mtWarning,
TMsgDlgButtons() mbOK, 0, 250, 0);

( Y=0) .
MessageDlgPos(" !", mtError,
TMsgDlgButtons() mbOK, 0,
BoundsRect.Left,BoundsRect.Bottom) ;

,
.
CreateMessageDialog, :
extern PACKAGE Forms::TForm* CreateMessagaDialog(
const System: :AnsiString Msg, TMsgDlgType DlgType, >,
TMsgDlgButtons Buttonsl

. , .
Show ShowModal. ShowModal
, .
DlgType Buttons
TMsgDlgType TMsgDlgButtons .
CreateMessageDialog . , . .
:>'roit . , KOTopi.ii' . -

, , , . CreateMessageDialog , ,
Free. .
CreateMessageDialog.
TForm *FMess;
FMess = CreateMessageDialog (" .", mtWarning,
TMsgDlgButtons() << mbOK);
FMess->Caption = "";

FMess , .
. (. 16.3)
. 16.2 ,
Warning.
FMess->ShowModal() ;

.
FMess->Free() ;

'

, .
. 16.3
, CreateMessageDialog

16.7.2.3 TApplication->MessageBox
. 16.7.2.1 16.7.2.2
( ) (
CreateMessageDialog). MessageBox Application TApplication, ++ilder. , .
, .
:
int

fastcall MessageBox(const char * Text,


const char * Caption, int Flags);

, .
, MessageDlg CreateMessageDialog. , . -,
MessageDlg (, , CreateMessageDialog, ).
( Windows).
MessageBox MessageBox API Windows.
Text ,
255 .
. Caption .
255 , .
.

Flatf ,
.
.
,

( Windows)

MB_ABORTRETRYIGNORE

Abort (), Retry () Ignore ().


. .

_
MB_OKCANCEL

Concel ().
Retry () Cancel ().

MB RETRYCANCEL
MB_YESNO

Yes () No ().
Yes (), No () Cancel ().

MB_YESNOCANCEL

MB ICONEXCLAMATION (, ).
, MB_ICONWARNING
MB ICONINFORMATION, i ().
MB_ICONASTERISK
MB_ICONQUESTION
( ).
MB ICONSTOP,
MB ICONERROR,
MB ICONHAND

(, ).

, ( )

. .

MB_DEFBUTTON1
MB DEFBUTTON2
MB_DEFBUTTON3
MB_DEFBUTTON4

.
v

.
.

MB_APPLMODAL

,
. .
. .

MB_SYSTEMMODAL

, MB_APPLMODAL,
WS_EX_TOPMOST,
, . , .

( )

MB_HELP

Help (),
F1 Help.

MBJTOPMOST

( WS_EX_TOPMOST).

,
,
( ) ..
,
. , :

IDABORT

Abort ().

IDCANCEL 2

Cancel ()

IDIGNORE 5

Ignore ().

IDNO

No ().

Esc.

' '

IDOK

IDRETRY

Retry ().

IDYES

Yes ().

. ,
.
if
(

(
if

(Application->MessageBox(
" ?",
" ",
MB_YESNOCANCEL + MB_ICONQUESTION) != IDYES)
{
DataSet->Cancel();
Abort();

else
Application->MessageBox("
Abort ;

","",

MB

ICONSTOP);

. 16.4.
, , .
. 16.4
,

Application->MessageBox

16.7.2.4 InputBox InputQuery


, ,
, .
,
,
- .
InputBox Dialogs :
extern PACKAGE AnsiString

f a s t c a l l InputBox(
const AnsiString ACaption,
const AnsiString APrompt,
const AnsiString ADefault);

(. . 16.5)
ACaption, APrompt -
,
ADefault. ,
. Concel, Esc,
, ADefault,
- .
,
AnsiString Name = InputBox(", ",
", ",
"");

, . 16.5, , , .
. 16.5
, InputBox

Cancel

, -
, , , ADefault. , , , .
, , ,
InputBox InputQuery:
extern PACKAGE bool

fastcall

InputQuery(
const AnsiString ACaption,
const AnsiString APrompt,
AnsiString SValue);

ACaption APrompt , InputBox. Value . , InputQuery Value .


InputQuery true ,
, . ( Esc,
Concel) false,
Value , InputQuery.
, :
AnsiString Name = "";
I f ( ! InputQuery(", ",
", ", Name))
ShowMessage(" , ");
e l s e ShowMessage(", "+Name+" ! " ) ;
, . 16.5
, , , .

16.7.2.5 SelectDirectory, LoginDialog, LoginDialogEx



. - . [1] [3].
SelectDirectory
. FileCtrl
. ,
:
extern PACKAGE bool
fastcall SelectDirectory(
const AnsiString Caption,
const WideString Root,
AnsiString SDirectory);
Caption ,
. Root , . Root
. Root ,
.
Directory . true, . , , false.
LoginDialog LoginDialogEx Windows,
.
LoginDialog Dblogdlg :
extern PACKAGE bool
fastcall LoginDialog(
const AnsiString ADatabaseMame,
AnsiString SAUserName,
AnsiString iAPassword);
ADatabaeeName , ,
. AUserName ,
. LoginDialog
User Nome. AUserName , , , .

APassword , ,
.
LoginDialog true, ,
.

, ,
. , false.
, LoginDialog,
, User Name. LoginDialogEx
. :
extern PACKAGE bool

fastcall
LoginDialogEx(
const AnsiString ADatabaseName,
AnsiString SAUserNarne,
AnsiString iAPassword,
bool NameReactonly);

LoginDialog NameReadOnly. true, User Nome, -


AUserName , .
LoginDialog LoginDialogEx
[^ .
. , , , .

16.7.3

/
extern PACKAGE void Beep(void)
C++Builder,

SysUtils.hpp

BOOL Beep(DWORD dwFreq,


DWORD dwDuration);
API Windows, Windows NT/
2000/XP, dwFreq dwDuration

MessageBeep

BOOL MessageBeep(UINT uType);


API Windows, uType

PlaySound

mmsystem.hpp
BOOL PlaySound(LPCSTR pszSound,
HMODULE hmod, DWORD fdwSound)
API Windows,
, ,

C++Builder Beep , MessageBeep API Windows . , Windows, (

).
,
.
, ..
.
API Windows, Windows NT/2000/XP, . Windows NT dwFreq . 37 32,767 ( 0x25 0x7FFF).
dwDuration .
: .
Windows NT/2000/XP. Windows 95 98
++ilder. , C++Builder
, API Windows . . GetLastError (. . 16.7.5).
, , .
MessageBeep . , ,
[sounds] .
MessageBeep . :

OxFFFFFFFF

MB ICONASTERISK

MB ICONEXCLAMATION

MB ICONHAND

MB_ICONQUESTION

MB_OK

(true).
,
- GetLastError (. . 16.7.5).
MessageBeep .
MessageBeep , .
, .
PlaySound API Windows
, , .
pszSound
. fdwSound
(SND_FILENAME, SND_ALIAS SND_RESOURCE) pszSound , . ,

Windows WIN.INI . , . , pszSound


.
, pszSound, . PlaySound : , Windows, Windows, , PATH, , .
OpenFile.
, PlaySound . , , false.
pszSound 0, . ,
, SND_PURGE fdwSound.
hmod fdwSound SNDJRESOURCE. hmod , , . hmod 0.
fdwSound . "|".
:
SND_ALIAS

pszSound
Windows WIN.INI.
SND FILENAME
SND RESOURCE.

SND_ALIAS_ID

szSound .
SNDAPPLICATION .
SND_ASYNC

PlaySound
.
, PlaySound
pszSound, 0.

SND_FILENAME
SNDJLOOP

pszSound .
,
PlaySound pszSound, 0.
SND_ASYNC .

SND_MEMORY

.
pszSound
.

SND_NODEFAULT

, . , PlaySound , .

SND_NOSTOP

, ,
, 1 , PlaySound false,
. , PlaySound
,
.

SND_NOWAIT

, .

SND_PURGE

, . pszSound 0, . pszSound 0, ,
.
SND RESOURCE.

SND_RESOURCE

pszSound .
hmod .

SND_SYNC

.
PlaySound .

PlaySound true,
false.
PlaySound . 6, . 6.2.1.

16.7.4 C++ C++Builder

ARRAYSIZE

ARRAYSIZE(const void *a)


sysdefs.h

bsearch

void *bsearch(const void *key, const void *base,


size t nelem, size t width,
int (_USERENTRY *fcmp)
(const void *, const void *))
key () base nelem width
fcmp; 0

stdlib.h

EXISTINGARRAY

EXISTINGARRAY(const void *a)



sysdefs.h

getenv

char *getenv(const char *name)



name

stdlib.h


/
Controls.hpp
extern PACKAGE System::AnsiString
GetLongHint( const System::AnsiString Hint)
, Hint
Controls.hpp
GetShortHint extern PACKAGE System: :Ansi String
GetShortHint(const System::AnsiString Hint)
, Hint
stdlib.h
void *Ifind(const void *key, const void *base,
lfind
size t *num, size t width,
int (_USERENTRY *fcmp)
(const void *, const void *))
key () base num width
fcmp;
0

GetLongHtnt

lsearch

void *lsearch(const void *key, void *base,


size t *num, size t width,
int(_USERENTRY *fcmp)
(const void *, const void *))
key () base num width
fcmp;
, ;

OPENARRAY OPENARRAY(type argl, ..., type argl9)
, 19
Param Count extern PACKAGE int fastcall ParamCount(void);

extern PACKAGE AnsiString
fastcall
ParamStr
ParamStr(int Index);
Index
int putenv(const char *name)
putenv
name
void qsort(void *base, size t nelem, size t width,
qsort
int (_USERENTRY *fcmp)
(const void *, const void *))
() base nelem width
fcmp
Shortcut
extern PACKAGE TShortCut ShortCut(Word Key,
Classes::TShiftState Shift)
,
Key Shift

stdlib.h

sysdefs.h

System.hpp
System.hpp

stdlib.h
stdlib.h

Menus.hpp

ShortCutToText

extern PACKAGE System::AnsiString


Menus, hpp
ShortCutToText(TShortCut Shortcut)
Shortcut,
,

void swab(char *from, char *to; int nbytes)
stdlib.h
nbytes from to,

Menus.hpp
extern PACKAGE TShortCut TextToShortCut(
System::AnsiString Text)
Text ,

type va_arg(va_list , type)
stdarg.h
type ;

va_start va_arg

swab

TextToShortCut

va_arg

void va_end(va_list )
stdarg.h
, va_start va_arg
va_start
void va_start(va_list , lastfix)
stdarg.h
, ,
; lastfix

-_ - - - -

va_end

va_start, va_arg va_end ,


.
. :
( , . . .)
( ),
. stdarg.h : va_start, va_arg, va_end
va_list.
va_start ,

. lastfix
.
va_arg . type . va_arg

va_start va_arj(. v*_arg


. .
va_end , .
, va_arg .
.
. . 13, . 13.5.5.
EXISTINGABRAY, ARRAYSIZE, OPENARRAY
. .
. 14, . ,14.10.3.
. 16.3.1.2.
bsearch, Ifind, lsearch, qsort (). base , nelem num ,
width , , fcmp , , .
bsearch () , key. , ,
.
fcmp :
*eleml *elem2. ,
, :
<0
== 0

*eleml == *elem2

> 0

*eleml > *elem2

*eleml < *elem2

< , *eleml *elem2, > , *eleml


*elem2, , . , , , , .
qsort , . ,
.
qsort bsearch.
array . fcmp , qsort bsearch. Buttonl
qsort,
bsearch , Editl.
#include <:malloc.h>
#include <scdlib.h>
int array[] = (800,123,512,627,933,145);
int fcmp (const void *pl, const void *p2)
( return (* (int*)pl - *(int*)p2); 1
void
fastcall TForml; :ButtonlClicMTObject 'Sender)
I
int key - StrToInt(Editl->Text);
int *elem;
qsortiarray, ARRAYSIZE(array),sizeof(int), temp};

elem - (int *) bsearch (Skey, array, ARRAYS!^ (array) ,


sizeof(int), fcmp);
if(elem == 0) ShowMessage("
" + IntToStr(key) +
11
") ;
else ShowMessage(" " + IntToStr(*elem) +
" " + IntToStr(elem- array));
)
lfind lsearch . , , . , lsearch, , . lfind lsearch
. , .
lsearch, . array .
fcmpl . Button 1 , Editl.
, .
#include <malloc.h>
#include <stdlib.h>
int array[10] = {800,123,512,627,933,145};
unsigned Narray = 6;
int fcmpl (const void *pl, const void *p2)
{ return (* (int*)pl != *(int*)p2); )
void
{

fastcall TForml::ButtonlClick(TObject *Sender)

int key = StrToInt(Editl->Text);


int *elera;
elem = (int *) lsearch (Skey, array, SNarray, s i z e o f ( i n t ) , fcmpl);
ShowMessage("
" + IntToStr(key) +
11
" + IntToStr (elem- array) ) ;
}

GetShortHint GetLongffint

< >I< >
, , Hint (.
. 17 . 5, . 5.1.9).
getenv putenv .
name=string\O. getenv
name. getenv ,
, . ,

Labell->Caption = getenv("PATH"); '


La bell PATH.
DOS OS/2 . , .
,
NULL. getenv name getenv "name=",
name . ,
getenv("=");

PATH.

putenv . name namc-ntring. :


putenv ("PATII-c:\\temp") ;
Shortcut, ShortCutToText TextToShortCut Shortcut ,
. Shortcut Key, , Shift,
Shift, Ctrl All,
TShortCut, Word. TextToShortCut . Shortcut ,
TextToShortCut ,
.
ShortCutToText
Shortcut TShortCut. , .
ParamStr ParamCount .
ParamStr Index.
. ,
ParamStr(O) , , D:\\TEST\\PROJECT1.EXE, ..
, .
. , - , ,
.
-.
- , ParamStr(l), ParamStr(2) .. ,
. .
ParamCount , .
. ,
for (int i=l;i<=ParamCount();i++)
,
if (LowerCase(ParamStr(i)) = "-e")
( ),
- -.
, CmdLine (char *).
' ,
. CmdLine,
, , . . 1, . 1.9.3.

16.7.5 API Windows

CloseWindow
I)<^stroyWindow

/
BOOL CloseWindow(HWND hWnd)
, , , hWnd
BOOL DestroyWindow(HWND hWnd)
, hWnd,
,


EnableWindow

/
BOOL EnableWindow(HWND hWnd, BOOL bEnable)
( bEnable = true)
( bEnable = false) , hWnd

Find Window

HWND FindWindow(LPCTSTR lpClassName,


LPCTSTR lpWindowName)
lpClassName lpWindowName

GetLastError

DWORD GetLastError(VOID)

GetNext Window HWND GetNextWindow(HWND hWnd, UINT wCmd)


hWnd Z-
GetWindow

HWND GetWindow(HWND hWnd, UINT wCmd)


, hWnd wCmd
-t

GetWijjdpwText

int GetWindowText(HWND hWnd, LPTSTB ipString,


int nMaxCount)
.,.>
,
hWnd, IpString nMaxCount

'

API Windows , , hWnd.


FindWindow. , ;
.
lpClassName ,
, ,
. * , ,
Global Add Atom. 16- , lpClassName, a
.
lpWindowName , ( Caption ,
). NULL, ,
.
, "FindWindow
, . NULL.
GetNextWindow. Z-. hWnd , .
wCmd . wCmd = GWJHWNDNEXT,
, . wCmd = GW_HWNDPREV,
, .
Z- , .
, .

, . ( wCmd),
0. (|) GetLastError.
FindWindow GetNextWindow . . 7,
. 7.3.1.
GetNextWindow ,
GetWindow GW_HWNDNEXT
GW_HWNDPREV. GetWindow , ,
hWnd ( Z- ). uCmd :
GW_CHILD

Z-, . NULL.
,

GW_HWNDFIRST , Z-
GW_HWNDLAST , Z-
GW_HWNDNEXT Z-
GW_HWNDPREV Z-
GW_OWNER
,

, .
, 0. GetLastError.
GetWindowText ,
( )
hWnd, ipString nMaxCount. , .
, ,
Windows WM_GETTEXT. .
,
, . , .
GetLastError.
GetWindowText . . 7, . 7.3.1.
. ,
, , Handle. ,
Closewindow (Handle) ;

"

. . GetLastError.
GetLastError . .
GetLastError ,
. ,
SetLastError(O),
.
API Win32
,
. , FALSE, NULL, OxFFFFFFFF
1.
32- . 31. 29 , . . , , . .
,
FormatMessage.
WINNT.H Win32 SDK.
EnableWindow
.
, ,
. ,
, , .

16.8 Windows
Windows . 7, . 7.4. , . 7.

16.8.1 PostMessage

, , ,

BOOL PostMessage(
'
HWND hWnd,
// ,
//
UINT Msg,
/ /
WPARAM wParam, //
LPARAM lParam //
);

hWnd , .
HWND_BROADCAST,
, , , , . NULL,
( ) .
Msg . wParam
lParam ' .



. GetLastError.

PostMessage
, , , |
. PostMessage
SendMessage,
, . GetMessage PeekMessage.
WM_USER *,
PostMessage, SendNotifyMessage SendMessageCallback, ';,
, .
- , , , , , .

16.8.2 SendMessage

,

LRESULT SendMessage(
HWND hWnd,
// ,
//
UINT Msg,
//
WPARAM wParam, //
LPARAM lParam //

'

hWnd , .
HWND_BROADCAST,
, , , , .
Msg . wParam
lParam .

, , .

SendMessage , , . , . , , , .
SendMessage PostMessage, .
, hWnd = HWND_BROADCAST
RegisterWindowMessage.
SendMessage . 7, . 7.4.2.

*
'

16.8.3 RegisterWindowMessage

, SendMessage PostMessage.

UINT RegisterWindowMessage(
LPCTSTR l p S t r i n g
//
);

lpString , .

, OxFFFF. ,
.

,
. , .
Windows.
RegisterWindowMessage ,
.

WM_USER 0x7FFF.

16.8.4 Perform
TControl, Windows.

int

fastcall Perform(Cardinal Msg, int WParam, int LParam);

Msg , WParam LParam .

Perform API Windows, , , C++Builder. , .


Perform TMessage Msg,
WParam, LParam .
, Window. , Perform . ,
Form2->Perform(WM_CLOSE, 0, 0) ;

WM_CLOSE Form2, .

16.8.5 WM USER
..

WM_USER ,
Windows, .
:
0 WM_USER - 1
, Windows
WM_USER 0x7FFF

0x8000 OxBFFF
OxFFFF

, Windows
, , RegisterWindowMessage

OxFFFF

, Windows

WM_USER 0x7FFF
.
, , (, TButton, TEdit, TListBox TComboBox) . , .
WM_USER . 7, . 7.4.4.

16.8.6 Message

, Windows WndProc
Messages

Messages
struct TMessage
{
Cardinal Msg;
union
{
struct
{
Word WParamLo;
Word WParamHi;
Word LParamLo;
Word LParamHi;
Word ResultLo;
Word ResultHi;

I;

17
, , ,
,
, , ,
,
.
, , , ,
C++Builder, . ,
, ,
,
.
,
, , ,
. , ,
, , .
, , . [1], [3], [4].

17.1
Align
( )
TControl

enura TAlign { alNone, alTop, alBottora, alLeft, alRight,


alClient, alCustom };
typedef Set<TAlign, alNone, alclient> TAlignSet;
property TAlign Align

Align ,
, , , ,
, , , .
:

alNone
, .
. Align .
alTop
. .

17

1054
alBottom

. .

alLeft

. .

alRight

. .

alClient

. , .

alCustom

C++Builder 6. CustomAiignPosition CustomAlignlnsertBefore.

Align alNone. , , , Align.


Align, alClient,
, .
: Esc - .
Align alTop alBottom alLeft alRight. , , , ,
alLeft, alTop,
, . , , .
C++Builder 6 alCustom ()
TAlignSet . - Align = alCustom, -
CustomAiignPosition, , Align = alCustom Visible = true. (, C++Builder 6
):
v i r t u a l void

f a s t c a l l CustomAiignPosition(TControl* Control,
int sNewLeft, i n t SNewTop, i n t SNewWidth,
i n t SNewHeight, Types::TRect SAlignRect,
const TAlignlnfo sAlignlnfo);

Control . NewLeft,
NewTop, NewWidth, NewHeight , , . AlignRect , , . Align Info TAlignlnfo, :

, , , ,

1055

struct TAlignlnfo
f
Classes::TList* AlignList;
int Controllndex;
TAlign Align;
int Scratch;
);
,
:
v i r t u a l bool

fastcall

CustomAlignlnsertBefore(TControl* Cl,
TControl* C2);

CustomAlignlnsertBefore
Cl 2 , Align = alCustom Visible =
true, , , .. CustomAlignPosition
.
CustomAlignlnsertBefore Controls , 1
, 2 . , Panell, Pancl2
13, Controls ,
Cl = Panel2, C2 Panell, Cl = Panel3, C2 = 12,
1 = 13, 2 = Panell. true, 1 , 2 ( C+4-Builder 6 ).
TWinControl CustomAlignlnsertBefore false,
, Controls. . , true,
.

. 5, . 5.2 Align.
.
Panell 12 ,
Panell , 12 . .
. Align =
alCustom. :
:
class TForml : public TForm
{

published:
// IDE-managed Components
TPanel *Panell;
TPanel *Panel2;
void
f a s t c a l l CustomAlignPosition(TControl* Control,
i n t 4NewLeft, i n t 4NewTop, i n t &NewWidth,
i n t sNewHeight, Types::TRect SAlignRect,
const TAlignlnfo SAlignlnfo);
private:
// User declarations
public:
// User declarations
f a s t c a l l TForml(TComponent* Owner);

1056

17

:
void

fastcall

TForral::CustomAlignPosition(TControl* Control,
i n t SNewLeft, i n t sNewTop, i n t SNewWidth,
i n t SNewHeight, Types::TRect SAlignRect,
const TAlignlnfo sAlignlnfo)

{
Panell->Left = 0;
Panell->Top = 0;
Panel2->Top = 0;
NewWidth = ClientWidth / 2;
NewHeight *= ClientHeight;
if (Control == Panel2)
NewLeft = ClientWidth / 2;
)

CustomAlignPosition. ,
ClientWidth , , ClientHeight .
ClientWidth 12.
, , , OnResize (. ).
Bitmap
8 8 , Brush
TBrush

property TBitmap* Bitmap

Bitmap TBitmap. 8 8 ,
Brush.
BitMap,
, Style. BitMap , ,
.
8 8 ,
8 8.
TBitmap , Bitmap.
TBitmap , .

Graphics::TBitmap *MyBitraap = new Graphics::TBitmap;


try
{
MyBitmap->LoadFromFile("MyBitmap.bmp") ;
Imagel->Canvas->Brush->Bitmap = MyBitmap;
}
finally

, , , ,

Imagel->Canvas->Brush->Bitmap
delete MyBitmap;

1057

NULL;

MyBitmap TBitmap
"MyBitmap.bmp". Imagel>
Canvas>Brush>Bitmap . Imagel.
BitMap NULL, Style. MyBitmap , .
BoundsRect
, ,
TControl

struct TRect
{
int Left;
int Top;
int Right;
int Bottom;
};
property Windows::TRect

BoundsRect

BoundsRect TRect .
Left ( ), ( ), Width (), Height () . , :
Control->BoundsRect.Left
Control->BoundsRect.Top
Control->BoundsRect.Right
Control>BoundsRect.Bottom

Control->Left
*
Control->Top
Control->Left + Control-> Width
Control>Top + Control->Height

.
. , , BoundsRect.Left . , , . BoundsRect.
BoundsRect Rect (.
. 16.3.3, . 16), TRect.
, , ClientWidth ClientHeight. . Width Height.
, , , .
34 C-H-Buildei 6

1058

17

1. Panell (, Align = alTop).


StaticTextl StaticText, , . ' , OnResize OnShow :
StaticTextl->Left =
(Panell->BoundsRect.Left + Panell->BoundsRect.Right StaticTextl->Width) / 2;
, BoundsRect, :

StaticTextl->Left := Panell->Left + (Panell->Width StaticTextl->Width) / 2;


2. , Memol
.
Panell , , :
Memol->BoundsRect - Panell->BoundsRect;
3.
Panell 12. :
TRect rec;
rec = Panell->BoundsRect;
// Panell
Panell->BoundsRect = Panel2->BoundsRect; // Panell
Panel2->BoundsRect = rec;
// Panel2
4. BoundsRect Rect. Memol Panell, .
, Memol , Panell , 10 ( ), 40 ( ).
, OnResize Panell :
Memol->BoundsRect =
Rect(10,40,Panell->ClientWidth-10,Panell->ClientHeight-10) ;
5. BoundsRect .
BringToFront Visible.

Brush

TWinControl

property Graphics::TBrush* Brush

Brush () , Canvas.
, . . Brush , Color Style.
Assign.

, , , ,

1059

TBrush Brush. .
, . TBrush.
Canvas

(, )

TForm, TImage. TBitMap, TPaintBox


property Graphics::TCanvas* Canvas

Canvas TCanvas Brush, ,


.
TImage ,
Picture .
Picture , TBitMap.
Canvas EInvalidOperation. Picture , Canvas , , TextOut.

Charset
,
TFont

typedef Byte TFontCharset;

property TFontCharset Charset

Charset TFont.
, , . Charset
. , , Charset.
C++Builder ,
. , , ,
, . .

ANSI CHARSET

ANSI.

DEFAULT
CHARSET

.
Name Size.
,
Windows .

SYMBOL CHARSET 2

MAC CHARSET

77

Macintosh. NT 3.51.

GREEK CHARSET

161

. NT 3.51.

34-

17

1060

RUSSIAN
CHARSET

204

. NT 3.51.

EASTEUROPE
CHARSET

238

(,
) -
. NT 3.51.

OEM_CHARSET

255

TFont Charset, DEFAULT_CHARSET. , C++Builder ,


.
RUSSIAN_CHARSE.
,
DEFAULT_CHARSET .

. 4 . Font.

ClientHeight

TControl

property int ClientHeight

ClientHeight . ClientHeight , , ,
- (. . BoundsRect).
ClientRect.Bottom (. ClientRecti.
TControl ClientHeight Height. Height. ,
ClientHeight - , , ,
.

, Panel 1, ListBoxl,
. ,
OnResize :
ListBoxl->Height = Panell->ClientHeight - ListBoxl->Top - 20;

. 5.2 . 5.

ClientOrigin

TControl

, , , ,

1061

struct TPoint
{

int
int
);

x;
;

property Windows::TPoint ClientOrigin

ClientOrigin
. TPoint.
.
ClientOrigin , TWinControl (.. ), (-),
Left . , ClientOrigin ElnvalidOperation.
ClientRect

TControl

struct TRect
{

int Left;
int Top;
int Right;
int Bottom;
);
property Windows::TRect ClientRect

ClientRect TRect.
.
Left , Right Bottom
ClientWidth ClientHeight. ClientRect
Rect (. . 16.3.3, . 16) Rect(0, 0, ClientWidth, CHentHeight).
, ,
.
ClientWidth

TControl

property int ClientWidth

ClientWidth . ClientWidth ,

1062

17

, , - (. . BoundsRect),
ClientRect. Right (. ClientRectV
TControl Client Width Width. Width ,
.
ClipRect
(
, OnPaint.
TCanvas

struct TRect
(
int Left;
int Top;
int Right;
int Bottom;
};

property windows::TRect ClipRect

ClipRect
, . ClipRect .
OnPaint , . .
Color
, TFont .
TControl

property Graphics: -.Tcolor Color

Color
TFont. , , RGB (. . TColor),
C++Builder .

clBlack
clMaroon
clGreen
clOlive
clNavy
clPurple

-
-

'

, , , ,

clTeal
clGray
cl Silver
clRed
clLime
clBlue
cIYellow
cIFuchsia
clAqua
clWhite
clBackground
cIScrollBar
cIActiveCaption
cllnactiveCaption
cIMenu
clWindow
cIWindowFrame
cIMenuText
clWindowText
cICaptionText
clActiveBorder
clInactiveBorder
cIAppWorkSpace
clHighlight
clHightlightText
clBtnFace
clBtnShadow
clGrayText
clBtnText
cllnactiveCaptionText
clBtnHighlight
cl3DDkShadow
cl3DLight
clInfoText
clInfoBk

1063

Windows















,

,


;
Windows 95/98 NT 4.0
; Windows 95/98 NT 4.0
; Windows 95/98 NT 4.0
; Windows 95/98 NT 4.0

1064

17

.
, Windows.
Windows. , . , cIBtnFace - .
, . , .
ParentColor true (
), Colpr , .
, .
Color, ParentColor false.
CommaText, DelimitedText, Delimiter, QuoteChar

TStrings

property AnsiString CommaText


property AnsiString DelimitedText
property char Delimiter
property char QuoteChar

CommaText , SDF (system data format).


,
, . , ( ).
DelimitedText ,
, QuoteChar, ,
, , Delimiter.
CommaText DelimitedText , Delimiter "," QuoteChar " " ".
ComponentConnt
,
TComponent
. . Components.
Componentlndex

TComponent
. . Components.
Components
,
TComponent

, , , ,

1065

property TComponent* Components[int Index]

Components , . Index Componentludex, TComponent.


0, .. 0. , Components, nentCount, TComponent. ComponentCount 1
Components.
Components ComponentCount , - .

1. , Buttonl, 10 .
for(int i = 0; i < ComponentCount; i++)
if(Components[i]->Name != "Buttonl")
( (TControl *)Components[i])->Left += 10;
2. , Tag , Tag =1.
for(int i - 0; i < ComponentCount; i++)
if (Components [i]-i;Tag -- 1)
((TControl *)Components[i])->Left += 10;
i

ControlCount

TWinControl

property int ControlCount

ControlCount Controls . Controls,


ControlCount, . ControlCount 1 , .
. . Controls.
Controls

TWinControl

property TControl* Controls[int Index]

Controls
. ,
Parent -

1066

17

. Index . , 0, Z- .
Controls
, .
ControlCount. .
Controls Components. Components , , . ,
Components.
Controls . (
) Z-.
Z- , Bring To Front Send To Bock.
, ,
, (0 , ).
Edit, .
Z- BringToFront SendToBack. Z-
InsertControl RemoveControl, , Parent, .


void
fastcall FuncfTObject *Sender);
, Sender. - , - , .. ,
((TControl *)Sender)->Left += 10;
10 .
, , Panell :
forfint i - 0; i < Panell->ControlCcmnt; i++)
Func(Panell->Controls[i]);
- Indl Ind2,

for(int i = Indl; i < Ind2; i++)
Func (Panell->Controls[i]) ;
.
Panell
, , :
for(int i 0; i < Panell->ControlCount; i++)
ShowMessage("Ind "+IntToStr (i) + ' + Panell->Controls[i]->
CopyMode

TCanvas

, , , ,

1067

property int CopyMode

CopyMode CopyRect TBitmap.


.
CopyMode (
Windows.hpp):
cmBlackness

, , . .

cmDstlnvert

.
.

cmMergeCopy

,
and. To , cmSrcAnd.

cmMergePaint


, or.

cmNotSrcCopy

. .

cmNqtSrcErase ,
, .
cmPatCopy

. .

cmPatlnvert

, .

cmPatPaint

,
. , or.

cm S re And

, and. To , cmMergeCopy.

cmSrcCopy

. . .

cmSrcErase


, and.

cmSrdnvert

, .
.

cmSrcPaint

,, or.

cm Whiteness

, , . .

1068

17

Imagel->Canvas->CopyMode " cmSrcCopy;


Imagel->Canvas->CopyRect(Rect(0,0,100,100),Image2->Canvas,
Rect(0,0,100,100));

Image2
Imagel. ,
Imagel, .

Imagel->Canvas->CopyMode cmSrdnvert;
Imagel->Canvas->CopyRect(Rect(0,0,100,100),Image2->Canvas,
Rect(0, 0,100,100) ) ;

Iraagel->Canvas->CopyRect(Rect(0,0,100,100),Image2->Canvas,
Rect (0,0,100,100) );

Image2 Imagel emSrdnvert. CopvRect Imagel Image2


, CopyRect
Imagel .

Imagel->Canvas->CopyMode = cmWhiteness;
Imagel->Canvas->CopyRect(Rect(0,0,100,100),Image2->Canvas,
Rect(0,0,100,100) ) ;

Imagel, . Image2
.
Cursor
,
TControl

enum TCursor {crMm=0x7f f f-1, crMax=0x7fff);


property TCursor Cursor

, . , Cursor DragCursor.

.
Cursor DragCursor
, Screen.
, TScreen,
(. . 4.7, . 4).
TScreen :

, , , ,

crDefanlt

1069

- crHour Glass
.
crArrow.

crNone

crDrag

cr Arrow

crNoDrop

crCross

crHSplit

crIBeam

crVSplit

crSize

crMuItiDrag

crSizeNESW

crSQLWait

crSizeNS

crNo

crSizeNWSE

crAppStart

crSizeWE

crHelp

crUpArrow

crHandPoint

Delimiter
. CommaText, DelimitedText, Delimiter, QuoteChar.
DelimitedText
DragCursor
CM. Cursor.
DragKind
, Drag&Drop,
Drag&Doc
TControl

enum TDragKind ( dkDrag, dkDock };


property TDragKind DragKind

DragKind , ( Drag&Drop) dkDrag, ( Drag& Doc) dkDock.


DragMode

TControl

1070

17

enum TDragMode { dntManual, draAutomatic );


property TDragMode DragMode

DragMode . :
dmAutomatic - .
.

dmManual
, BeginDrag
DragMode . . OnDragDrop.

Font

TControl

property Graphics::TFont* Font


,
Font TFoat. TFont, Color.
Height. Name, Pitch. Size. Style . .
Font . TFont.

1. Memol, , FontDialogl .
, Memol,
:
if (FontDialogl->Execute())
Memol->Font->Assign(FontDialogl->Font);
, FontDialogl->ExecuteO true
Memol .
2. , ,

RichEdit :
if (FontDialogl->Execute() )
RichEditl->SelAttributes->Assign(FontDialogl->Font! ;
3. ,
, ComboBoxl
Memol .
(
OnCreatei. OnClick ComboBoxl , Name Font
Memol.
void
fastcall TForml::FormCreate(TObject *Sender)
{

ComboBoxl->ltems Screen->Fonts;

, , , ,

1071

ComboBoxl->ItemIndex - 0;
)
void
{
}

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

Memol->Font->Name - ComboBoxl->Items->Stnngs t
ComboBoxl->ItemIndex];

4.
Charaet. , (, CSpinEdit) ,
OnClick :
Memol->Font->Charset - CSpinEditl->Value;
5. Eiici.
ComboBox, Items
fpDefault, fpPixed fpVariable, OnClick :
switch (ComboBox2->ItemIndex)
{

case 0: Memol->Font->Pitoh = fpDefault;


break;
case 1: Memol->Font->i'itch = fpFixed;
break;
case 2: Memol->Font->Pitoh - fpVariable;

Handle

TWinControl

^ p r o p e r t y HWND Handle

Handle API Windows, -.


.
Handle ,
. .
Height

TControl

property int Height

Height
. . . . ClientHeight, ClientRect.
Height

1072

17

TFont

property int Height

Height . Height
, .
Height, :
Size , Windows.
Height Size PixelsPerlnch (
. TFonU :
Font->Height = -Font->Size * Font->PixelsPerInch / 72

, , , Size Height. Size ; Height .

HelpContext
-
TControl

typedef int THelpContext;


property Classes::THelpContext HelpContext

HelpContext
- . ,
F1, .
HelpContext 0, HelpContext (-, ). , HelpContext , , HelpContext, , . THelpContext
Classes.cpp
typedef

int

THelpContext;

HelpContext, C++Builder 6, HelpTvpe = htContext.


HelpKeyword
:
i
, -
TControl

property

AnsiString

HelpKeyword

HelpKeyword
- . , F1, .
HelpKeyword C++Builder 6
HelnTvne = htKeyword.

, , , ,

1073

HelpType
, -
TControl

ertum THelpType (htKeyword, htContext);


property Classes::THelpType HelpType

HelpType , : HclpContext (
htContext), HelpKevword ( htKeyword)
- , . C++Builder 6.
Imagelndex

TMenuItem, TToolButton, TListltem, TTreeNode, TTabSheet .

property int Imagelndex

Imagelndex ,
, , , .. Images
- ( TMenu TPopupMenu, , ..) 0. Imagelndex = - 1 ,
.
-, ( Images
NULL),
Bitmap TMenuItem. Bitmap Images NULL Imagelndex.
Bitmap .
Left

TControl

property int Left

Left .
(, , , ,
).
Left ,
.
Left (. . BoundsRect Components).
Mode

1074

17

enum TPenMode (pmBlack, pmWhite, pmNop, praNot, pmCopy,


pmNotCopy, pmMergePenNot, praMaskPenNot,
pmMergeNotPen, pmMaskNotPen, pmMerge,
pmNotMerge, pmMask, pmNotMask, pmXor, pmNotXor};
property TPenMode Mode

Mode ,
. Mode .
Mode:

pmBlack
pm White
pmNop
pmNot
pmCopy


, Color :

>
pmNotCopy

pmMergePenNot
pmMaskPenNot ,
pmMergeNotPen
praMaskNotPen ,
pmMerge

pmNotMerge
pmMerge:

pmMask
, .
pmNptMask
pmMask: ,

pmXor
: , ,
pmNotXor
pmXor: ,
,

Name
,
TComponent

property AnsiString Name

Name , . -

, , , ,

1075

. .
C++Builder , .
. - , 17 Buttonl3.
Name . . Components.

Parent
,
TControl

property TWinControl* Parent

Parent , .. -, . , , , . , , , , , .
true ParentFont.
ParentColor, ParentShowHint. ParentCtI3D.
: Parent ,
Owner . ,
. ,
. .
Application .
Parent .
,
, Parent.
Parent . Visible.
ParentColor
. . TControl.

_ _ _

,
TCanvaa

property TPen*

,
. (.
).
, , .
Assign.

1076

17

PenPos

TCanvaa

property Windows::TPoint PenPos

PenPos TPolnt
. , , LineTo.
PenPos MoveTo (, LineTo). PenPos MoveTo.

Pitch

TFont

enum TFontPitch ( fpDefault, fpVariable, fpFixed );


property TFontPitch Pitch


. . , .
, .
.
Pitch:
fpDefault

, ..
Name

fpFixed

fpVariable

. fpVariable fpFixed Windows .


, .
.
.
. 5 . Font.

Pixels
ClipRect

TCanvas

enura TColor (clMin0x7f ff f fff-1, clMax-0x7fffffff};


property TColor Pixels[int X][int Y]

, , , ,

1077

Pixels X Y
ClipRect. ClipRect. Pixels - 1 .
. FillRect. . . 6, . 6.1.3.
Pixels. Pixels 1. Pixels
.

QuoteChar
. CommaText, DelimitedText, Delimiter, QuoteChar

Shortcut
,

TMenuItem

typedef Word TShortCut;


__property TShortCut Shortcut

Shortcut , . Shortcut .
Shortcut .
Shortcut ShortCut,
TextToShortCut, ShortCutToText (. . 16.7.4, . 16)
Size

()
TFont

property int Size

Size (, Windows). Size , . Size ,


.
: Height
. Size Height PixelsPerlnch ( . TFont) :
Font->Size = -Font->Hei<jht * 72 / Font->PixelsPerInch

, , ,
Size Height. Size ; Height .

17

1078
Style TPen

enum TPenStyle (psSolid, psDash, psDot, psDashDot,


psDashDotDot, psClear, psInsideFrame};
property TPenStyle Style

Style .
:
psSolid


psDash

psDot

psDashDot
-
psDashDotDot ,
psClear

psInsideFrame , Width > 1 , Windows
. 6, . 6.1.3.3.
Width = 1. .
psInsideFrame , .
Windows.
Style TBrush
Brush
TBrush

enum TBrushStyle (bsSolid, bsClear, bsHorizontal, bsVertical,


bsFDiagonal, bsBDiagonal, bsCross, .
bsDiagCross};
property TBrushStyle Style
Style , Brush,
Bitmap.
Style:

bsSolid
bsClear

bsCross
bsDiagCross

1079

, . , ,

bsBDiagonal
bsFDiagonal

WMkz

bsHorizontal

bsVertical -

Imagel->Canvas->Brush->Color = clRed;
Imagel->Canvas->Brush->Style - bsDiagCross;
Imagel->Canvas->Ellipse (0, 0, Imagel->Width, Imagel->Height);
Imagel ,
.
Style TFont

TFont

enum TFontStyle { fsBold, fsltalic, fsOnderline, fsStrikeOut j;


typedef Set<TFontStyle, fsBold, fsStrikeOut> TFontStyles;
property TFontStyles Style

Style : . Set, ,
:

fsBold
fsltalic

fsUnderline
fsStrikeout

Tag
,
TComponent

property int Tag

Tag . , .
, Tag
.
Tag . . Components.

1080

17

Top

TControl

property int Top

.
"
(, , ,
, ). . , .
(. . BoundsRecU Components).

TransparentColor
,

TBitmap

property TColor TransparentColor

TransparentColor TColor TransparentMode. TransparentMode tmAuto,


TransparentColor .
TransparentColor, TransparentMode
tmFixed. . TransparentColor, TransparentMode tmAuto,
TransparentColor .
TransparentMode
. TransparentColor.

Visible
,
TControl

property bool Visible

Visible .
Visible true, ;
Visible false, ,
. false Visible -, , Visible. Visible - true,
, Visible = true.

, , , ,

1081

Visible , ,
, ,
.
Visible . ,
.
false Enabled. , . ,
, .
true false Visible Show Hide. < Visible true.
Visible false.

: Panel 1 12, - : . 12 Panel 1, , , . OnCreate :


Panel2->Visible = false;
Panell->Visible - true;
Panel2->Parent = Forml;
Panel2->BoundsRect = Panell->BoundsRect;

12 , a Panell .
,
Visible, true Panell false 12.
12 Forml.
12 , Panell. ,
Panell. ,
, Panell.
, 12 Panell, - , Visible, true Panell false 12.
OnCreate :
Panel2->BoundsRect = Panell->BoundsRect;
Panel2.
|
SetBounds:
Panel2->SetBounds(Panell->Left,
Panell->Top,
Panell->Width, Panell->Height);


Panell. ,
12, :
Panell->Visible = false;
Panel2->Visible = true;

. Panell, :
Panel2->Visible = false;
Panell->Visible - true;

'

. BringToFront.

1082

17

Width

TControl

property int Width

Width
.
. - Width . . . GlientWidth, ClientReet.

17.2
Add


TList, TStringLlst, TStrings

TList:
int

fastcall Add(void * Item);

Tgtrings TStringList:
virtual int __fastcall Add(const System: :AnsiString S);

Add . , . ,
, . ( 0).
Count 1. Count
Capacity ( ), Capacity ( ) .
TStringList Add
EListError. S Duplicates
dupError.

1.
TList *List = new TList;
'// - :
List->Add((char *)malloc(10));
2.
TStringList *TL = new TStringList; //
TL->Sorted = true;
//
TL->Duplicates = dupError;
//
TL->Add("");
int i = TL->Add(""); // .. , i~0
TL->Add("");
// -

int i - TL->Add("");

, , , ,

1083

i 0, , . : String list does not allow dubliucates.


Assign

TBitMap, TIcon, TMetaFite, TPicture

virtual void

fastcall Assign (Classes::TPersistent * Source);

Assign , Source, . .
Graphic TPictnre. Graphic TBitMap. TIcon. TMetaFile.
TBitMap. TIcon. TMetaFile
Clipboard.
tinclude <vcl\Clipbrd.hpp>.

Graphic TPicture ,
, .

1. : Image2 Image!.
, Image2 TBitMap.
Imagel->Picture->Bitmap->Assign(Image2->Picture->Bitmap) ;
Imagel->Picture->Bitmap->Assign(Image2->Picture->Graphic) ;
2. Image2 Clipboard.
Clipboard () ->_Assign (Image2->Picture->Bitmap) ;
Clipboard()->Assign(Image2->Picture->Graphic) ;

3. Clipboard Image 1. Clipboard ,


.
Imagel->Picture->Bitmap->Assign(Clipboard());

Assign
,
TBlobField, TBrush, TChechConstraint, TClipboard, TCollection, tColumn,
TColumnTitle, TControlScrollBar, TCoolBand, TCustomlmageList, TDuteTimeColors,
TDimensionltems, TField, TFieldDefs, TFont, THeaderSection, TIndexDefs, TJPEGImage, TListCotumn, TListltems, TOleGraphic, TParaAitnbutes, TParam, TParams,
TPen, TPersistent, TSmalllntArray, TStatusPanel, TStringGridStrings, TStrings,
TTexiAttrtbuies, TTreeNode, TTreeNodes

<06beKT-Ha3Ha4eHMe>->Assign(<->) ;

Assign .
TPersistent , . -

1084

17

C++Builder . , TPersistent. Assign


EConvertError.
Assign
<-> = <->;
<->
<->. Assign .
Assign .
, D>Assign(S) 1>
, S ( S ). Assign ,
AssignTo, TPersistent , . S>AssignTo(D).
AssignTo , AssignTo TPersistent .

1. FontDiaolgl, . :
if (FontDialogl->Execute())
Font->Assign(FontDialogl->Font);

2. SL1 SL2 TStringList. ComboBoxl,


SL1 SL2 ,
RadioGroupl. OnClick , . Boxl->ltemlndex = 0 ,
.
TStringList *SL1 - new TStringList;
TStringList *SL2 - new TStringList;
voj,d
fastoall TForml: :RadioGrouplCliok (TOb^ect *Sender)
{
if(RadioGroupl->ItemIndex == 0)
ComboBoxl->Items->Assign(SL1);
else ComboBoxl->Items->Assign(SL2);,
ComboBoxl->ItemIndex - 0;
}

3. Assign , , TClipboard TBitmap.


Clipboard()->Assign(Bitmap);

Bitmap->Assign(Clipboard());
BeginDrag


TControl

void

fastcall BeginDrag(bool Immediate, int Threshold);

, , , ,

1085

BeginDrag , . DragMode dmManual. .


BeginDrag MouseDown. Immediate () , ,
. . Immediate false, , , Threshold.
, .
Threshold ( ),
BeginDrag DragThreshold
Mouse.
. . OnDragDrop.
BringToFront
Z-
TControl

void
fastcall BringToFront(void);

BringToFront ,

Z-, . , , , Z- . BringToFront Z- .
, , ,
, .., , , Memo,
ComboBox . Z- BringToFront .
, BringToFront ,
, .

1. , - ,
.
( Buttonl Button2),
.
Buttonl->BringToFront();

Button2->BringToFront();
, .

1086

17

2. : Panell 12, -
. 12 Panell, '
, , . OnCreate
:
Panel2->Parent = Forml;
Panel2->BoundsRect = Panell->BoundsRect;
Panell->BringToFront ();

12
Forml. 12 ,
Panell. ,
Panell. ,
, Panell. Panell.
, ,
12 Panell, - (, ,
).
OnCreate :
Panel2->BoundsRect = Panell->BoundsRect;
Panell->BringToFront();

12 Panell.

Panell. , 12, :
Panel2->BringToFront();

. Panell, :
Panell->BringToFront();

. Visible,
BringToFront .
BrushCopy
, ,
TCanvas

void

fastcall BrushCopy(const Windows::TRect SDest, TBitmap* Bitmap,


const Windows::TRe0t Source/ TColor Color);

BrushCopy
Bitmap , Color , Brush. Source Bitmap. Dest , .
, Color , Color Brush .

, , , ,

1087

Forml->Canvas->BrushCopy(Rect(10,10,100,100) ,
Bitmapl, Rect(10,10,100,100) , clBlack) ;
(10, 10) (100, 100)
Bitmapl Forml
, Forml>Canvas>Brnsh>Color.
Chord
:
,

TCanvas

void
fastcall Chordfint XI, int Yl, int X2, int 2,
int X3, int Y3, int X4, int 4);

Chord : , , . Brush. (XI, Y1) (2, Y2) ,


.
, (, Y3). ,
(4, Y4). .
(, Y3) (4, Y4) .
Windows 95/98 XI + 2, Y1 + Y2 XI + 2 + Yl + Y2
32768.
Windows NT
SetArcDirection.

Imagel->Canvas->Chord(0,0,
Image2->Canvas->Chord(0,0,

200,200,
200,200,

200,0,
0,0);
0,0,
200,0);

, .

ClassName

1088

TObject

s t a t i c Shortstring
fastcall ClassName(TClass e l s ) ;

ClassName . ,
- -. ClassName ,
, . ,
catch(Exceptions E)
{
ShowMessage("

"+.ClassName());

. ,
catch(Exceptions E)
{

ShowMessage(" "+.Message) ;
I
, .
Clear


TClipboard, TList, TStringList, TStrings, TComboBox, TDBCombobox,
TDBEdit, TDBListBox, TDBMemo, TDirectoryListBox, TDriveComboBox, TEdit,
TFileListBox, TListBox, TMaskEdit, TMemo, TOutline

DYNAMIC void
fastcall Clear(void);

Clear
. .
Clipboard Clear
Clipboard. , ( Cut
).

ClientToParent ParentToClient


TControl

struct TPoint
f
int x;
int y;

);
TPoint

fastcall ClientToParent(ponst TPoint Point,


TWinControl *AParent (TWinControl*) NULL);
Types::TPoint
fastcall ParentToClient(
const Types::TPoint sPoint,
TWinControl* AParent = (TWinControl*) NULL);

, , , ,

1089

ClientToParent ( C++Builder 6)
Point AParent. ParentToClient .
AParent ,
. , Parent.
AParent NULL , .
AParent
Parent nil, ElnvalidOperation.

Panell, Forml - . Panell


12. , Forml,
. , , 12 Panell.
,
:
TPoint Coord - Panell->ClientToParent(
Point (Panel2->Left,Panel2->Top),Forml);
Panel2->SetBounds(Coord.x. Coord.y, Panel2->Width, Panel2->Height);
Panel2->Parent = Forml;
12,
Panell, Forml Coord. 12. 12 Forml.
<
Panell , (Forml) ClientToParent NULL.
ClientToScreen

TControl

struct TPoint
(
int x;
int ;
);
Windows::TPoint

fastcall ClientToScreen(
const Windows::TPoint SPoint);

ClientToScreen
( ) (
).
ScreenToClient

.
35 C++Builder 6

1090

17

N
- Comp2->ScreenToClieftt (Compl->ClientToSCreen(P)) ;
Compl 2.
CopyRect

___

'

{
TCanvas

void fastcall CopyRect(const Windows::TRect SDest,


TCanvas* Canvas, const Windows::TRect SSource);

CopyRect Source Canvas Dest


TCanvas. ,
CopvMode.

Imagel->Canvas->CopyRect(MyRect2,Bitmap->Canvas,MyRectl) ;
Image 1 MyRect2
MyRectl Bitmap.
Delete___


TList, TStringList, TStHngs, TMenuItem

void
fastcall Delete(int Index);

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

for (I - 0; I < 1; I++)


1
List->Delete(O);
List.
:
for (I - 0; I <- 1; I++)
List->Delete(l) ;
, 1 , 2. , , 2.

, , , ,

1091

Draw

TCanvas

void

fastcall Draw(int X, int Y, TGraphic* Graphic);

Draw , , Graphic,
. X Y. ,
. TBitmao.
, CopvMode.

Imagel->Canvas->Draw(10,10, Bitmapl)
Image 1 Bitmapl (10, 10).
DrawFocusRect
,
,
TCanvas

void __fastcall DrawFocusRect(const Windows::TRect SRect);

DrawFocusRect Rect , , .. . , .

, ,
Imagl 10 10 :
int ;
bool drag = false;
void __fastcall TForml:;lmagelMouseDown(TObject 'Sender,
TMouseButton Button, TShiftState Shi,ft, int X, int Y)
f
//
Imagel->Canvas->DrawFocusRect(Rect(X-5 ,Y-5, X+5 + 5 ) ) ;
//
XO - X;
YO - Y;
//
drag - true;
}
//
void fastcall TForml: : ImagelMouseMove (TObiject Sender,
TShiftState Shift, int X, int Y)

1092

17

if( Idrag) return;


//
Imagel->Canvas->DrawFocusReot(Rect(XO-5,Y0-5,X0+5,Y0+5));
//
Imagel->Canvas->DrawFocusRect(Rect(X-5,Y-5,X+5, Y+5));
//
XO - XV
YO = Y;
)
y/
_
_
r

void
fastcall TForml::ImagelMouseUp(TObject Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
<
if( Idrag) return;
//
Imagel->Canvas->DrawFocusRect(Rect(XO-5,YO-5,X0+5, YO+5));
//
drag *= false;
)

,
( drag = true). , . .
Ellipse

TCanvas
void

f a s t c a l l E l l i p s e d n t XI,

i n t Yl,

i n t X2,

i n t Y2);

Ellipse
. Brush, (XI, Y1) (2,
Y2) , .
Windows 95/98 XI + 2, Y1 + Y2 XI + 2 + Yl + Y2
32768.

Imagel->Canvas->Brush->Color - clRed;
Imagel->Canvas->Brush->Style = bsDiagCross;
Imagel->Canvas->Ellipse(0, 0, Imagel->Width, Imagel->Height);
, Image 1 .
Exchange

TList, TStringList, TStrings

TList:
void
fastcall Exchange (int Indexl, int Index2);
TStrings TStringList:
virtual void
fastcall Exchange(int Indexl, int Index2);

, , , ,

1093


Exchange Indexl Index2 . ( ).
,
.
Exchange TStringList. ,
. , Exchange .

List TList .
( ).
for(int i - 1; i < List->Count; i++)
i f ( * ( ( i n t *)List->Items[O]) > * ( (int *)List->Items[i]))
List->Exchange (0, i ) ;
:
for(int j = 0; 2 < List->Count-l;
for(int i = j; i < List->Count;
if (*((int *)Liat->Items[j]) > *((int *)List->Items[i]))
List->Exchange (j, i ) ;

/
FillRect
,
Brush
TCanvas

void
fastcall FillRect(const Windows::TRect SRect);

FillRect , Rect,
Brush.
, .
FillRect Rect Rect (. .
16.3.3, . 16).

Imagel->Canvas->FillRect(Rect(0,0, Imagel->Width, Imagel->Height));


Image 1, ,
Brush.
FindNextControI

TWinControl

TWinControl*

fastcall FindNextControI(
TWinControl* CurControl, bool GoForward,
bool CheckTabStop, bool CheckParent);

1094

17

FindNextControl CurControl . CurControl


, , . , CurControl .
GoForward true, , CurControl.
GoForward false, .
CheckTabStop CheckParent .
CheckTabStop true, , TabSton true. CheckTabStop false TabStop
. CheckParent true, , Parent , .. . CheckParent false,
, .
FindNextControl GetTabOrderlist .

TWinControl *Obj;
for(int i = 0; i < Forml->ControlCount; i++)
{
obj = Forml->FindNextControl(obj,true, true, true);

obj
Forml, , ..
TabStop true. ,
, , ,
TabStop true, , .
CheckParent false:
obj = Forral->FindNextControl (obj, true, true, false);

, TabStop true, , , ,
, TabStop .
CheckTabStop false:
obj < Forml->FindNextControl(obj,true, false, false);

,
TabStop.
FloodFill
,
TCanvas

enum TFillStyle {fsSurface, fsBorder);


void
fastcall FloodFill(int X, int Y, TColor Color,
TFillStyle FillStyle);

, , , ,

1095

FloodFill Brush , (X, Y). X Y ,


. Color, FillStyle. Color TColor
, ,
FillStyle , .
FillStyle = fsSurface, , Color,
. FillStyle = fsBorder, , , Color,
Color .

1.
l->Canvas->Brush->Color = clWhite;
lmagel->Canvas->FloodFill(X,,Imagel->Canvas->Pixels[X][],fsSurface);

Imagel , {X, Y)
, . , OnClick Imagel, , , , .

2.
lmagel->Canvas->Brush->Color = clWhite;
Imagel->Canvas->FloodFill(X, Y, clBlack, fsBorder);

Imagel , (X, Y)
, . .
FrameRect

TCanvas

void
f a s t c a l l FrameRect(const Windows::TRect SRect);

FrameRect Rect,
Brush. 1 .
. Rectangle ,
( Rectangle )
( Rectangle ).

Imagel~>Canvas->BruSh->Color = clBlack;
Imagel->Canvas->FrameRect(Rect(10,10,100,100));
Imagel .
Free

1096

17

TObject

fastcall Free ;

-
Free , , . delete,
Free.
Free ,
(
NULL). .
Hide

TControl

void

fastcall Hide(void);

'

Hide , False Visible. ,


.
, .
IndexOf
1


TList, TStringList, TStrings

TList:
int

fastcall IndexOf(void * Item);

TStrings TStringList:
virtual int __fastcall IndexOf(const System;:AnsiString S) ;

IndexOf ( Item TList S TStringList TStrings').


0 (0 ). , - 1 .

, , Editl.
TStringList *LPerson = new TStringList;
if (LPerson->IndexOf(Editl->Text) < 0)
ShowMessage(" " + Editl->Text + " ");

Insert
,
,
________^_

, , , ,

1097

TLiat, TStringList, TStrings

TUst:
void __fastcall Insert(int Index, void * Item);

TStrings TStringList:
virtual void

fastcall Insert(int Index, const System::AnsiString S) ;

Insert ( Item S)
, Index. Index = 0,
. , Index, , .. 1.
, Insert
EListError. Add.
TStringList TStrings , , Insert InsertObject.
LineTo
,

TCanvas

void
fastcall LineTo(int X, int Y) ;

LineTo , PenPos (X, Y), (X, Y). PenPos (X, Y). ,

Imagel->Canvas->MoveTo(XI,Y1) ;
Imagel->Canvas->LineTo(X2,12)
Imagel->Canvas->LineTo(, )
- , (Xl.Yl), (X2,Y2) (X3.Y3).
LoadFromClipboardFormat
Clipboard
TGraphic, TBitmap, TIcon, TMetafile, TPicture

virtual void
fastcall LoadFromClipboardFormat(
Word AFormat, int AData, HPALETTE APalette);


Clipboard. AFormat , AData
APalette .
: CF_BITMAP CF_METAFILEPICT .
AData GetAsHandle TClipboard.

1098

17

include <vcl\Clipbrd.hpp>

RegisterClipboardFormat.
, ) EInvalidGraphic.

include <vcl\Clipbrd.hpp>
if (Clipboard{)->HasFormat(CF_BITMAP))
{

try
<
Imagel->Picture->Bitmap->LoadFromClipboardFormat(CF_BITMAP,
Clipboard()->GetAsHandle(CF_BITMftP) , 0 ) ;
>
catch (...)
<
ShowMessage(" ");
}

>

else
ShowMessage(" ");

Image 1,
LoadFromFile
,
TGraphic, TPicture

virtual void fastcall LoadFromFile<const AnsiString FileName);

LoadFromFile FileName
.
,
, EInvalidGraphic.

if (0penPictureDialagl->ExecuteO )
Imagel->Picture->LoadFromFile(OpenPictureDialogl->FileName);
OpenPictureDialogl, , Imagel.
Move

System
TList, TStringList, TStringa

void
fastcall Move(int Curlndex, int Newlndex);

Move , Curlndex, ,

^, , , ,

1099

Newlndex ( 0). TStrinps TStringList


, .

My Strings
.
MyStrings->Move(Q, MyStrings->Count - 1 ) ;

MoveTo
,
TCanvas

void

f a s t c a l l MoveTo(int X, i n t Y) ;

MoveTo PenPos
(X, Y). PenPos. MoveTo .

ParentToClient

. . ClientToParent ParentToClient.
Pie

TCanvas

void

fastcall Pie(int XI, int Yl, int x2, int 42,


i n t X3, int Y3, int X4, int Y4);

Pie .
. (XI, Y1) (2, Y2) , . , (, Y3). , (4, Y4). . , (,
Y3) (4, Y4).
Windows 95/98 XI + 2, Y1 + Y2 XI + 2 + Yl + Y2
32768.
Windows NT
SetArcDirection.

Imagel->Canvas->Pie(0, 0, 200, 200, 200, 0, 0, 0 ) ;


Image2->Canvas->Pie(0, 0, 200, 200, 0, 0, 200, 0 ) ;

, .

1100

17

PoIyBezier PolyBezierTo
,
TCanvas

void
void

fastcall PoIyBezier(const Windows::TPoint * Points,


const int Points_Size);
fastcall PolyBezierTo (const Windows: .-TPoint * Points,
const int Points_Size};

PoIyBezier PolyBezierTo Points_Size,


Points, .
PoIyBezier , a PolyBezierTo . Points_Size
( , , ++der): PoIyBezier 3 (.. i*3), PolyBezierTo
, 3 (.. i*3-l). , .
N
, , :
PoIyBezier(points, (N/3)*3);
PolyBezierTo(points, (N/3)*3-l);

N .

-sin(x)
PoIyBezier, PolyBezierTo Polyline.
const N - 10, Lx = 500, Ly = 100, T = 10;
TPoint points[Nl;
//
for (int i = 0; i <= N; i++)
points[i] - Point ((int) (i * Lx / ( N - D ) ,
(int)(sin((double)i * T / (N-l))*Ly) +
Imagel-XTlientHeight / 2) ;
//
Imagel->Canvas->Pen->Color = clBlack;
Imagel->Canvas->Polyline(points, N-l);
Imagel->Canvas->Pen->Color = clRed;
Imagel->Canvas->PolyBezier(points,
(N/3)*3);

, , , ,

1101

Imagel->Canvas->Pen->Color = cl^reen;
Imagel->Canvas->PolyBezierTo(points,
(N/3)*3-l);
, .
Polyline

Polygon
() ,
TCanvas

void
fastcall Polygon(const Windows::TPoint * Points,
const int Points_Size);

Polygon (, )
, Points.
. Polygon
Polyline, .
. Brash.
, TPoint.

TPoint p o i n t s [ 5 ] ;

p o i n t s [ 0 ] Point (30,150);
p o i n t s t l ] - Point(40,130);
p o i n t s [ 2 ] = Point(50,14Q);
p o i n t s [ 3 ] - Point(60,130);
p o i n t s [ 4 ] = Point(70,150);
Imagel->Canvas->Polygon(points,4);
, points.

Polyline
-
TCanvas

1102

void
fastcall Polyline(const Windows::TPoint * Points,
const int Points_Size);

Polyline - , Points. Polyline Polygon , Polygon , Polyline .


.
PenPos .
- ,
TPoint.
, Polyline, MoveTo
LineTo.
LineTo. , Polyline , MoveTo LineTo .

TPoint points[5];
points[0] = Point(30,150);
points[1] - Point(40,130);
points[2] - Point (50,140);
points[3] - Point(60,130);
points[4] - Point (70,150);
Iraagel->Canvas->Polyline(points, 4) ;
I
- , Point (. . 16.3.3, . 16) points.
Rectangle

TCanvas

void _ fastcall Rectangle (int XI, int XI, int X2, int 2) ;

Rectangle ,
(XI, Y1), (2, Y2).
Brush.
, FillRect.
RoundRect. FrameRect.

Imagel->Canvas->Rectangle(10,10, 210,110) ;
Refresh


TControl

void
fastcall Refresh(void);

, , , ,

1103

Refresh .
Refresh Repaint. Refresh Repaint .

Repaint

TControl

virtual void
fastcall Repaint(void);

Repaint
. ControlStyle csOpaque,
. Repaint Invalidate.
Update.

RoundRect

TCanvas

void
fastcall RoundRect (int XI, int 41, mt X2, int 42,
int X3, int Y3);

RoundRect , Brush. (X1,Y1)


(X2.Y2). Y3.
> 2 - XI, ( ). Y3 > Y2 - Y1,
.
, . , ,
Ellipse. , . , ,
Rectangle.

,
:
Imagel->Canvas->RaundRect(10,10,110,210,50,100);
Imagel->Canvas->RoundRect(160,10,260,210,100,100) ;
Imagel->Canvas->RoundRect(310,10,410,210, 50, 200);
Imagel->Canvas->RoundRect(460,10,560, 210,100,200) ;

1104

17

SaveToClipboardForinat
Clipboard

TGrapfiic, TBitmap, TIcbn, TMetafile, TPicture

v i r t u a l void

fastcail

SaveToClipboardFormat(Word SAFormat,
i n t SAData, HPALETTE SAPalette) - 0;

SaveToClipboardFormat Clipboard. , ' AFormat, AData APalette. : CF_BITMAP


CF_METAFILEPICT .

RegisterCIipboardFormat.
SaveToClipboardFormat
Clipboard AFormat AData SetAsHandle.

include <vcl\Clipbrd.hpp>.

, Clipboard , Assign Clipboard TGraphic. TBitMap.


TIcon. TMetafile.

include

<vcl\Clipbrd.hpp>

Word MyFormat;
THandle AData;
HPALETTE APalette;
Imagel->Picture->Bitmap->SaVeToClipboardFormat(MyFormat,
AData,/APalette);
Clipboard()->SetAsHandle(MyFormat, AData) ;

, Picture>Bitmap Imagel, MyFormat. :


if (Clipboard!)->HasFormat(MyFormat) )
(
try

Image2->Picture->Bitmap->LoadFromClipboardFormat(CF_BITMAP,
Clipboard()->GetAsHandle(MyFormat) , 0 ) ;
}
catch
(...)
i
ShowMessage (" ");
)
)
else
ShowMessage(" MyFormat");

,
SaveToClipboardFormat, , :
Clipboard()->Assign(Imagel->Picture->Bitmap) ;

Clipboard ()->Assign(Imagel->Picture->Graphic) ;

, , , ,

1105

SaveToFile

6
TGraphic, TMetafile, TPicture

virtual void

fastcall SaveToFile(const AnsiString Filename);

SaveToFile
FileName.

SaveToFile TPktere , ,
.
, My.ico My.bmp.
TIcon *lco new TIcon();
try
(
ico->LoadFromFile("Wy.ico");
Imagel->iutoSize false;
Imagel->idth = ico->Width;
Imagel->Height - ico->Height;
Imagel->Canvas->Draw(O, 0, ico) ;
imagel->Picture->SaveToFile("My.bmp");
)
finally
{
delete ico;

ScreenToClient

___*^__


TControl

struct TPoint
(
int x;
int ;
};

Windows::TPoint
fastcall ScreenToClient(const Windows::TPoint SPoint);

ScreenToClient ( ) (
).
ClientToSfcreen

.

Comp2->ScreenToClient(Compl->ClientToScreen(P));


Compl 2.

1106

17

SelectFirst

, TWinControl

void

fastcall SelectFirst(void);

SelectFirst , . FindNextControl. , NULL. FindNextControl , .

SelectFirst();

SelectNext
,
TWinControl

void

f a s t c a l l SelectNext(TWinControl* CarControl,
bool GoForward, bool CheckTabStop);

SelectNext , , CarControl. GoForward : true , false .


CheckTabStop ,
Tab. Stop, true. CheckTabStop true,
TabStop. true, .
SelectNext
GoForward CheckTabStop, CurControl.
SendToBack
Z-
TControl

'void

fastcall

SendToBack(void);

SendToBack .

Z-,
. ,
,

, , , ,

110*7

, Z-
. SendToBack Z- .
, .
, , ,
, .., , , Memo,
ComboBox . Z- SendToBack . , SendToBack ,
, .

, BrinqfToFront. , .
BrinqTaFront. ,
SendToBack, .

SetBounds
Left, Top, Width Height
TControl

v i r t u a l void _ f a s t c a l l SetBounds(int ALeft, int ATop,


int AWidth, int AHeight);

SetBounds , . Left. Top. Width Height. To, SetBounds , ,


. ,
.
Left. Top. Width Height SetBounds ALeft, ATop, AWidth AHeight.
, , . .
Visible BringToFront.

SetFocus

TWinCantrol

virtual void

fastcall SetFocus(void);

SetFocus , .

Editl->SetFocus() ;

Editl.

1108

_^_

17

Show

TControl

void

f a s t c a l l Show(void);

Show .
true Visible , .
. .
Visible.
/
StretchDraw
>______^_
|
,

TCanvas

void

f a s t c a l l StretchDraV (const Windows::TRect SRect,


TGraphic* Graphic);

StretchDraw ,, ,
Graphic, ,
Rect. .
StretchDraw firaw.
.
Graphic , . 1 TBitMap,
, CoovMode.

Imagel->Canvas->StretchDraw(Rect(10,10,110,110)/Bitmapl);

Image 1 Bitmapl (10, 10) (110, 110).


100.

TextExtent
, ^
TCanvas

struct TSize
{

LONG c x ;
LONG ;
);

TSize

fastcall TextExtent(const AnsiStrxng Text);

v
'

, , , ,

1109

TextExtent TSize,
Text, (.
Canvas) . .
TextHeight TextWidth.

String st - Editl->Text;
Canvas->TextOut((ClientWidth - Canvas->TextExtent(st).ex) / 2,
Canvas->TextExtent(st).cy,st);
,
Editl, () .

TextHeight
,

TCfanvas
'
int
fastcall TextHeight (const AnsiString Text);

TextHeight Text,
Canvas .

.
TextExtent. , . TextHeight , TextExtent(Text).cy.

String st = Editl->Text;
Imagel->Canvas->TextOut( (Imagel->ClientWidth Imagel->Canvas->TextWidth(st)) / 2,
Imagel->Canvas->TextHeight(st) , st) ;
, Editl, Image 1, .
. TextRect.

TextOut
,
TCanvas
,

void __fastcall TextOut(int X, int Y, const AnsiString Text);

TextOut Text (. Canvas1). (X, Y). Font- Brush.


Penpos .

1110

17

, : TextExtent.
TextHeight Text Width.
, , .
.

, TextRect,

Imagel->Canvas->TextOut(10, 10, s) ;

, s, Imagel, (10, 10).


. TextExtent. Text Height. TexfrWidth
TextRect.
TextRect
* - p.
^
- -. H
, ,
TCanvas

void

_fastcall TextRect(const Windows::TReet SRect,


int X, int Y, const AnsiString Text) ;

TextRect Text (. Canvasi.


(X, Y) . ,
fleet, .
Eani. Beet Brush.
, :
TextExtent. TextHeight TextWidth.
,

1.
int Xl,Yl,X2,Y2;
String st Editl->Text;
XI = 100;
Yl - 100;
X2 - 200;
Y2 - 150;
Imagel->Canvas->Brush->Color = clRed;
Imagel->Canvas->TextRect (Rect(XI,Y1,X2,Y2),
Xl+(X2-Xl-Imagel->Canvas->TeXtWidth(st)) / 2,
Yl+(Y2-Yl-Imacrel->Canvas->TextHeight(st}> / 2, st) ;

Imagel
TextRect ,
Editl. , . , .

, , , ,

1111

2.
Imagel->Canvas->TextRect (Rect (Xl-5, VT1-5,
Xl+lmagel->Canvas->TextWidth(st)+5,
n+Imagel->Canvas->TextHeight(st)+5),
XI, Yl, s t ) ;

, 5 . , ,
TextOut(Xl,Yl,st);

TextOut.

TextWidth
,

TCanvas

int

fastcall TextWidthfconst AnsiString Text);

TextWidth Text, (. Canvas) . .


TextExtent. , . TextWidth , TextExtent(Text).ex.

String st = Editl->Text;
Imcigel->Canvas->TextOut ((Imagel->ClientWidth Imagel->Canvas->TextWidth(st)) / 2,
Imagel->Canvas->TextHeight (st) , st)i;

,
Editl, .
<
, tRect.
Update

TWinControl

virtual void

fastcall Update(void);

Update , - Windows . , , Repaint.


Update Window API Windows.

1112

17

17.3
OnChange TCanvas

TCanvas

typedef void ( closure *TNotifyEvent)(System::TObject* Sender);


property Classes::TNotifyEvent OnChange

OnChange .
:
1. OnChanging.
2. TCanvas .
3,. OnChange.
OnChange , . , Font ,
OnChange.
OnChanging
. OnChange.
OnClick

TControl

typedef void ( closure *TNotifyEvent)(System::TOfcoect* Sender);


property Classes::TNotifyEvent OnClick

OnClick , , . , :
, , , ,
.
,
.
Enter, , Default.
Esc, , Cancel.
. , Caption &
, Alt-
OnClick .
true Checked RadioButton.
Checked CheckBox.
Click .

, , , ,

1113

OnClick ,
.
,
Seeder , , .

OnClick
. , , Sender, , ,
;
ShowMessage("OnClick "+((TControl *)Sender)->Name);
, , .
OnCreate
___*_
.
TCustomForm

typedef void ( closure *TNotifyEvent)(System::TObject* Sender);


property Classes::TNotifyEvent OnCreate

OnCreate -
. -
, , OnDestroy.
, Visible, true: OnCreate, OnShow, OnActivate, OnPaint.
OnDblCIick

TControl

typedef void ( closure *TNotifyEvent)(System:iTObject* Sender);


property Classes::TNotifyEvent OnDblCIick

OnDblCIick , : ,
.
OnClick OnDblCIick,
.
Sender , , (. . OnClick).
OnDragDrop

1114

17

TControl

typedef void (

closure *TDragDrppEven,t) (
System:iTObject* Sender,
System::TObject* Source,
i n t X, i n t Y);
property TDragDropEvent OnOragDrop

OnDragDrop . ,
. Source , Sender , .
X Y
.

1. TListBox *
.
.
DragMode, dsiAutomatic.
.
OnDra^Over :
void
f a s t c a l l TForml:;ListBoxlDragOver(TObject *Sender,
TObject *Source, i n t X, i n t Y, TDragState S t a t e ,
bool SAccept)
(
Accept - Source->ClassNameIs("TListBox");
}

,
TListBox.
\
OnDragQver .
, OnBragDrep ;
void
f a s t c a l l TForml::ListBoxlDragDrop(TObject *Sender,
TObject *Source, i n t X, i n t Y)
{

TListBox *S - (TListBox *)Souroe;


((TListBox*) Sender) ->Iterns->Adot(S->lteras->Strings[S->IteraIndex]) ;
S->Items->Delete(S->ItemIndex);

)
,
-. , & , 1, ((TListBox*)Sender) S ListBoxl. ( , , ).
OnDragDrop .
, , .
.
2. -
, (, -
), .

, , , ,

1115

DrapMode. dmManual.
.
OnMouseDown :
void __fastcall TForml::ListBqx3MouseDown(TOBJect *Sender,
TMouseButton Button, TShiftState Shift, int x, int Y)
{
,
'
if ( (Button >-- mbLeft) && < - >)
((TControl*)Sender)->BeginDrag(false, 5) ;
)

, , - , ( ). BcginDrag . false 5, 5 .
OnMouseDown .
.
3. Drag&Drop
5, . 5,4.1.
OnDragOver
,

TControl

typedef void ( closure *TDragOverEvent)(


System: :TObject* Sender, System: :TOb;ject* Source,
int X, int Y, TDragStata State, bool Accept);
property TDragOverEvent OnDragOver

OnDragOver , .
, , , . OnDragOver , ,
. ,
Accept, true. ,
true, .
, . ,
.
, , , . ,
OnDragOver ( ) DracCursor.
Source , Sender
, X Y . State TDragState
. ;

1116

1?

dsDragEnter
dsDragMove
dsDragLeave

.
, .
.

void

fastcall TForml::ListBoxlDragOver (TObject Sender,


TObject *Source, mt X, int Y, TDragState Sta'te,
bool SAccept)

{
Accept - ( ( (TControl*>Sexlder)->Name ~ "ListBoxl") ;
}

OnDragOver , , ListBoxl.
, , OnDragOver, . OnDragDrop.
OnEndDrag

TControl

typedef void

closure *TEndDragEvent) (
System::TOb]eot* Sender,
System::TObject* t a r g e t , i n t X, i n t Y);
property TEndDragEvent OnEndDrag

OnEndDrag ( ) ( , ). .
& . , -
, , - .
Sender . Target
-, , NULL, . X Y .

void

fastcall TForml::ListBoxlEndDrag(TObject *Sender,


tOb^eot Target, int X, int Y)

if (Target NOLL)
ShowMessage(" "+
((TControl*)Sender)->Name + " ");
else
ShowMessage(((TControl*)Sender)->Mame + " "
+ ( (TControl*)Target)->Name);
}


ListBoxl ListBoxl ListBox2.
, , .

$'

, , , ,

OnEnter


TWinControl

'

typedef void ( closure *TNotifyEvent)(System::TOb]ect* Sender);


property Classes::TNotifyEvent OnEnter

OnEnter . .
, , , , OnEnter , . OnExit.
, .

, . . , ^)^.- OnEnter , OnEnter


, .
, OnExit ,
OnExit , OnEnter .
OnExit
-
TWinControl

typeclef void ( closure *TNotifyEvent) (System: :TOb]eot* Sender);


property Classes::TNOtifyEvent OnExit

OnExit ,
.
.
*
ActiveControl ,
OnExit.
, , , , OnExit ,
.
OnEnter.
, , .
, , . OnEnter.
OnKeyDown
.

TWinControl

enum Classes

1 { ssShift, ssAlt, ssCtrl,


ssMiddle, ssDouble );

ssLeft,

ssRight,

1 '

typedef Set<Classes
typeclef void (

1, ssShift, ssDouble>

IJVI

'

TSJiiftState;

closure *TKeyvent) (System: sTOirject* Sender,


Word SKey, Classes::TShiftState S h i f t ) ;

property TKeyEvent OftKeyDown

. OnKeyDown , , , , , Shift, Alt Ctrl.


, Sender, , , Key
Shift. Key . - API Windows.
Key . 16, . 16.1.1. .
Shift , :
*

ssShift
ssAlt

Shift.
Alt.
Ctrl.

ssCtrl

Shift, , .

Alf-X.
:
i f ( ( K e y ~ 'X') & S h i f t . C o n t a i n s ( s s f t l t ) ) . . . ;
Enter
:
if (Key 13) ... ;
/

if (Key == OxOD) . . . ;

if (Key -- VK_RETURN) ... ;


OnKeyPress
u___

TWinControl

typedef void ( closure *TKeyPressEvent)(


System: :TObjeet* Sender, char SKey);
property TKeyPressEvent OnKeyPress

OnKeyPress , , . Key -

, , , ,

11

f Char . .
, ASCII ( ,
Shift, Alt, Ctrl), .
, , , Shift-A, OnKeyPress,
Key . , , ,
OnKeyDown OnKeyUp.
, QnKeyPresS , Shift.
- , OnKeyPress ( OnKevDown OnKeyUp ) , , . , Alt
OnKeyPress . OnKeyPress ,
.
Key , , , .

1. ,
Editl - , . , Editl
OnKeyPress:
Set <char, ' 0 ' , ' 9 ' > Dig;
D i g ' 0 ' << ' ' 2 '
'6' '71 '8'
if t ! D i g . C o n t a i n s < K e y ) )
Key - 0 ;

' 3 ' '<3'


'9';

'5'
/


.
2. OnKeyPress
, , :
Key - UpCase(Key);
' ' ' '
.
, ( . . 16.4.2.3, . 16):
Key - AnsiOpperCase(Key)[1];
OnKeyUp

' TWinControl

enum Classes_l { ssShift, ssAlt, ssCtrl, ssLeft, ssRight,


ssMiddle, ssDouble } ;
typedef Set<Classes 1, ssShift, ssDbuble> TShj.ftState;
typsdef void ( closure *TKeyEvent)(System::TObject* Sender,
Word &Key,
Classes::TShiftState Shift);
property TKeyEvent OnKeyUp

1120

________^

17

OnKeyUp , , ,
, , Shift, Alt Ctrl.
, Sender, , Key
Shift. Key , .
- API Windows.
Key . 16, . 16.1.1.
.
Shift , :

ssShift

Shift.
Alt.
Ctrl,

ssAlt
ssCtri

Shift, , ^
.
OnKeyUp , ,
, . , Key
word, char,
. , ,
,
.

,
Shift-Y. :
i f ( ( K e y

'Y')

SS

Shift.Contains(ssShift))

...

Y, ,
, , Y.
OnKeyPress.
OnMouseDown OnMouseUp

TControl

enum TMouseButton { mbLeft, mbRight, mbMiddle );


Classes
typedef
I

ssShift, ssAlt, ssCtri, ssLeft, ssRight,


ssMiddle, ssDouble !;
Set<Classes
1, ssShift, ssDouble>
TShiftstate;

typedef void ( closure *TMouseEvent)(System::T0b3ect* Sender,


'
TMouseButton Button,
Classes:iTShiftstate Shift,
int X, int Y ) ;
property TMouseEvent OnMouseDown

, , , ,

1121

OnMouseUp, .
TMouseEvent:
property TMouseEvent OnMouseUp

OnMouseDown OnMouseUp ,
- .
,
, Button Shift. Button , : mbLeft , mbRight , mbMiddle . Shift , Shift, Alt, Ctrl ( ssShift, ssAlt,
ssCtri), ssDouble . X Y . Sender
, .

1. OnMouseDown , - (, - ),
. DragMode. dmManual, . OnMouseDown :
void
fastcall TForml::ListBox3MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
I
if ((Button == mbLeft) && < - >)
((TControl*)Sender)->BeginDrag(false, 5);
)
if (Button == mbLeft) , Shift:
if

(Shift.Contains(saLeft))

...;

2. , , , ,
Alt, :
if ((Button =- mbLeft) SS (Shift.Contains(ssAlt)))
((TControl*)Sender)->BeginDrag(false, 5);
OnMouseEnter
,

TCustomLabel

typedef void (__closure *TNotifyEvent)(System:iTofcgect* Sender);


property Classes::TNotifyEvent OnMouseEnter

OnMouseEnter , . OnMouseEnter , -
. , , , ^6 C++Buttder 6

1122

17

OnMouscLcave. OnMouseEnter
((TLabel *)Sender)->Font->Color - clBlue;

OnMouseLeave
((TLabel *>Sender)->Font->Color = clBlack;

- .
OnMouseLeave
^
..
,
TCustomLabel

typedef void ( closure *TNotifyEvent) (-Systeift: :TObject* Sender)^property classes::TNotifyEvent OnMouseLeave

OnMouseLeave , -
, OnMou^eEnter
- , . OnMouseEnter.
OnMouseMove

TCantrol

enuro Classes 1 { ssShift, ssAlt, ssctrl, ssLeft, ssRight,


ssMiddle, ssDouble \;
typedef Set<Classes 1, ssShift, ssDouble> *TShiftState;
typedef void ( closure *TMouseMoveEvent)(
Systefti: :TObject* Sender,
Classes::TShiftState Shift,
int X, int Y ) ;
_property TMouseMoveEvent OnMouseMove

OnMauseMove , -
.
Shift, , ,
, (Shift, Ctrl
) . X Y
. Sender ( )
.
OnMouse.Move , -
. , C++Builder,
( -
) , -, .

if

(Shift.Contains(ssAlt))...

, Alt
, , , -
.

1t23

, , , ,
OnMouseUp

. . OnMouseDown OnMouseUp.
OnPaint
^___
Windows
TCustomForm, TPaintBox

typedef void

closure *TNotifyEvent)(System::TObjeot* Sender);

property-- Classes : :TNotifyEvent OnPaint

OnPaint , Windows . -
. . Canvas ClipRect. , .

, ,
BitMap, OnPaint :
Canvas->Draw(0,O,BitMap);
PaintBox
PaintBoxl->Canvas->Draw(0,0,BitMap);
ClipRect
, :
Canvas->CopyRect(Canvas->ClipRect, Bitmap->Canvas, canvas->ClipRect);

OnProgress

TGraphic, TImage, TPicture

enum TProgressStage {psStarting, psRunning, psEndingf;


typedef void (

closure *TProgressEvent)(
System: tTObject"* Sender,
TProgressStage Stage,
Byte PeroentDone,
bool RedrawNow,
const Windows:^TRect &R,
const AnsiString Msg);

property TProgressiSVent OnProgress

OnProgress , , , . , . OnProgress, Progress.

1124

17

Stage : , , . psStarting, psRimning


psEnding. , Stage = psStarting, , Stage =
psRunning Stage = psEnding. PercentDone ,
.
.
RedrawNow ,
. R ,
.
Msg . , Loading, Storing Reducing colors. Msg .

OnStartDrag
,

TControl

typedef void

(__closure *TStartDragEvent)(
System::TObject* Sender,
TDragObject* SDragOb]ect);
property TStartDragEvent OnStartDrag

OnStartDrag ,
, , , .. .
OnStartDrag -
, . Sender
,
.
DragObject NULL. , . TDragControlObject, C++Builder . , - ..

17.4
VCL
VCL C+-t-Builder "
, .
, .
,
.

, , , ,
TObject

VCL.
, , : ClassName, ClassNamels, ClassParent, Free, InheritsFrom

Exception

.
HelpContext Message, ,

TPersistent

VCL C++Builder,
. Assign

TComponent

.
Name - Owner

TControl

.
,
, , , , ..
,

TWinControl

TCustomEdit

.
, , , I
, - [
,
.

TCustomCombo- . Box

TButtonControl

TGraphicControl

, , , . Canvas ,

TMenu

TMenuItem

TCommonDialog

.
Execute

17

t126
TField

. :
AsFLoat, Aslnteger ..

TDataSet

(TTable, TQnery, TStoredProc .).



, C++Builder .

TStrings

AnsiString
C++Builder AnsiString , vcl/dstring.h Delphi. . AnsiString .
AnsiString ==, !=, >, <, >=, <=. . , , , , . ,
, , .
AnsiString . =, += () +. [ J. 1. , S1 - "", S l [ l ] '', Sl[2] '' ..
AnsiString . 14, . 14.4.2. AnsiString ( S1 ,
):
'

AnsiCompare

int
fastcall AnsiCompare(const AnsiString& rhs) const
SI rhs . Windows , . > 0 SI > rhs, < 0
SI < rhs 0 S1 = rhs

/
AnsiCompareIC

int
fastcall AnsiCompareIC(const AnsiString& rhs) const
, AnsiCompare,

AnsiLastChar

char*
fastcall AnsiLastChar() const
.

AnsiPos

int
fastcall AnsiPos(const AnsiString& subStr) const

subStr S1. 1. subStr S1, 0.

il

, , , ,

AnsiString

112?

/
__fastcall AnsiString(apryMeHT)
. :

const char* src

const AnsiString& src AnsiString src


,
const char* src,
len unsigned char len
src
const wchar_t* src


src wchar_t

int src


src

src
;
15

double src

c_str

char* _fastcall c_str()const


, , AnsiString

CurrToStr

static AnsiString __fastcall CurrToStr (Currency value)


value Currency
static AnsiString
fastcall CurrToStrF(Currency value,
TstringFloatFormat format, int digits)
value Currency ,
(. . TstringFloatFormat ).
. CurrToStrF 19

CurrToStrF

Delete

FloatToStrF

Format

void
fastcall Delete(int index, int count)
, index ,
count
static AnsiString
fastcall FloatToStrF(long double value,
TstringFloatFormat format, int precision, int digits)
value ,
(. . TstringFloatFormat }? precision digits
. 7
float, 15 double 18 Extended
static AnsiString
fastcall Format(const AnsiString& format,
const TVarRec *args, int size)
, format args

1128

17

FormatFloat

static AnsiString
fastcall FormatFloat(
const AnsiString& format, const long double& value)
value , format (. . 16, . 16.1.2.5)

Insert

void
fastcall Insert(const AnsiString& str, int index)
str, index

IntToHex

static AnsiString
fastcall IntToHex(int value, int digits)
value ,
digits

IsDelimiter

bool fastcall IsDelimiter (const AnsiString& delimiters,


int index) const
true, index , delimiters.

IsEmpty

bool
fastcall IsEmptyO const
true,

LastDelimiter

int __fastcall LastDelimiter(const AnsiString& delimiters) const


, delimiters. ,
AnsiString s "c:\\filename.ext";

s.LastDelimiter("\\.:" );

12 ( )
Length

int
fastcall Length() const

LowerCase

AnsiString
fastcall LowerCase() const
, .

Pos

int
fastcall Pos(const AnsiString& subStr) const

subStr S1. 1. subStr Sl^ 0. AnsiPos

SetLength

void
fastcall SetLengtb(int ne^vLength)
newLength . ,

StringOfChar

static AnsiString
fastcall StringOfChar(char ch, int count)
, ch count .
,

AnsiString s = AnsiString::StringOfChar('',

10);

, , , ,

Substring

AnsiString
fastcall SubString(int index, int count) const
,
index count

ToDouble

double
fastcall ToDonble(> const
. , EConvertError

Tolnt

int
fastcall Tolnt() const
. , EConvertError

ToIntDef

int
fastcall ToIntDef(int defaultValue) const
. , defaultValue

Trim

AnsiString
fastcall Trim() const
, ,

TrimLeft

AnsiString
fastcall TrimLeft() const
, ,

TrimRight

AnsiString
fastcall TrimRight() const
, ,

Unique

void
fastcall UniqueQ
, ..
(refcnt) 1. ,

UpperCase

AnsiString fastcall UpperCase() const


, .

WideChar

wchar_t* fastcall WideChar(wchar_t* dest, int destSize) const


dest wchar_t

WideCharBufSize

int
fastcall WideCharBufSize() const
, WideChar

Set
, Delphi,
VCL
vcl/sysset.h

1130

17

template<class T, unsigned char minEl, unsigned char maxEl>


class

declspec(delphiretttrn)

Set;

;
type
minval

( int, char )

maxval

( 255}

( 0)

Set .
- , , , , . ,

Set <char, 'A' , ' si;


Set <char, 'X', 'Z'> s2;

i f ( s i s2)

...

, si s2 .
Set , , (. . 14.6, . 14).
TBitmap
Windows {),
(HPALETTE)
TObject TPersistent TGraphtc
graphics

TBitmap Windows, .
,
, .

,
TBitmap.

Canvas

TCanvas

()
.
.

Empty

bool

, .
.

Handle

HBITMAP

GDI Windows. API


Windows.

, , , ,

HandleType

Height

ignorePalette

Modified
MaskHandle

Monochrome
Palette

PixelFormat

ScanLine

Transparent
TransparentColor
TransparentMode
Width

1131

enum TBitmapHandleType ,
DDB (Device Dependent Bit{bmDIB, bmDDB}
map ),
DIB (Device Independent Bitmap
). .

int
. , .
,
bool
. true , .
, bool
.
HBITMAP
GDI Windows. API Windows. .
, bool
( true).
HPALETTE
256 .
, Palette 0.
TPixelFormat
.
{pfDevice, pflbit, pf4bit,
pf8bit, pflSbit, pfl6bit,
pf24fiit, p32bit, pfCustom} , .

void *
DIBs
(Device Independent Bitmap ). .
,
bool
.
,
TColor

. TransparentMode.
enum TTransparentMode , TransparentColor {tmAuto, tmFixed}
.

int
. , .

1132

17

, TBitmap.

'

Assiea

, , Clipboard.

Dormant

Freelmage

, , , . . Dormant.

LoadFromClipboard1"
Format

Clipboard .

LoadFromFile

LoadFromResourcelD

LoadFromResourceName

LoadFromStream

Mask

ReleaseHandle

HBitmap TBitmap .

ReleaseMaskHandle

HBitmap
TBitmap .

ReleasePalette

HPalette TBitmap.

SaveToClipboardFormat

Clipboard .

SaveToFile

SaveToStream

OnChangB

OnProgress

TBrush
:
TObject TPersistent TGraphic&Object
graphics

, , , ,

1133

TBrush HBRUSH Winodws


. TBrush , , Brush.

Bitmap

TBitmap

, .

Color

TColor

. clWhite.

Handle

HBRUSH

, GDI Windows.

Style

TBrushStyle

TBrush He - . , Assign, .
-.

TBrush TGraphicsObject OnChange. , .


TBrush.

Imagel->
Canvas Imagel:
Imagel>Canvas->Brush->Style = bsCross;
Imagel->Canvas->Brush*>Color = clRed;
Imagel->Canvas->FillRect(Rect(0, 0, Imagel->Width, Imagel->Height));
FillRect .
TCanvas
(, ) ,
>
TObject TPersistent
t
graphics

TCanvas C++Builder.
:

, ,

, ,

TCanvas TControlCanvas TMetafileCanvas,
.

1134

17

,
TCanvas.

Brush

TBrush

CanvasOrientation

enum TCanvasOrientation ( }
{ coLeftToRight,
{ ) .
coRightToLeft }

ClipRect

TRect

, ,int.

CoDvMode

int

Fopt

TFont

Handle
LockCount

HDC

, ,

,
.

int

TPen

Pixels
TextFlaffs

TPoint
TCpipr
int

, TCanvas.

Arc

BrushCoov
Chord
CoDvRect


,
,
,

Draw

DrawFocusEficJ
Ellipse

,
,

, , , ,

1135

FiURect

,
Brush
,

,
>
,

FloodFill
FrameRect
LineTo
Lock
MoveTo

Ek


,
PolvBezierTo ,
Polygon
-

PolvBezier

Polyline
Rectangle

RoundRect


StretchDraw ,
TextExtent ,
,
TextHeiffht

,
TextOut

,
TextRect
,
,
TextWidth

TryLock
, ,

Unlock
LockCount, , LockCount
0

OnChantre

OnChanging

36

17

.^________

TColor
4


Graphics

enum TColor

{clMin0x7fff ffff-1,

cIMax-0x7fffffff} ,-

TColor . Color , TFont. , ..


Graphics TColor.
( clBlue ),
, Windows (, cIBtnFace
). . . Color,
TColor 4- , , . ,
OxOOFFOOOO , OxOOOOFFQO ,
SOOOOOOFF . 0x00000000 , OxOOFFFFFF .
(00),
. (), . (02),

.
TCursor
. Cursor
TDragMode
. DragMode.

,.

TFont

TObject TPeraistent TGraphicsObject

graphics
^

TFont , ,
: , , (, ) .. Font.
Name.
,
Charset .
Name, CharSet, Pitch, Size
, , Windows .
TFont
: Color = clWindowText, Name = MS Sans Serif, Size 8, Pitch =
fpDefault, CharSet = DEFAULT_CHARSET PixelsPerlnch.

1137

, , , ,

Charset

TFontCharset

Color

TColor

FontAdapter

_di_IChangeNotifier
ActiveX

Handle

HFONT

, API Windows,
.

Height

int

Name

System::AnsiString

()

Pitch

enum TFontPitch {
fpDefault, fpVariab-
le, fpFixed }

PixelsPerlnch int

'


.
,

. .

Size

int

()

Style

enum TFontStyle
{ fsBold, fsltalic,
fsUnderline, fsStrikeOut }

: , , ,

TFont , , . :
TFont . PixelsPerlnch Assign .

TFont OnChange TGraphicsObiect.


TFont . .
Font.

TObject TPersistent TGraphicsObject


graphics

Windows
TCanvas.

1138

i/

<

Color

TColor

. cffilaek

Handle

HPBN

. API Windows

Mode

TPenMode

Style

TPenStyle

Width

int

. SisM

- . !, Assign, . -.

TGraphicsObiect OnCfaange. .
TPicture
__*__
_

i
, , ,
TObject TPersistent
graphics

TPicture
TGraphic. Graphic TPteture
LoadFroinFile Sav&TqFile. .
, ,
, Bitmap. Icjut Metafile, .
( ")
.

Graphic. , , Imagel->Picture>
Graphic Imagel>Picture>Bitmap ,
.
TPictare Clipboard Assign TClipboard.
/

TPicture :

Bitmap

TBitmap

( .bmp)

Graphic

TGraphic

, ,

, , , ,

113S

Height

int

, .

Icon

TIcon


( )

Metafile

TMetafile ( .emf)

Width

int

, . .

, TPicture.

LoadFromCliDboardFormat Clipboard


LoadFromFile
RegisterClipboardFormat
Clipboard LoadFromClipboardFormat
EegisterFileFormat

LoadFromFile

RegisterFileFormatRes

LoadFromFile

SaveToClipboardFormat

Clipboard

SaveToFile

SupportsClipboardFormat

, Clipboard

Clipboard

UnregisterGraphicClass

OnChanffe

OnPro^ress

TPoint

1140

___________

17

Windows
()
struct TPoint
{
i n t x;
i n t ;
>;

TPoint . ,

. , ,
.
TPoint Point (. . 16.3.3, . 16), TPoint.
, .
C++Builder
Windows.cpp.
TRect -^


Windows
()
struct TRect
{
int Left;
int Top;
int Right;
int Bottom;
};

,
, , ,
TPoint.
.
.
- WidthO HeightQ,
. "==" " ! = " .
TRect Rect,
, , Left, Top, Right, Bottom,
Bounds, Left ,
AWidth AHeight. . . 16, . 16.3.3.

TStringFloatFormat
TStringFloatFormat

enum TStringFloatFormat {sffGeneral, sffExpuhent, sffFixed,


sffNumber, sffCurrency };

, , , ,

1141

sffGeneral

: .
. .
0.00001.
( 0 4).

sffExponent .
-d.ddd...E+dddd. '' .
. ( ) . ''
+ -. ( )
0 4.
sffFixed

. -ddd.ddd.... '' .
.
( 0 18).
, .

sffNumber

.
-d,ddd,ddd.ddd.... sffFixed
.

sffCurrency

, . Windows (
CurreneyString, Currency Format, NegCurrFormat,
ThousandSeparator, DecimalSeparator). ( 0 18).

,
DecimalSeparator ThousandSeparator.
TStringList

TObject TPersistent TStrings
classes

TStringList TStrinys. -'


:


, TStringList.

42

17

Capacity

int

, ,

, , ,

CaseSensitive bool
Count

int

Objects
[int Index]
Duplicates

System::
,
TObject *
Strings
enum TDupIicates , , { duplgnore,
.
dupAccept,
duplgnore dupError }
, dupAccept , dupError EListError , . dupAccept
dupError . Duplicates

Sorted

bool

Strings
[int Index]

System::
AnsiString

.
0

TStringList TStrings , CommaText, Names, StringsAdapter, Text, Values.

TStringList TStrings , Add. Clear. Delete.


Exchange. IndexOf. Insert . TStringList :

bool Find(const System::


, S AnsiString S, int &Index) , , , Index . IndexOf
Sort
, Sorted
false,
. Sorted = true,

TStrings
, C++Builder .
TObject TPersistent

, , , ,

1143

classes

TStringff ,
:



>

, Strings.

Capacity

int

,
. TStrings Capacity Count, Capacity
. , TStrings, Capacity

CommaText AnsiString , SDF (system data format). ,


,
.
, ( )
Count
DelimitedText

int

AnsiString

, , QuoteChar, , , , Delimiter

Delimiter

char

, DelimitedText

Names
[int Index]

System::
AnsiString

, =
. , ,
.mi. Names ,
.
= , .

Objects
[int Index]

TObject *

,
Strings. TStrings Objects
, , TStrings

OuoteChar

char

, DelimitedText

Strings
[int Index]

System::
AnsiString

.
0

17

1144

Text

System::
AnsiString

Values
[System::
AnsiString
Name]

System::
AnsiString

,
= . , , .ini. Values , Name. Name ,

, TStrings.

int Add<
const System::AnsiString S)

int AddObject(
const System::AnsiString S,
System::TObject* AObject)

S
AObject.

Strings
TStrings
. Add,

void AddStrings(
TStrings* Strings)
void Append(
'
const System::AnsiString S)

S . .

,

void Clear(void)
void Deletefint Index)


Index

bool Equals(TStrings* Strings)

Strings. true

void Exchanged
int Indexl, int Index2) Indexl Index2
char * GetText (void)
,
,
Text
S.
, -1
int IndexOfName(const
, System::AnsiString Name) = .
, , .ini.
, Name.
, -1

intIadjesQf(
const System::AnsiString S)

, , , ,

1145

int lndexOfObject(
System::TObjeet* AObject)

, AObject. , -1

void Insert( int Index,


const System::AnsiString S)

S
Index. Index = 0,

void InsertObject(int Index,


const System::AnsiString S,
System::TObject* AObject)

S
Index
AObject. Index = 0,

void LoadFromFiIe(const
System::AnsiString File Name) FileName
void LoadFromStream(
TStream* Stream) Stream
void Move(int Curlndex,
Cuint Newlndex) rlndex, Newlndex
void SaveToFile<
const System::
FileName
AnsiStrmg FileName)
void SaveToStream(
Text TStream* Stream) Stream
void SetText(char * Text)
Text

17.5 ,

VCL
, , -
. ,
,
, - .
ActionList
ActionMainMenuBar
ActionManager
ActionToolBar
ADOCommand
ADOConnection
ADODataSet
ADOQuery
ADOStoredProc
ADOTable
Animate
Applet Application
AppletModule

3.2, 4.1 , 4.3 , 4.4, 4, 5. 1,4.5.2, 4.6,8.2


1.8, 4.1 , 4 .3 , 4.5, 5. 1. 1
1.8, 4.1 , 4 .3 , 4 .5, 5. 1. 1, 5.1.6
1.8, 4.1 , 4 .3 , 4.5, 5. 1. 1
10.4.1
10.4.1, 10 .4,.2, 10 .4. 3, 10.4.4
10.4.1
10.4.1, 10 .4 .4
10.4.1, 10 .4 .4
10.4.1, 10 .4 2 , 10 .4. 4
6.2.3
2.3.2.2
2.3.2.2

1146

Application
ApplicationEvents
BatchMove
Bevel
BDEClientDataSet
BitBtn
Button
CCalendar
CDirectoryOutline
CGauge
Chart
Chartfx
Checkbox
CheckListBox
ClientDataSet
ClientSocket
ColorDialog
ColorBox
ComboBox
ComboBoxEx
ControlBar
CoolBar
CorbaDataModule
CustomizeDlg
Database
DataModule
DataSetProvider
DataSetPageProducer
DataSetTableProdncer
DataSource
DateTimePicker
DBCheckBox
DBComboBox
DBCtrlGrid
DBEdit
DBGrid
J

DBImage
DBListBox
DBLookupCombo
DBLookupComboBox
DBLookupList
DBLookupListBox
DBMemo
DBNavigator
DBRadioGroup
DBRichEdit
DBText
DDEClientConv

17
1.9.3,1.6.2, 4.1, 4.6, 5.1.9, 5.3.2.1, 5.5.1, 5.5.3,
5.5.4 5.5.5,7.2.2,7.5.3.5, 7.9.1,8.1,16.6.2,16.7.2.3
3.2.3, 3.9.7, 4.1, 4.6, 5.1.9, 5.3.2.1, 8.2, 11.3
9.9
3.9.2
1.8, 9.4, 9.14.1, 9.14.2, 94.6
3.7.1, 3.7,2, 5.5.2, 6.1.2.3
3.7.1, 3.7.2, 3.9.7
3.3.3
3.10.3
3.6.6
3.6.4, 5.6.2
3.6.5, 5.6.2
3.7.1, 3.7.4, 3.7.5, 5.3.1.1, 7.8.3, 8.1, 8.3.4, 9.12
1.8, 3.2.5, 3.7.5
9.14.1, 9.14.2, 9.14.3, 9.14.4, 9.14.5, 10.7
12.12
3.10.5
1.8, 3.10.5
3.2.5, 3.4, 3.9.4, 3.10.3, 4.7, 7.5.3.2, 7.8.3, 8.1,
9.5.5, 9.8, 9.12, 10.1.6.4, 10.1,7, 12.4
1.8,3.2.5
3.9.5, 5.1.1
3.9.5, 5.1.1, 12.4
10.7
1.8, 4.1, 4.5.1, 4.5.2
9.4, 9.8, 9.14.6, 10.2.2, 10.4.1
4.7, 9.13
9.14.4, 9.14.5, 9.14.6, 10.6.1, 10.6.3, 10.7
12.10.2
12.10.1, 12.10.2
9.4, 9,5.1, 9.6, 9.7, 9.8, 9.10.1, 9.10.2, 9.12,
9.13, 9.14.5, 10.1.2.1, 10.1.6.1, 10.1.6.3, 10.1.7,
10.4.1, 10.4.4, 10.5.1, 11.2, 11.3
3.3.3, 3.4
9.5.2, 9.7
9.10.2
9.7, 9.10.1
9.4, 9.5.2, 9.7, 9.12, 10.4.1, 11.3
9.4, 9,5.1, 9.5.5, 9.6, 9.7, 9.8, 9.10, 9.10.2,
9.12, 9.14.5, 10.1.2.1, 10.1.6.1, 10.1.6.3, 10.1.6.5,
10.1.7, 10.4.1
6.1.1.1, 9.5.2, 9.7, 9.12, 9.14.5, 11.3
9.10.2
3.1
9.10.2
3.1
9.10.2
9.5.2, 9.7, 9.12
9.5.1, 9.14.5, 10.1.6.5
9.7
9.7, 11.3
9.4, 9.7, 9.10.1, 9.14.5
7.5.1, 7.5.2, 7.5.3.2, 7.5.3.3, 7.5.3.4, 7.5.3.5

, , , ,
DDECUentltem
DDEServerCoHv
DDEServerltem
DecisionCube
DecisionGraph
DecisionGrid
DecisionPivot
DecisionQuery
DecisionSource
DirectoryListBox
DrawGrid
DriveComboBox
Edit

FIBook
FileListBox
FilterComboBox
FindDialog
FontDialog
Form
Frame
GroupBox
Header
HeaderControl
HotKey
IBDatabase
IBDatabaselnfo
IBDataSet
IBEvents
IBQuery
IBSQL
IBSQLMonitor
IBStoredProc
IBTable
IBTransaction
IBUpdateSQL
IconView
Image
ImageList
Label
LabeledEdit
LCDNumber
List Box
ListView

t?47

7.5.1, 7.5.3.2, 7.5.3.3, 7.5.3.4, 7.5.3.5


7,5.1, 7.5.2, 7.5.3.1, 7.5.3.5
7.5.1, 7.5.2r 7.5.3.1, 7.5.3.3, 7.5.3.4, 7.5.3.5
11.1.1
11.1.1, 11.1.4
11.1.1, 11.1.2
11.1.1, 11.1.3
11.1.1
11.1.1, 11.1.3, 11.1.4
3.10.3
3.6.2
3.10.3
3.2.2, 3.2.3, 3.3.2^3.4, 3.9.5, 3.9.7, 3.10.S, 4.6,
5.1.8, 5.1.9, 5.2.5, 5.3.1.2, 5.3.2.2, 5.5.3, 7.2.2,
7.2.3, 7.5.3.1, 7.5.3,2, 7.5.3.3, 7.5.3.4, 7.5.3.5,
7.8.2, 7.8.3, 7.9.2, 7.9.3, 8.1, 8.2, 8.3.1, 8.4.4,
9.11.4, 9.12, 10.2.2, 10.3.5.2
3.3.4, 3.6.5
3.10.3
3.10.3
3.10.7
3.2.4, 3.10.4, 5.1.5 , 5.7.5!, 5.7.3, 11.2
2.4, 5.1.3, 5.2.4, 5..5, 5.6 .1, 6.1.1.2,6.1.7
3.9.7, 5.1.7
3.7.1, 3.7.4, 3.9.2, 3.9.7
3.1,3.7.7
3.1, 3.7.7
3.8.3
10.5.1, 10.5.2, 10.J).3
10.5.1
10.5.1
10.5.1
10.5.1, 10.5.3
10.5.1
10.5.1
10.5.1, 10.5.3
10.5.1, 10.5.3
10.5.1, 10.5.2, 10.55.3
10.5.1
8.1

5.4.3, 5.5.3, 5.6.4, 6.1.1. 1, 6.1.1.2, 6.1.1.4,


6.1.3.1, 6.1.3.2, 6.., 6.1.3.4, 6.1.4, 6.1.5.2,
6.1.6, 6.1.7, 6.2.2, 7.9.2, 7.9.3
3.2.5, 3.5.2, 3.5.3, 3.6.2, 3.7.7, 3.8.1, 3.9.3,
3.9.4, 3.9.5, 4.1, 4 .2, 4.3 , 4.4, 4.5,8.1,8.2, 11.3,
12.4
1.6, 2.2.1, 2.2.2, 3 .2.2, 3 .2.6, 3.9.7, 3.10.3,
5.5.3,5.7.1,6.2.4, 7.4.3, 7.4.4,7.5.3.5,7.6.2,7.6.3
7.8.2, 8.3.4, 12.11. 1
1.8, 2.2.2, 3.2.3
8.1

1.8, 1.9.6.2, 3.2.5, 3.4, 3 .8.3, 5.2.1, 5.2.2,


5.3.1.2, 5.4.1, 5.7.:L, 8.1
3.5.3

1148
MainMenu
MaskEdit
MediaPlayer
Memo
MonthCalendar
NMDayTime
NMFTP
NMMsg
NMMSGServ
NMNNTP
NMPOP3
NMSMTP
NMStrm
NMStrmServ
NMTime
NMURL
NMUUProcessor
NoteBook
OLEContainer
OpenDialog
OpenPictureDialog
Outline
PageControl
PageProducer
PageSeroller
PaintBox
Panel
PopupMenu
PrintDialog
Printer
PrinterSetupDialog
ProgressBar
QRDBImage
QRDBRichText
QRDBText
QRImage
QRLahel
QRMemo
QRRichText

QRShape
QRSnbDetail
QRSysData
Query
QueryTableProducer
QuickRep
RadioButton

3.5.3, 3.8.1, 3.8.8, 3.10.2, 4.1, 4.5.2, 5.1.1,


5.1.6, 5.42, 5.6.4, 5.5.5, 5.7.1, 6.1.4, 6.2.4, 7.7,
8.2, 11.2, 11.3, 12.4
3.2.2, 3.2.3, 3.4
6.2.4
2.81, 3.2.4, 3.3.3, 3.10.4, 3.10.5, 3.10.7,
4.5.2, 5.2.1, 5.3.1.2, 5.4.1, 5.4.2, 7.2.2, 7.5.3.2,
7.5.3.3, 7.5.3.5, 7.9u3, 10.1.7, 12.11.1
3.3.3, 7.8.4
12.12
12.12
12.12
12.12
12.12
12.12
122
12.12
12.12
12.12
12.12
12.12
3.1, 3.9.3
7.7
8.9.7, 3.10.2, 5.5.5, 6.2.1.2, 6.2.3, 6.2.4, 7.2.3,
7.7, 12.4
3.10.2, 6.1.1.2, 6.1.1.4, 6.1.4, 6.1.7, 6.2.2
3.1, 3.5.2
3.1, 3.9.3, 5.4.2, 9.12
12.9, 12.10,3
3.9.4, 5.1.1
6.1.7
2.2.2, 3.2.2, 3.9.2, 3.9.3, 3.9.4, 4.7, 5.1.9,
5.2.1, 5.2.2, 5.2.5, 5.4.2
3.8.1, 3.8.2, 3.9.4, 4.5.2, 5.1.1, 5.1.6
0.6
3.10.6,5.6.4
3.10.6
3.6.6, 11.3
11.2
11.2
11.2
11.2
11.2
11.2
11.2
11.2
11.2
11.2
9.4, 9.8, 9.14,4,10.1.2.1, 10.1.2.2, 10.1.6, 10.1.7,
10.2.2,10.2.4, .5.3, 10.4.1, 10.4.4,' 10.5.1,
11.2, 11.3, 12.10.3
12.10.3
11.2.
3.7.1, 3.7.4, 3.9.2, 5.3.1.1

, , , ,
ItadioGroup
ReplaceDialog
RichEdit
SaveDialog
SavePictureDialog
Screen
Scrollbar
ScrollBox
ServerSocket
Session
Shape
SpeedButton
CSpinEdit
Splitter
SQLConnection
SQLDataSet
SQLQuery
SQLStoredProc
SQLTable
SQLClientDataSet
StaticText
StatusBar
StoredProc
StringGrid
TabbedNoteBook
TabControl
Table

TabSet
TextBrowser
TextViewer
Timer
ToolBar
TrackBar
Tree View
UpdateSQL
UpDown
ValueListEditor
WebBrowser
WebModule
WordApplication
WordDocument
WordFont
WordLetterContent
WordParagraphFormat

1149

3.7.1, 3.7.4, 3.9.2, 5.3.1.1


3.10.7
3.2.4, 3.9.6, 3.10.2, 3.10.4, 3.10.7, 4.4, 4.7,
5.3.1.2, 5.5.1, 5.5.5, 5.6.2, 11.2, 14.9.1
3.10.2, 5.5.5, 7.7
3.10.2, 6.1.6
4.1, 4.7, 5.1.5, 6.1.2.4, 6.1.6
3.7.6
3.9.2, 3.9.4
12.12
9.4, 9.8, 9.13
3.6.3
3.7.1, 3.7.2, 3.7.3, 3.9.2, 3.9.4, 6.1.2.3, 6.1.4,
7.5.3.2
3.3.2, 3.3.3, 3.4, 3.9.4, 7.4.4, 8.1, 9.5.5, 14.4.1
3.9.2, 5.2.3
10.6.1, 10.6.2, 10.6.3
10.6.1, 10.6.3
10.6.1, 10.6.3
10.6.1, 10.6.3
10.6.1, 10.6.3
1.8, 10.6.1, 10.6.3
3.2.2, 5.2.1, 5.2.2
3.9.6, 4.6, 5.1.1, 5.1.9, 5.7.1, 8.2, 11.3, 12.4
9.4, 10.3.5.2, 10.3.5.3
3.2.6, 3.4, 3.6.2, 12.11.1
3.1, 3.9.3
3.1, 3.9.3
9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 9.10, 9.11, 9.12,
9.13, 9.14.2, 9.14.3, 9.14.4, 9.14.5, 10.1.2.1,
10.1.6.1, 10.2.2, 10.2.4, 10.4.1, 11.2, 12.10.1,
12.10.2, 12.10.3
3.1, 3.9.3
8.1
8.1

3.7.8, 5.5.3, 6.2.2, 7.6.3


3.2.5, 3.9.4, 3.9.5, 4.1, 4.3, 4.4, 4.5.2, 5.1.1,
7.7, 8.2, 11.3, 12.4
3.7.6, 5.3.1.2
3.1, 3.5.2
10.1.6.5
3.3.2
1.8, 3.2.5, 3.4
12.4
12.6.1, 12.6.2, 12.8.2, 12.9, 12.10.2, 12.10.3
7.9.1, 7.9.2, 7.9.3, 11.3
7.9.2, 7.9.3, 11.3
7.9.2, 7.9.3, 11.3
7.9.2
7.9.2, 7.9.3, 11.3

1150


C++Builder 6
i. <
C++Builder , ,
. , ,
.
1. . . C++Builder 6. . : , 2002
, , C++Builder 6 C++. ,
, . : , ,
.
.
. :
C++ C++ ( )
C++ C++Builder 6 (
),
( )
C++Builder 6 (
)
, ,
.
C++Builder 6, .
, , .
, .
, , . , .
( ) , .
2. . . C++Bnilder 6. :
, 2003
( , , Delphi 6). , C++Builder, , . ,
: ( ,
, ..),
C++Builder 6; C++Builder 6;
; , . , .
,
. -

-1, , , ,

1151

, .
3. C++Builder 6
, . C+4-Builder Help | Customize (. 2.7.6)
F1
. , , ,
[1]. , , C++Builder, ,
1' , (, ).
C+4-Builder ...
. ,
, (
2500 , ). .
, , , (
, , ,
). : http://labl8.ipu.rssi.ru/help2/. ., 3-4 , , . , C+4-Builder 5. , , ,
C+4-Builder 6.
,

e-mail. , e-mail
- . , .
4. .. ++ilder 5 : , 2001
Sid 2001 . ( 100)
C+4-Builder. , , C++Builder 6.
, , . ,
. , , , . 3 .

-

C++Builder 6


21.10.2002. 70x100/16. . . . 93,6
. .
. 4000 . 2519
, 2003 .
103473, , , 16
065249 26 1997

. 432980, . , . , 14

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