Академический Документы
Профессиональный Документы
Культура Документы
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++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.
, . , , , - , , .
_.._______*.
.
, ,
. .
, , , 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;
:
/
^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.
______________
__
:
//
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
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 ;
.
, , . .
( )
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);
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;
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
true, string. :
if (Sender->ClassNameIs("TLabel") )
, -,
. ScaleBy, TWinControl. , Sender, TWinControl (, TLabel, TWinControl),
ScaleBy .
, , .
, ,
, ,
, . , ScaleBy, ,
TWinControl.
InheritsFroin,
TObject , , .
:
bool
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()
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
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
( )
Help
s)
C++Builder Help
View Units
(Ctrl-F 12)
View Forms
(Shift- F12)
File
New Form
Run
(F9)
Run
.
,
>
CPU.
C++Builder 6
67
View | Desktops |
Save Desktop
View | Desktops |
Set Debug Desktop
WebSnup
Web ( Delphi 6)
CORBA
,
IDL
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..
68
C++Builder 6 :
Standard
Additional
Win32
System
, , ,
Data Access
, C++Builder 6 ,
, BDE
Data Controls
dbExpress
dbExpress ( C++Builder 6)
DataSnap
, (
C++Builder 6 C++Builder)
BDE
ADO
InterBase
WebServices
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
Samples
, ,
ActiveX
ActiveX
COM+
, +,
+
C++Builder 6
--
69
Servers
( C++Builder 6,
C++Builder 5 , Office2k)
indyClienfs
IndyServers
IndyMisk
Internet
Direct (Indy) ( C++Builder 6)
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
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
...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
72
2.1.7
) 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
. , 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.
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)
, .
(.?)
, , Windows, C++Builder:
(.)
Windows,
C++Builder.
Windows
.
(.wmf, , )
( ) ., .h, .dfm, .bpr, .res. , , , ,
. C++Builder .
.
WinMain, . ++ilder . ,
, , . . 1.9.3.
,
.. C++Builder . , Project | View Source.
.
,...,
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
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
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>
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
, .
, , ,
C++Builder,
. . ,
, ,
.
,
, .
..-.
.,
- , , C++Builder no .
Project!, . , . ,
, Project!.
-~.~
.-..-.
. 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
New () .
Remove () ,
. ,
. .,
. , , .
, . ,
Open (), Remove From Project ( ), Save
(), Save As ( ) . , ., , ,
, Add ( ), Remove File (
, ), Save ( ) .
.
, ^
New ,
C++Builder 6
91
92
,
C++Builder 5 -
. . ,
, .. .
. 15.9. .
,
.
, . . ,
, Edit Local Options. (. . 15.9), , . -
, ,
. (. , . 15.15) ,
Right Click to Revert. , ,
, . . Revert All .
, .
Change Override Color _ .
- ,
. , .
;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
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- ^ ^ -
'
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^
J j
2.3.1.0
;
?-*.
.
-
__
C++Builder 6
97
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
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 . , .
, , . . . . , , .
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.
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!
OK
Cancel
Help
; Horizontal
j " No change
> ff Left sides
Centers
<~ HigN sides
Space equally
! **" Center h window
|
OK
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,
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 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 [
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
Pages:
Forms
Dialogs
Proiects
Data Modue
ls
1
Web Documents
WebSnap
WebServices
[Object Repository]
QbiectsfiddPage..
Celete Page
Page
EditObrect.
Ddete Detect
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
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
.
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
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
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
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
"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
i n t 1;
f n r | l - 0;
i < 50;
;\Unil1 cpp/_-i
.
Ctrl-F2
.
126
, , , , , . , , .. ! ,
, , . , , , .. .
, .
Run | Run (
, F9), , , .
(. 2.38) ,
. , .
. 2.38
-Si
_____
,
.
, , - .
.
, , :
, .
. C++Builder 6 Tooltip Expression Evaluation.
, , , : =1+308.
. , .
, .
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
^ Memory Dump
o,nt B
*
Default
Cancel
Help
C++Builder 6
129
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
Shift+F7
...)
F4
Run to Cursor
( )
, .
131
C++Builder 6
Shift+F8
, ,
.
,
.
( )
. 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
,
:
()
()
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
134
( 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
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
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*'
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
. 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);
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
, ,
, . , , , .
#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);
)
, , . , ,
.
- , -
-
, . ,
, , , , 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
(
)
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")
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,
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);
150
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
, -
, ,
.
, 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
ilesl Input.
555-12-12
123456
V-ll 12345B
01 03 02
03 02
210515
13:45
Cancel
Help
C++Builder
1!55
. 3.3 , . 3.2
.
. :
!\(999\)
000-00-00;0;__
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;
J T O - E?E
RichEditj
i :
-1
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");
160
RichEdit Windows,
,
(, ), ..
. C++Builder [2], [3].
-=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
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
fastcall TForml::ListBoxlMeasureItera(
TWinControl "Control,
int Index, int SHeight)
(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
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
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
3.2.6 StringGrid
StringGrid (. . 3.12) ,
. . , . , ,
.
.
StringGrid . . 3.6.2 ,
.
, :
System:: AnSiString Cells
[int ACol][int ARow]
, ACol ARow
,
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++)
, . 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
_|
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));
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
-.;""
"
'*<!.
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
1
2
3
Item
Properties . 3.19. Text , -
178
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, "") ;
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
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
{
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
(
Accept - (Source = Listviewl);
void
{
((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?
+
188
ACol AKow , 0,
. , . ,
DrawGridl->Canvas->CopyRect(DrawGridl->CellRect(1,1),
BitMap->Carwas,Rect(0,0,BitMap->Height,BitMap->Width));
)
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
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
. 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
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
" .
"
:
196
3.6.6
ProgressBar CGauge
ProgressBar Win32 CGauge Samples , , , , , .. ProgressBar CGauge . 3.31.
. 3.31
ProgressBar CGauge
C++Builder
197
, :
ProgressBar CGauge
MaxValue
Min
Min Value
(Position, Progress), .
Position
Progress
Smooth
Step
,
Steplt. 10.
: pbHorizontaJ , pbVertical . pb Vertical, (. . 3.31 ).
Orientation
ForeColor
ShowText
Kind
: gkHorizontalBar
, gkVerticalBar ,
gkPie , gkNeedle
, gkText .
ProgressBar CGauge.
: Count, Current. :
CGaugel->MaxValue = Count;
CGaugel->Progress = Current;
198
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.
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
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
C+-i Builder
205
CheckListBoxl , (,
0).
,
- (
).
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
:
.
scPageUp,
scPageDown
:
PageUp PogeDown.
scPosition
scTrack
scTop,
scBottom
scEndScroll
ScrollPos , , ,
, ScrollPos.
208
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
.,,
,..
. 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"
.
|
,
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
)
//
void
fastcall TForm2::LiatBox2Click(TObjsct *Sender)
(
/* ListBox2
HotKeyl */
HotKeyl->HotKey = Forml->MainMenul->Iterns->Itema [
LiatBoxl->ItemIndex]->Items[
ListBox2->ltemIndex]->shortCut;
)
//
/*
*/
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
|&
2 j @ 3
: "
: (
t?
f"
[?
222
PageControl . , .
: New Page , Next Page , Previous Page .
TTabSheet.
, , .. , ,
, , . :
Name
Caption
Pagelndex
Imagelndex
PageControl :
Style
MultiLine
, ,
( . 3.42
, MultiLine = false, true; MultiLine = false
C++Builder).
TabPosition
TabHeight
TabWidth
. 0,
.
Images
ScrollOpposite
( , ).
ActivePage
Pages
[int Index]
( 0).
.
PageCount
. .
, ,
, , .
C++Builder
223
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
+-Builder
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
:
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
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
*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);
}
!=
"")
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
'ipg
"ipeg
Bitmaps (*.bmp)
*.bmp
Icons (*.ico)
jco
*.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
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
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
frShowHelp
frWholeWord
,
.
, .
FindDialog ReplaceDialog , . .
.
OnFind, , ,
OnReplace, ,
. OnReplace , , frReplace frReplaceAll.
RichEdit , FindText, :
int
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
subStr , . 1.
subStr , 0.
AnsiString:
Substring LowerCase. :
AnsiString
, 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
// " ",
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
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
, ,
.
Stretch
,
. .
Center
, , .
TImageList :
Height
Integer
Width
Integer
AllocBy
Integer
, .
Count
Integer
.
.
.
C++Builder
[3].
ImageList.
- , . 6,
.
, Draw:
void
(. . 6.1.3) Canvas ,
Index. X Y
. Enabled , , ( false), . Enabled true,
.
Draw . . 3.2.5 3.6.2, . 3.
void
void
Index Image.
.
:
int
int
int
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
, 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 () ;
)
268
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
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
.
. Other
4.5.2
. ,
Memo,
, , ,
,
. , , , . , , , , , .
,
. . 4.9 .
. 4.9
Jr
43 , > *
276
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
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
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
InstanceClass ,
classic!, a Reference ( ). :
Application->CreateForm(
classid(TForm2),
SForm2);
Terminate . , Application->Terminate()
Close .
- , , , Application>Terminate().
Minimize ,
Windows.
.
HelpFile, . HelpContext:
bool
Context. , . Helpjump:
281
bool
fastcall HelpJump(const System::AnsiString JumpID);
, JumpID
#
, , .
HelpCommand:
bool
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,
293
';
BdSl>ite bsToolWmdow
Botdetlcons {biuisteniMenu.
bjMwmBel
'
BorderStyle *= bsSingle
(Barderlcons.byMaximize = false]. , , .
BorderStyle = bsDialog. BorderStyle = bsSingle,
( Borderlcons.byMoximize = false). -'
, - , ,
.
, , BorderStyle = bsNone. , -
.
WindowState ,
.
:
wsNormal
( WindowState )
wsMinimized
wsMaximized
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
Default
OK
Cancel
Help
FormStyle,
:
fsNormal
. FormStyle
.
fsMDIForm
MDI, .. , .
296
fsMDIChild
fsStayOnTop
MDI.
, Windows.
...--..~*~._,_._-~-
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,
! ..,
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
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
{
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();
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
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
320
(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
(
ScaleBy(100,101);
}
321
5.3.2
5.3.2.1
C++Builder ,
. :
OnKeyDown
.
, , ,
. ,
OnKeyPress
. , ,
,
.
OnKeyUp
.
, ,
, .
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
, , Key, . , , , a char . , ,
, , , , .
.
, , , "" "" (), "" "" (). OnKeyPress :
if
((Key
==
'')
I!
(Key
= = ' ' ) ) . .
, . switch (. .
13.8.1.2, . 13):
switch (Key)
{
break;
325
,
.
, ,
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
'
f a s t c a l l TForml::ListBoxlMouseDown(TObject Sender,
TMouseButton Button, TShiftState Shift, i n t X, i n t Y)
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)
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
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]
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
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
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;
.
.
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)
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 ) ;
5.5
5.5.1
, .
, , .
- . File | New Form
, . 2.4.
. . -,
.
-, . -, , ,
, ,
( ).
, ( ,
), . , .
.
(, ), .
. MDI , , .
, , , Project | Options
. (Project Options) Forms, . 5.13.
. 5.13
Forms
341
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);
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
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
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();
. 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
. ' 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();
, .
,
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
();
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");
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
Resource Scripis
) PlqeclLDR
d
- \^ Resource Scripts
*] Proiicfl.DR
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
, . ,
.
. , , , - - . , , ,
Left, Right, Width, Height, . 5.19.
.
.
, ,
.
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
i ^ Qttpby eeleefon
f? Aulornafcali' isfn^s
MsceHaieous
p" ^ save files
; grfftrnal Editor - " J !
Help
Resource DLL Wizard. :
Automatic repository query
363
- , 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
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
, .
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
bool CanCreate);
Key, .
Key . Key
, , RootKey.
CanCreate , Key,
. KEY_ALL_ACCESS. .
: WriteInteger, WriteFloat, WriteBool, WriteString .
. :
void
void
, :
, .
.
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
-_
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
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);
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
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 :
jpg. jpeg
(Bitmaps)
.bmp
.ico
Enhanced Metafiles
.emf
Metafiles
.wmf
fastcall Assign(TPersistent*
Source);
377
....
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.
fi
()
i;:
379
File, Open
, New
. New, ,
, :
Resource File (.res)
, , ..
, , ..
, ,
.
, , , ,
, .
, ,
, ,
. ,
.
, , , ,
. , .
. . ,
.
.
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)
*! "
*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
~ 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
,
, . , :
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;
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);
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);
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(" ");
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);
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
SND_NOSTOP
,
, , , PlaySound
false, .
, PlaySound
,
.
SND_NOWAIT
, .
SND_PURGE
,
. pszSound 0,
. pszSound 0,
, .
SND_SYNC
. PlaySound .
'
410
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, ,
.
SND_PURGE);
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();
)
. , . 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
.
, 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
//
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
int Count);
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;
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
, .
(10, 10),
, 200.
MediaPlayer OnClick OnNotify.
-
enura TMPBtnType (btPlay, btPause, btstop, btNext,
btPrev, btstep, btBack, btRecord,
void
btEject);
423
, .
, ,
MediaPlayer. .
. MediaPlayer, MainMenu OpenDialog. OpenDialog , , :
(*.wav,*.mid,*.avi)
(*.wav,*.mid)
*.wav;*.mid
(*.avi)
*.avi
: .
OnClick
if (OpenDialogl->Execute())
MediaPIayerl->FileName
MediaPlayerl->Open() ;
OpenDialogl->FileName;
. 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
"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 .
, ,
429
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)
, .
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))
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" //
/
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);
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.
ERROR_BAD_FORMAT
11
. (,
Win32 .).
ERROR_FILE_NOT_FOUND
ERROR_PATH_NOT_FOUND 3
, ,
433
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
.
, .
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
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 " , " " ) ;
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
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 ) ;
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
// UlMess2. cpp
void
fastcall TForml::OnMyPost(TMessageS a)
15 C++Builder 6
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
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
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
SetLink OpenLink , DdeClientConv. , DdeService DdeTopic.
. ,
Clipboard. -, C++Builder,
CopyToClipboard DdeServerltem (
).
, ,
PasteLink DdeClientConv. :
if ( ! DdeClientConvl->PasteLink())
\
ShowMessage(
" , . " ) ;
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
3.
4.
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();
)
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)
//
//
//
//
Synchronize (UpdateCaption) ;
//
where UpdateCaption
//
void
//
fastcall
VCL
/'
Unit2::UpdateCaption ()
/* : VCL
, Synchronize, :
Synchronize {UpdateCaption) ;
UpdateCaption :
void
fastcall
Unit2::UpdateCaption (!
, ++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
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);
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
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"
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;
, 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;
, .
, ,
. , ' , . 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
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
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
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
*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
QSMKT
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);
, ,
, . , , :
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 " ) ) ;
}
, . , ,
LoadFromFile. FNa-
475
, ,
. DoVerb , . . OLE.
, . . (Insert
Object), . 7.8. : OLE ( ), ( ).
7.8
OLE -
>
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 -
,
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);
7.8
7.8.1
COM (Component Object Model )
() (). ,
,
. ,
: , , .
(
). . ,
. , , .
.
DLL. Windows
. CLSID (Class Identifier), . : (in-process ) DLL, , (local) , (remote)
. , . , ,
.
, ,
479
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
Options
"'
P GenaiateEvent support code
Threading model
:
Single
. , , .
Apartment
,
. (apartment) . .
Free
.
.
Both
, Free,
.
Neutral
,
, . , , .. . +.
Apartment.
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
Dncd
, . . MyObject
Implements. Insertlnterface. , .
IntDiv. .
.
. Refresh Implementation ( . 7.12). . , , . ,
MyObjectlmpl.cpp.
:
STDMETHODIMP TMyObjectlmpl::Add(long Numberl, long Number2)
, . :
STDMETHODIMP TMyObjectlmpl::Add(long Numberl, long Number2}
{
r e t u r n Numberl + Number2;
}
. 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
, ,
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;
};
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)
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'");
Editl->Text = Serv.OlePropertyGet("Mess");
}
catch(Exception &)
{
)
)
, ,
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
|MonthCatondurKConlrol1 cpp
I., v , ,
I
Include Stout Bo*
Udp
492
, ,
493
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;
}
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 " ) ) ;
, ,
501
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
, 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
!
,
,
.
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). , , .
: .
, ,
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 .
. VCL, .
Dota Controls
. VCL, .
dbExpress i
dbExpress.
VCL, .
Interbase
InterBase. VCL, .
WebServices
InternetExpress
InternetExpress
Web .
Internet
Web.
VCL, .
WebSnap
Web,
, . VCL.
Dialogs
, . VCL, .
IndyClients
IndyServers
IndyMisk
, - , C++Builder.
.
C++Builder
515
'
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 ,
, . 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
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
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>
C++Builder
523
/ /
, _
#endif
EditLetNum.cpp:
#include <vcl.h>
#pragma hdrstop
include "EditLetNum.h"
pragma package(smart_init)
//
//
//
//
//
, . 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
, , .
, , .
.
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
-. , 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
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();
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
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
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
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
(
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
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
|
-
Cancel |
Applj
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
:
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
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:
//
//
//
//
//
//
//
//
//
//
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"
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)
, 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 , '');
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
*\
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
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()
System::initialization()
from KERNEL32.DLL
FreeLibrary
C++Builder
551
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
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
:
^ '
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:
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
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
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 ,
.
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
SDICDBDB
EPEBS.Oe
EPEnS2.De
, . , , .
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
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.9
*>.
Child Held!
IDep|A15[
(A2D1
lAMl
= 1A2D]
1 Update mli:
! ff Cascade
I Dep 14151
BDICDBDB
BPIRSDB
DPERS2D8
<~ Erahbn
570
. 9.10
Auxiliary Passwords.-
9.12
Current Password ( ) ( , ),
.
Table Rights ( )
:
571
, , , .
(,
, ), .
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
.;.-.-.-.' jBWORK.
:
zJ
Optraiss-4,/ J7 oispMable
:P Add data to table
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
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 ( ).
.
5, 0 32.
LANGDRIVER
SQLQRYMODE
SQL
SQLPASSTHRU MODE
QBE SQL
, Database Desktop
QBE SQL . : NOT SHARED
, SHARED AUTOCOMMIT ( )
SQL
, SHARED NO AUTOCOMMIT ,
SQL
.
Possword
, .
. -1
.
j
|
p Public alias
Database alas I
Oliverlipe | STANDARD _^J
athF
| SOATABASESDBPAR
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
'
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 () - , , , .
578
Oetntion of dbP
Definition I
Tfpe
DEFAULT DRIVER
ENABLE BCD
PATH
STANDARD
PARADOX
FALSE
F^DATABASEWBPARj
\<\
Database locators
SQL Explorer
. , , (, ..),
( . 9.20). Definition ,
Text SQL,
( SQL). Data . ;
, .. -:
Enter SQL .
. 9.20
SQL Explorer Pers
iif '
' '- -
"
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
581
$-'
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
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
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
f a s t c a l l TForml::TablelCalcFields(TDataSet
*DataSet)
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
{
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!
9.6
.
, , , .. Table .
.
592
. 9.34
SQL Explorer
Database: |BCDEMOS
zl
Canoe)
, . 9.35. Dictionary,
: Databases , Attribute Sets . .
. 9.35
Qbjert dictionary
Dictionary: Dicdb
Databases Dictionary I
Dictionary
Databases
*-
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.
593
.
. Attribute Sets,
New.
. .
, , - , . - , Pers. Table. ,
. , Save Attributes
as. , . 9.36.
Attribute set name
, .
, . , .
Based on
, . , ,
Pers, Dep. Dep
PersDep.
. 9.36
[
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
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
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
Indexes
Dlail
M
Add
Joined Fields
(. 9.43), ,
, . , ,
& , .
604
. 9.43
ill
Field properties ~~ ~
Hamr
Opponent )2
<* Lookup
<"" Calculated
Lookup definition
&w Fields.
_2J Djtaset
JDep
JTablei
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
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
~ "
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
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;
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
KeyValues : , , , . . KeyValues_Size ,
. 0, KeyValues_Size
, .
FindKey
FindNearest, ,
.
, FindKey. FindNearest
. , .
613
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!
fastcall SetRange(const
const
const
const
System::TVarRec * StartValues,
int StartValues_Size,
System:: TVarRec * EndValues,
int EndValues_Size);
, , ^
TVarRec ( , OPENARRAY), . 9.10.6.
,
-, , 1, :
Tablel->IndexFieldNames = "Dep;Fam";
Tablel->SetRange(OPENARRAY(TVarRec,(" 1 " , " " ) ) ,
OPENARRAY(TVarRec,(" 1 " , " " ) ) ) ;
9.11.8
Table , . .
616
CreateTable
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 ;
'
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
, 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;
(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 () ,-
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
, ,
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
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
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
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
- -.
ApplyUpdates
:
virtual int
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)
|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
{
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 < >;
, 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,
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 ).
,
Fam LIKE '%%'
, , .
644
10
. ,
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
, .
10.1.2.2
Select ,
() ,
. ,
, (<>) ,
. ,
SELECT count(*) FROM Pers
Pers.
SELECT c o u n t ( * )
1.
645
, DISTINCT (),
. ,
SELECT count(DISTINCT Dep) FROM Pers
, Dep Pers.
min(<none>), (<>), avg(<none>), sum(<none>) , , . ,
SELECT min(Year_b), max(Year_b),
, ,
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
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
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)
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
:
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 < > <> < > < > . . .
10.1.5
. Select ORDER BY
, . .
Create Index:
CREATE
:
CREATE INDEX depyear ON Pers Dep, Year_b
:
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.
652
10
. , ++ilder. ,
, .
, , DataBaseName Query , Table, , . , ( ).
DotaSaurce , .
'^^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
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
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
658
. 10.2
UpdateSQL
Opter JSQL I
SQlSanwiton
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
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)
:SEX)
Table
OnClick . :
Queryl->ApplyUpdates {);
Queryl->CommitUpdates();
Queryl->Close ( ) ;
Queryl->Open () ;
modif = f a l s e ;
Apply(Db::TUpdateKind
UpdateKind)
, ModifySQL.
SQL , UpdateSQL, ExecSQL:
ExecSQMDb: : TUpdateKind UpdateKind)
661
, . ,
SetParams (Db: :Tt)pdateKind UpdateKind)
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;
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
tiReadCommit
tiRepeatableRead
Read commited
Repeatable Read
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!
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
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 |
. . _
Executed Query
Statements
Statement
Operations
Connect /
Disconnect
(- '
..)
Transactions
: BEGIN, COMMIT,
ROLLBACK, ABORT
BLOB I/O
BLOB ()
Miscellaneous
Vendor Errors
Vendor Calls
API
669
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
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
1
1
674
. 10.10
10
JJ*J
Svet Local Server
1
[CVRT~
P R egsler daiabsse
ASas
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
.
EXECUTE PROCEDURE <>;
: Interactive SQL,
, ..
.
, ,
.
, , , , . '
. 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))
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
683
ADOTable
ADOQuery
. , ADOConnection.
SQL, DDL (data definition language), CREATE TABLE.
, ADOConnection.
ADOStoredProc
, . ,
ADOConnection.
ADOCommand
SQL,
.
. , ADOConnection.
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
&UmQam
on
ictS
n
rig
ns<l TNeads"3,UlD=admniiserCoiri*S3rkc=Yes"
&.
10
684
| \ |
***| ODBC yuawctfre .
1 *1!<
f *1
*"
jCoMjSetHJence^Sai.DBQ-F
2.
*- j
_______
, (
:
"
:
685
**. |
"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
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
,
.
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)
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;
693
ADOStoredProc.
, , ADO.
, , .
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
, .
InterBase , TCP/IP, 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
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
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
701
. , - (, , ,
.), . ConnectionName LoadParamsFromlniFile:
procedure LoadParamsFromlniFile( AFileName
String -
''
) ;
702
10
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
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
||
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
dit Done
Cancel Ed*
Cancel
Help
, SQL,
.
SQL , . -
708
11
, COUNT(YEAR_B) SUM(YEAR_B)
(. 11.2). Dirnention/Surnmaries, , Summaries (.
. 11.1).
i
!
"
4
4
DecrsoinQuerylDecsionCubel
. 2
9
11
Decisions ourcel
, . . . DecisionCubel, DimensionMap ,
Decision Cube Editor.
, . 11.4.
. 11.4
Decision Settings
Ds
ipa
i y Ha
Ivpe
l r.,ii":?
Active Type
Formal
As Needed
Year b"
SUMOFYea_ib"
Average ol PERSM.Year_b"
709
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
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
11.2
+-(-Builder QuickReport. QReport .
QuickReport , .
(band) , , , , ..
, .
,
, -
11
714
. , , , ,
.
, ,
,
. , , , .
. 9 10 dbP,
. 11.9. ,
... :
...,
.
|
|
|
, |
..., j
, , - t
, , , S
.
i,
, , j
...
.
. , , .
, .
, , QuickRep.
, , , , . , .
QuickRep , :
PrinterSetting
Page
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
,
.
.
FRep->QuickRepl->Print() ;
if (FontDialogl->Execute() )
RichEditl->SelAttributes->Assign(FontDialogl->Font) ;
RichEditl->SetFocus () ;
'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
11
TForml->AAllExecute
AExit
ANew
TForml->ANewExecute
AOpen
TForml >AOpenExecute
APreview TForml>APreviewExecute
APrint
TForml->APrintExecute
ARecord
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
//
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)
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, , , C++Builder, , -
12
732
</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;*.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
{
// 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
,
. :
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
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
,
. , .. , 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
)
You m select from one of the loliowing types of Woild
Wide Web server applications
ISAPI/NS/SPI Dmamic Lrts Libtarii
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
743
Pathlnfa. OnAction, , . :
void
fastcall
TWebModulel::WebModulelWebActionItemlAction!
TObject *Sender, TWebRequest *Request,
TWebResponse *Response, bool iHandled)
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;
}
flea</title>
<body>
<!>3 ?</>
<> 2 x 2 ?</>
<hr>
<>< HREF="http://mycomputer/cgi-bin/TwoTwo.exe/l?4">4</a>
. 12.7
: ()
4 (6) 5 ()
745
)
-3
\!
1
1
2 x 2
^ ?,
:gs-brj/Tv4i eTvo exe: 9 HI 9
6)
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
, , .
746
12
2.
12.8 HTML
12.8.1
. 12.6 .
.
. , <form> HTML. -.
, ,
, , .
.
<FORM>, . =. URL , ,
action. :
action-"http://mycomputer/cgi-bin/test.exe"
747
Request->QuerFields->Values["result"]
result.
size,
.
,
. <table>
</table>. <tr> </tr>, . <td>
</td>, . .
.
. HTML, , . 12.8.
. 12.8
, ,
- 9 9
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 () ;
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;
)
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 ;
(
12
750
. 12.9
HTML
()
()
6)
' fhttp/Ar^computei^cgibtn/mdt
!! 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
, . 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() ;
}
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;
756
12
Hiiiiii
. 12.11
[ |
1
.. .
1965
,37
1950
52
1930
12
1937
165
,1961
41
'1975
"
.27
_jj
9 9
, .
. 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 ' ;
2 ( Header),
Web. . 12.12.
.
. 12.12
| > |
[]
1930
72
1930
12
Rip
1937
65
'
19W
52
1955
47
I960
42
19
*"
'
' 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 };
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> </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
>
'
- ActvieX CondolOpo
tins
MakeCcnbol Licensed
IncludeAbcutBox
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
{
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
!.**
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
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
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
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
#undef MyConst
#if defined
#ifdef, #if ! defined #ifndef. ,
#ifdef Size
fendif
* ' 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 -
" , "
" "
" , "
, , '\'. ,
" , \
"
.
, . ,
"\"\"\ \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};
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);
.
-, ,
- . , , . -, , .
. , . , , , ( ), . ,
.
, - , . , ,
#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 * ) ;
//
//
* *= *;
//
)
, , :
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);
.
. ,
,
, , . :
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)
, . , 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());}
, , :
c h a r S [ 1 2 8 ] = " =>";
c h a r SI = T o S ( S , 5 ) ;
,
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;
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
, , .
., ,
13.7.10 typeid
typeid type_info,
. :
typeid( )
typeid( )
, typeid , . , .
13.7.12 (::)
, (::). :
:
: :
:
:: _
,
. , ::1 I,
I. () . . 13.6.
- - , , . - .
, C++Builder,
.
. . 1, . 1.9.5.3.
, . , 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;
}
// , :
//
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.
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;
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;
, .
.
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;
}
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 *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 ;
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.
, , . , ,
. - , - , , , .
HelpContext
int
-- |
. , ,
,
F1. 0.
Message
System::AnsiString
,
; .
Message ,
. , ,
Message string .
HelpContext - . , ,
, F1.
",
4);
11
t
'
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
:
void
(
)
//
.
, .
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
,
()
()
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
enum
long
unsigned long
0 65 535
-2 147 483 648 2 147 483 647
char
4
4
int
long
unsigned int
unsigned long
float
double
long double
bool
10
3.4 - 3 2 1.1 4 9 3 2
true false
.
. , (. . 13.6).
:
typedef
, ^ . ,
typedef double Ar[10];
10 .
. :
= ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 0 ) ;
bool Boolean;
int Integer;
short Smallint;
unsigned char Byte;
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
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 . ) ;
"
"
IntToStr((int).);
.
C++Builder 5
. .
14.3
.
char, short, int long
signed unsigned . .
, .
, char signed
, char unsigned
__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
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 = "";
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 '
Pt
. strcpy S S1,
:
' ' , ' ' , '
strcat S S3:
' ' ,'
,'
,'
,' ','
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;
, . , , : >, < .. , :
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: . . .
- , 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;
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
)
,
, (type, minval
maxval) . , ( +, *),
, , ,
. true , . false.
Set :
Clear
Set&
Contains
bool
fastcall Clear();
..
* , 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
, ,
( ) .
. 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] ;
Pt . Pt
, , 2.
, b 2 , Pt (.. , Pt) 4.
.
. , Pt
, P t l ,
P t l Pt 2 ,
. , , ,
, 4 ( 2 ).
,
. ,
, . >, <, >=, <=
. == !=
. ,
.
,
.
,
. void (.. void*), , . void
. void
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 + " \ " ");
)
.. 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,
fopen ,
filename, . mode ,
. :
+
w
W+
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);
//
==
'\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
e, E
float *arg
char arg[]
char *arg
, ,
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;
"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++)
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);
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);
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);
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 () ;
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
ios::showpos ios::showpoint.
resetiosflags unsetf , ,
. , #include <iomanip.h>.
.
, showpoint:
outfile 1. " " << 1.1 "
" <<
setiosflags(ios::showpoint) << 1. << "
:
1
1.1
1.00000
1.10000
-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]
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;
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()
{
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;
-
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;
, , 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
. -,
.
, (-). ,
. :
class MyClass
{
public:
-MyClass ( ) ;
//
, - -
, - .
.
.
, .
14.12.5 , ,
, - , - -, , .
( ). .
public,
protected private (. . 14.12.1). .
public , .
.
.
. , .
.
- public
protected
-
public
protected
private
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)
//
// 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
{
// (i,j)
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;
;,
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
Help
15.2
Properties . Component | Configure Palette.
Tools | Environment Options
Palette (. 15.2).
. 15.2
Environment Options
_*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
,
, , .
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
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
. -
'
*
*
*
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
-
t
ifl 7^ Jill
Cancel
tit*
Smart lab
Optimal fill
Backspace
unindents
Backspace
.
Cursor through
tabs
Group undo
Alt-Backspace
Edit | Undo , .
Cursor beyond
EOF
Keep trailing
blanks
, .
BRIEF regular
expressions
Brief.
Persistent blocks
, .
Overwrite blacks
. Persistent Blocks,
.
-
. ,
.
. 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.
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
Stacfcftamei
' (7 0*81
fieatenumtsjesasW
Bleasa
De(a<*
| [
[
EnlendedetiornfiaUcin]
Help
BRIEF.
.
, "-".
. ,
.
, :
. 80 . 1024.
Visible gutter
, .
Gutter width
. - 30.
Editor font
, .
Courier. , .
Size
,
.
Sample
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
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
Categories
Edit Background
Edit Value
Instance List
Cl.assname
Readonly
References
SubProperties
, ,
Value
,
.
Options
:
,
, .
, ,
.
, ().
Integral height
(when not dacked)
, .
,
(), ..
.
15.7
C++Builder 6 ,
,
.
, Tools | Environment Options
Internet (. 15.9).
. 15.9
Internet Environment Options
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
OK
Cancel
Ueb
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
XML.
15.8
Tools | Debugger Options.
, . 15.11.
. 15.11
General
<- General-
i Map IP32 keystrokes on tun
i M * k b i ) ! i ! lead-only 1
P Reaianfl&jditorlocalmenuoniun I
-"
' 17 Shoginhented
, SorthjiQeme
j-Palhs
1
17 Integrated debuggn
ig
OK j Cancel
.
Inlegroted debugging, . , .
General, . 15.11, ,
:
Map TD32 keystrokes an
run
TD32 .
Mark buffers reod-anly on run.
.
,
, - ( )
.
.
,
.
C++
Pascal. , C++.
(,
) (. . 2.8.4).
, , .
.
.
, Unlimited.
. 15.12
Event Log
W Integrated dobugeng
lp
Thread Messages
( ) .
Output messages
, OutputDebugString
(. . 2.8.9).
Window messages
Windows.
P lO|>nOlphiEKMf*nnt
P Stop on Exceptions
OS Exceptions (. 15.14) .
.
, Add. Remove
, ,
. C+4-Builder 1 Remove
.
. 15.14
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
|$(BCB)\lib\vc6u.csm
Stop, after
CornpiwlQ
~"
MetgeduplbatestFngs
P Staqbhames
" Ttealenumtiipesesrits
* ^KWfleWfalmesdges
'gtfuHdebuaj Batee
default
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
MaxgtHxs: j(j
Map*
Off
Segments
-^j
-
I Delated
!
f~ Sh^wmangied names
*-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.
.
15.9.5 Directories/Conditionals
Directories/Conditionals . 15.17. , . , . . .
. 15.17
Directories/Conditionals
- Directories - - - - - ;
COflBA I CodeGuard
*
- -
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
Greyedteimsdenoe
tn
ivad
il path.
|$(BCBn
)\iculde
Dee
lteInvad
il atht
#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
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.
, 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
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 double
type.
int
*)
II
long (long *arg)
g. G
(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
include <SysUtils.hpp>
enum TFloatFormat ( ffGeneral, ffExponent,.ffFixed, ffNumber,
ffCurrency );
enum TFIoatValue ( fvExtended, fvCurrency );
. ,
. ,
.
, 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
,
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>
_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
EACCES
EAGAIN
EBADF
Permission denied
42
_sys_crrlist
EUUSY
44
Resource busy
ECHILD
24
No child process
ECONTR
ECURDIR
16
EDEADLOCK
36
Locking violation
EDOM
33
Math argument
EEXIST
35
EFAULT
14
Unknown error
EFBIG
27
UNIX MSDOS
EINTR
39
EINVACC
12
EINVAL
19
Invalid argument
EINVDAT
13
Invalid data
EINVDRV
15
EINVENV
10
Invalid environment
EINVFMT
11
Invalid format
EINVFNC
EINVMEM
40
Input/output error
EISDIR
46
UNIX MSDOS
EMFILE
EMLINK
31
UNIX MSDOS
ENFILE
23
ENMFILE
18
No more files
ENODEV
15
No such device
ENOENT
ENOEXEC
21
ENOFILE
ENOMEM
ENOPATH
ENOSPC
28
ENOTBLK
43
UNIX MSDOS
ENOTDIR
45
UNIX MSDOS
ENOTSAM
17
ENOTTY
25
UNIX MSDOS
ENX1O
41
_sys_errlist
EPERM
37
EPIPE
32
Broken pipe
ERANGE
34
EROFS
30
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]/" ");
2
3
100
(EOF)
101
106
include <mach.h>
int
matherr(struct ^exception *e) ;
nH
mjrherrl(struct
exception! * e ) ;
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
(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);
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
stdlib.h
_Irotr
stdlib.h
_rotl
value stdlib.h
unsigned short _rotl(
unsigned short value, count
int count)
_rotr
abs
int abs(int x)
stdlib.h
cabs
math.h
cabsl
math.h
ceil
double ceil(double x)
: , X
math.h
Ceil
: , X
Math.hpp
ceill
math.h
div
math.h
exp
double exp(double x)
math.h
cxpl
math.h
fabs
double fabs(double x)
math.h
fabsl
math.h
floor
double floor(double x)
: ,
math.h
Floor
: - Math.hpp
, X
floorl
fmod
math.h
fmodl
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
()
exponent
math.h
IntPower
Extended IntPower(
Extended Base,
int Exponent)
Base
Exponent
Math.hpp
labs
stdlib.h
Math.hpp
Idexp
Ldexp
Extended Ldexp(Extended X,
int P)
ldexpl
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
- 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
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
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.
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
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)
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 x)
Extended Tan(Extended X)
tan
Tanh
double tan(double x)
Extended Tanh(Extcnded X)
tanh
double tanh(double x)
tanhl
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 ) ) ;
16.2.4
_lrand
long _lrand(void)
, 0 2 3 1 - 1
stdlib.h
rand
int rand(void)
, 0 RAND_MAX
stdlib.h
RandG
Math.hpp
random
stdlib.h
randomize
/
void randomize(void)
( RandG)
Math.hpp
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
MaxValue
Mean
Math.hpp
MeanAndStdDev
Math.hpp
Minlnt Value
Math.hpp
MinValue
Math.hpp
MomentSkewKurtosis
Norm
Math.hpp
PopnStdDev
PopnVariance
StdDev
Sum
Sumlnt
Math.hpp
Math.hpp
Math.hpp
Variance
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
math.h
_i64toa
stdlib.h
_itow
stdlib.h
Jtoa
_strtold
_ui64toa
_ultow
_wcstold
stdlib.h
stdlib.h
stdlib.h
stdlib.h
stdlib.h
stdlib.h
_wtof
math.h
_wtoi
stdlib.h
_wtoi64
stdlib.h
_wtol
stdlib.h
_wtold
math.h
atof
stdlib.h,
math.h
atoi
stdlib.h
atol
stdlib.h
ecvt
stdlib.h
fcvt
stdlib.h
gcvt
stdlib.h
itoa
stdlib.h
strtod
stdlib.h
strtol
stdlib.h
strtoul
stdlib.h
ultoa
stdlib.h
wcstod
stdlib.h
wcstol
wcstoul
, . ,
, .
, 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
CurrToStrF
FIoatToDecimal
FloatToStr
FloatToStrF
FloatToText
FloatToTextFmt
FmtStr
Format
FormatBuf
Formate urr
FormatFloat
GetFormatSettings
IntToHex
IntToStr
StrFmt
it lluifcr no F o r m a t (. . 10.1.2.3)
StrLFmt
StrToCurr
StrToFloat
StrToInt
StrToIntDef
TextToFloat
(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
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
16.3.2
asctime
/
char *asctime(const struct tm *tblock)
tm
time.h
ctime
Date
System::TDateTime Date(void)
DateTimeToFileDate
SysUtils.hpp
int DateTimeToFileDate(
System::TDateTime DateTime)
DateTime DOS
SysUtils.hpp
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
SysUtils.hpp
DecodeTime
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
dos.h
gmtime
time.h
IncMonth
SysUtils.hpp
System::TDateTime IncMonth(
const System:: TDateTime Date,
int NumberOfMonths)
Date, NumberOfMonths
IsLeapYear
Iocaltime
mktime
MSccsToTimeStamp
TTinieStamp MSecsToTimeStamp(
SysUtils hpp
System::Comp MSecs)
MSecs TTinieStamp
SysUtils hpp
System::TDateTime Now(void)
Now
SysUtils.hpp
setdate
dos.h
settime
dos.h
stime
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
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 , :
(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
, DateSeparator.
, TimeScparator.
xx'/"xx" , , , ,
.
:
""
14.04.02 8:34:14
"d/m/yy h:n"
14.4.02 8:34
: 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));
16.3.3
Bounds
Rect
Classes.hpp
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
_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
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
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
ctype.h
toupper
ctype.h
towlower
ctype.h
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
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|
mem.h
aetmem
mem.h
, , , .
16.4.2.2
AnsiStrComp
AnsiStrIComp
AnsiStrLComp
AnsiStrLlComp
AnsiStrLower
SysUtils.hpp
SysUtils.hpp
AnsiStrRScan
SysUtils.hpp
AnsiStrScan
SysUtils.hpp
AnsiStrUpper
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
SysUtils.hpp
StrAlloc
SysUtils.hpp
StrBufSize
SysUtils.hpp
strcat
StrCat
SysUtils.hpp
strchr
string.h
strcmp
strcmpi
string.h
I StrComp
SysUtils.hpp
SysUtils.hpp
string.h
string.h
si, s2
strdup
string.h
StrECopy
SysUtils.hpp
StrEnd
SysUtils.hpp
Str
strerror
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
SysUtils.hpp
S I H S2 ( AnsiStrlComp);
< 0 Sl< S2, = 0 Sl= S2, > Opi^Sl> S2
StrLCat
StrLComp
StrLCopy
SysUtils.hpp
char * StrLCopy(char * Dest, char * Source,
Cardinal MaxLen)
MaxLen Sonrce Dest Dest
strlen
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
strlwr
StrMove
SysUtils.hpp
char * StrMove(char * Dest, char * Source,
Cardinal Count)
Count Source Dest Dest; Source Dest
strncat
strncmp
strncmpi
etrncpy
stdio.h
char *strncpy(char *dest, const char *src,
size_t maxlen)
maxlen src dest; .- dest
string.h
StrNew
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
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
string.h
SysUtils.hpp
StrPos
Strrchr
strrev
StrRScan
string.h
StrScan
SysUtils.hpp
strset
string.h
strspn
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
if
tin
"
, . ; ") ;
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
AnsiExtractQuotedStr
|
SysUtils.hpp
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
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++)
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
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
_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
stdio.h
fflush
stdio.h
fopen
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
stdio.h
tmpfile
FILE *tmpfile(void)
FILE NULL
stdio.h
; ,
W+
;
,
, , .
.
fseek rewind, . 16.5.4. , :
() () fseek rewind
in' MHIU.IM fscck rewind
-
"wt",
stdout);
"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
io.h,
sys\stat.h
_rtl_close
io.h
_rtl_creat
_rtl_open
/
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, ,
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
io.h
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
stdout ( 1
. . 16.5.1) output.txt.
16.5.4 /
_fgetchar
int _fgetchar(void)
stdin
stdio.h
stdio.h
_getw
stdio.h
cgets
conio.h
clearerr
stdio.h
cprintf
conio.h
cputs
cscanf
conio.h
int cscanf(char *format [, address, ...])
argument format;
EOF
eof
feof
stdio.h
ferror
stdio.li
fgctc
(!<- /
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
stdio.h
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
(' / -
(n * size)
stdio.h
getch
int getch(void)
conio.h
getchar
int getchar(void)
stdin; , getc(stdin)
stdio.h
getche
int getche(void)
conio.h
getpass
conio.h
gets
stdio.h
kbhit
conio.h
lseek
perror
printf
puto
piilch
stdio.h
stdio.h
conio.h
:]
putchar
int putchar(int c)
, stdout;
putc(c,stdout)
stdiu.h
puts
stdio.h
puttext
conio.h
putw
stdio.h
read
io.h
scanf
stdio.h
sprintf
sscanf
tell
ungetc
ungetch
vfprintf
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;
3)
<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);
|
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
,
. :
" : \\ 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
, : :
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
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
waccess
wrtl chmod
io.h
access
io.h
chdir
dir.h
chmod
io.h
chsize
CreateDir
SysUtils.hpp
DeleteFile
SysUtils.hpp
DirectoryExists
bool DirectoryExists(
const System;:AnsiString Name)
, Name
SysUtils.hpp
DiskFrec
DiskSizc
FilcAge
FileDateToDateTime
FileExists
FileGetAttr
FileGetDate
filelength
FileSearch
FileSetAttr
FileSetDate
FindClose
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
findfirst
attrib;
ffblk;
0 -1
FindNext
SysUtils.hpp
int FindNext(TSearchRec &F)
,
FindFirst F; F;
0
findnext
fnmerge
fnsplit
ForceDirectories
FileCtrl.hpp
void ForceDirectories(System::AnsiString Dir)
Dir ,
fstat
gctcurdir
GetCurrentDir
System::AnsiString GetCurrentDir()
sys\stat.h
SysUtils.hpp
gctcwd
dir.h
getdisk
int getdisk(void)
: 0 , 1 ..
dir.h
gett'time
io.h
GetSystemDirectory
GetWindowsDirectory
isatty
mkdir
dir.h
remove
stdio.h
BemoveDir
SysUtils.hpp
rename
stdiu.h
int rename(const char *oldname,
const char *newname)
oldname,
newname; ; 0
1
RcnameFile
searchpath
dir.h
SetCurrentDir
setdisk
setftime
io.h
int setftime(int handle, struct ftime *ftimep)
handle ftimep; 0
- 1
stat
dir.h
sys\stat.h
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
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)));
//
//
//
//
//
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 () ;
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];
//
//'
//
//
//
- || . ' , 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)
{
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
+ " - ");
*- " - ");
+ " - ");
+ " - ");
+ " - ");
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
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
signal.h
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
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
execlpe
process.h
/
execv
int execv(char *path, char *argv[])
path
argv[]
process.h
execve
path
argv[] env
process, h
cxecvp
process.h
execvpe
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
process.h,
stdio.h
spawnv
process.h,
stdio.h
spawnve
process.h,
stdio.h
spawnvp
process.h,
stdio.h
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. , .
, 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
.
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
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
al.txt",
else
{
. DOS, Windows
. system 0
-1 . :
// DOS dir
// dir.txt
systemfdir dir.txt");
-'/'
DOS
tnkdir,
c ; \ \ t t t
systemC'mkdir c:\\ttt");
,,
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
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
malloc .h
_new_handler
alloca
AllocMem
calloe
free
GetMemoryManager
malloc
realloe
set_new_
handler
SetMemoryManager
void SetMemoryManager(
System.hpp
const TMemoryManager &MemMgr)
MemMgr ,
SysFreeMem
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 ,
, .
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.
, .
.
GetMem
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)
. 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
mbYesN oCancel
Yes, No Cancel
mbOkCancel
Concel
mbAbort Retrylgnore
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
,
(. . 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
, .
, MessageDlg CreateMessageDialog. , . -,
MessageDlg (, , CreateMessageDialog, ).
( Windows).
MessageBox MessageBox API Windows.
Text ,
255 .
. Caption .
255 , .
.
Flatf ,
.
.
,
( Windows)
MB_ABORTRETRYIGNORE
_
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
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);
APassword , ,
.
LoginDialog true, ,
.
, ,
. , false.
, LoginDialog,
, User Name. LoginDialogEx
. :
extern PACKAGE bool
fastcall
LoginDialogEx(
const AnsiString ADatabaseName,
AnsiString SAUserNarne,
AnsiString iAPassword,
bool NameReactonly);
16.7.3
/
extern PACKAGE void Beep(void)
C++Builder,
SysUtils.hpp
MessageBeep
PlaySound
mmsystem.hpp
BOOL PlaySound(LPCSTR pszSound,
HMODULE hmod, DWORD fdwSound)
API 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 , . ,
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.
ARRAYSIZE
sysdefs.h
bsearch
stdlib.h
EXISTINGARRAY
sysdefs.h
getenv
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
stdlib.h
sysdefs.h
System.hpp
System.hpp
stdlib.h
stdlib.h
Menus.hpp
ShortCutToText
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
*eleml == *elem2
> 0
GetShortHint GetLongffint
< >I< >
, , Hint (.
. 17 . 5, . 5.1.9).
getenv putenv .
name=string\O. getenv
name. getenv ,
, . ,
PATH.
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
GetLastError
DWORD GetLastError(VOID)
GetWijjdpwText
'
, . ( 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
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
Align ,
, , , ,
, , , .
:
alNone
, .
. Align .
alTop
. .
17
1054
alBottom
. .
alLeft
. .
alRight
. .
alClient
. , .
alCustom
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
Bitmap TBitmap. 8 8 ,
Brush.
BitMap,
, Style. BitMap , ,
.
8 8 ,
8 8.
TBitmap , Bitmap.
TBitmap , .
, , , ,
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
Brush
TWinControl
Brush () , Canvas.
, . . Brush , Color Style.
Assign.
, , , ,
1059
TBrush Brush. .
, . TBrush.
Canvas
(, )
Charset
,
TFont
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
. 4 . Font.
ClientHeight
TControl
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;
;
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
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;
};
ClipRect
, . ClipRect .
OnPaint , . .
Color
, TFont .
TControl
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
, , , ,
1065
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
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
, , . .
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
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) );
Imagel->Canvas->CopyMode = cmWhiteness;
Imagel->Canvas->CopyRect(Rect(0,0,100,100),Image2->Canvas,
Rect(0,0,100,100) ) ;
Imagel, . Image2
.
Cursor
,
TControl
, . , 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
1070
17
DragMode . :
dmAutomatic - .
.
dmManual
, BeginDrag
DragMode . . OnDragDrop.
Font
TControl
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)
{
Handle
TWinControl
^ p r o p e r t y HWND Handle
Height
. . . . ClientHeight, ClientRect.
Height
1072
17
TFont
Height . Height
, .
Height, :
Size , Windows.
Height Size PixelsPerlnch (
. TFonU :
Font->Height = -Font->Size * Font->PixelsPerInch / 72
HelpContext
-
TControl
HelpContext
- . ,
F1, .
HelpContext 0, HelpContext (-, ). , HelpContext , , HelpContext, , . THelpContext
Classes.cpp
typedef
int
THelpContext;
property
AnsiString
HelpKeyword
HelpKeyword
- . , F1, .
HelpKeyword C++Builder 6
HelnTvne = htKeyword.
, , , ,
1073
HelpType
, -
TControl
HelpType , : HclpContext (
htContext), HelpKevword ( htKeyword)
- , . C++Builder 6.
Imagelndex
TMenuItem, TToolButton, TListltem, TTreeNode, TTabSheet .
Imagelndex ,
, , , .. Images
- ( TMenu TPopupMenu, , ..) 0. Imagelndex = - 1 ,
.
-, ( Images
NULL),
Bitmap TMenuItem. Bitmap Images NULL Imagelndex.
Bitmap .
Left
TControl
Left .
(, , , ,
).
Left ,
.
Left (. . BoundsRect Components).
Mode
1074
17
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
Name , . -
, , , ,
1075
. .
C++Builder , .
. - , 17 Buttonl3.
Name . . Components.
Parent
,
TControl
Parent , .. -, . , , , . , , , , , .
true ParentFont.
ParentColor, ParentShowHint. ParentCtI3D.
: Parent ,
Owner . ,
. ,
. .
Application .
Parent .
,
, Parent.
Parent . Visible.
ParentColor
. . TControl.
_ _ _
,
TCanvaa
property TPen*
,
. (.
).
, , .
Assign.
1076
17
PenPos
TCanvaa
PenPos TPolnt
. , , LineTo.
PenPos MoveTo (, LineTo). PenPos MoveTo.
Pitch
TFont
. . , .
, .
.
Pitch:
fpDefault
, ..
Name
fpFixed
fpVariable
Pixels
ClipRect
TCanvas
, , , ,
1077
Pixels X Y
ClipRect. ClipRect. Pixels - 1 .
. FillRect. . . 6, . 6.1.3.
Pixels. Pixels 1. Pixels
.
QuoteChar
. CommaText, DelimitedText, Delimiter, QuoteChar
Shortcut
,
TMenuItem
Shortcut , . Shortcut .
Shortcut .
Shortcut ShortCut,
TextToShortCut, ShortCutToText (. . 16.7.4, . 16)
Size
()
TFont
, , ,
Size Height. Size ; Height .
17
1078
Style TPen
Style .
:
psSolid
psDash
psDot
psDashDot
-
psDashDotDot ,
psClear
psInsideFrame , Width > 1 , Windows
. 6, . 6.1.3.3.
Width = 1. .
psInsideFrame , .
Windows.
Style TBrush
Brush
TBrush
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
Style : . Set, ,
:
fsBold
fsltalic
fsUnderline
fsStrikeout
Tag
,
TComponent
Tag . , .
, Tag
.
Tag . . Components.
1080
17
Top
TControl
.
"
(, , ,
, ). . , .
(. . BoundsRecU Components).
TransparentColor
,
TBitmap
Visible
,
TControl
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.
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
Width
.
. - Width . . . GlientWidth, ClientReet.
17.2
Add
TList, TStringLlst, TStrings
TList:
int
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
virtual void
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) ;
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
1. FontDiaolgl, . :
if (FontDialogl->Execute())
Font->Assign(FontDialogl->Font);
TControl
void
, , , ,
1085
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
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);
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
, , , ,
1089
ClientToParent ( C++Builder 6)
Point AParent. ParentToClient .
AParent ,
. , Parent.
AParent NULL , .
AParent
Parent nil, ElnvalidOperation.
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
Imagel->Canvas->CopyRect(MyRect2,Bitmap->Canvas,MyRectl) ;
Image 1 MyRect2
MyRectl Bitmap.
Delete___
TList, TStringList, TStHngs, TMenuItem
void
fastcall Delete(int Index);
Delete .
, ( ).
.
(
).
.
, .
, , , ,
1091
Draw
TCanvas
void
Draw , , Graphic,
. X Y. ,
. TBitmao.
, CopvMode.
Imagel->Canvas->Draw(10,10, Bitmapl)
Image 1 Bitmapl (10, 10).
DrawFocusRect
,
,
TCanvas
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
,
( 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).
TWinControl
TWinControl*
fastcall FindNextControI(
TWinControl* CurControl, bool GoForward,
bool CheckTabStop, bool CheckParent);
1094
17
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
, , , ,
1095
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);
'
TList, TStringList, TStrings
TList:
int
TStrings TStringList:
virtual int __fastcall IndexOf(const System;:AnsiString S) ;
, , Editl.
TStringList *LPerson = new TStringList;
if (LPerson->IndexOf(Editl->Text) < 0)
ShowMessage(" " + Editl->Text + " ");
Insert
,
,
________^_
, , , ,
1097
TUst:
void __fastcall Insert(int Index, void * Item);
TStrings TStringList:
virtual void
Insert ( Item S)
, Index. Index = 0,
. , Index, , .. 1.
, Insert
EListError. Add.
TStringList TStrings , , Insert InsertObject.
LineTo
,
TCanvas
void
fastcall LineTo(int X, int 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
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
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
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.
, .
1100
17
PoIyBezier PolyBezierTo
,
TCanvas
void
void
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);
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);
,
:
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
v i r t u a l void
fastcail
SaveToClipboardFormat(Word SAFormat,
i n t SAData, HPALETTE SAPalette) - 0;
include
<vcl\Clipbrd.hpp>
Word MyFormat;
THandle AData;
HPALETTE APalette;
Imagel->Picture->Bitmap->SaVeToClipboardFormat(MyFormat,
AData,/APalette);
Clipboard()->SetAsHandle(MyFormat, AData) ;
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
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();
SelectNext
,
TWinControl
void
f a s t c a l l SelectNext(TWinControl* CarControl,
bool GoForward, bool CheckTabStop);
'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
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
StretchDraw ,, ,
Graphic, ,
Rect. .
StretchDraw firaw.
.
Graphic , . 1 TBitMap,
, CoovMode.
Imagel->Canvas->StretchDraw(Rect(10,10,110,110)/Bitmapl);
TextExtent
, ^
TCanvas
struct TSize
{
LONG c x ;
LONG ;
);
TSize
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
,
1110
17
, : TextExtent.
TextHeight Text Width.
, , .
.
, TextRect,
Imagel->Canvas->TextOut(10, 10, s) ;
void
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
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);
1112
17
17.3
OnChange TCanvas
TCanvas
OnChange .
:
1. OnChanging.
2. TCanvas .
3,. OnChange.
OnChange , . , Font ,
OnChange.
OnChanging
. OnChange.
OnClick
TControl
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
OnCreate -
. -
, , OnDestroy.
, Visible, true: OnCreate, OnShow, OnActivate, OnPaint.
OnDblCIick
TControl
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)
{
)
,
-. , & , 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
OnDragOver , .
, , , . OnDragOver , ,
. ,
Accept, true. ,
true, .
, . ,
.
, , , . ,
OnDragOver ( ) DracCursor.
Source , Sender
, X Y . State TDragState
. ;
1116
1?
dsDragEnter
dsDragMove
dsDragLeave
.
, .
.
void
{
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
if (Target NOLL)
ShowMessage(" "+
((TControl*)Sender)->Name + " ");
else
ShowMessage(((TControl*)Sender)->Mame + " "
+ ( (TControl*)Target)->Name);
}
ListBoxl ListBoxl ListBox2.
, , .
$'
, , , ,
OnEnter
TWinControl
'
OnEnter . .
, , , , OnEnter , . OnExit.
, .
OnExit ,
.
.
*
ActiveControl ,
OnExit.
, , , , OnExit ,
.
OnEnter.
, , .
, , . OnEnter.
OnKeyDown
.
TWinControl
enum Classes
ssLeft,
ssRight,
1 '
typedef Set<Classes
typeclef void (
1, ssShift, ssDouble>
IJVI
'
TSJiiftState;
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) . . . ;
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 ;
'5'
/
.
2. OnKeyPress
, , :
Key - UpCase(Key);
' ' ' '
.
, ( . . 16.4.2.3, . 16):
Key - AnsiOpperCase(Key)[1];
OnKeyUp
' TWinControl
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
, , , ,
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
OnMouseEnter , . OnMouseEnter , -
. , , , ^6 C++Buttder 6
1122
17
OnMouscLcave. OnMouseEnter
((TLabel *)Sender)->Font->Color - clBlue;
OnMouseLeave
((TLabel *>Sender)->Font->Color = clBlack;
- .
OnMouseLeave
^
..
,
TCustomLabel
OnMouseLeave , -
, OnMou^eEnter
- , . OnMouseEnter.
OnMouseMove
TCantrol
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
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
closure *TProgressEvent)(
System: tTObject"* Sender,
TProgressStage Stage,
Byte PeroentDone,
bool RedrawNow,
const Windows:^TRect &R,
const AnsiString Msg);
1124
17
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
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)
. :
src wchar_t
int src
src
src
;
15
double src
c_str
CurrToStr
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
IsEmpty
bool
fastcall IsEmptyO const
true,
LastDelimiter
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
WideChar
WideCharBufSize
int
fastcall WideCharBufSize() const
, WideChar
Set
, Delphi,
VCL
vcl/sysset.h
1130
17
declspec(delphiretttrn)
Set;
;
type
minval
( int, char )
maxval
( 255}
( 0)
Set .
- , , , , . ,
...
, si s2 .
Set , , (. . 14.6, . 14).
TBitmap
Windows {),
(HPALETTE)
TObject TPersistent TGraphtc
graphics
TBitmap Windows, .
,
, .
,
TBitmap.
Canvas
TCanvas
()
.
.
Empty
bool
, .
.
Handle
HBITMAP
, , , ,
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
Bitmap
TBitmap
, .
Color
TColor
. clWhite.
Handle
HBRUSH
, GDI Windows.
Style
TBrushStyle
TBrush He - . , Assign, .
-.
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} ,-
,.
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 .
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
, , , ,
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.
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
TStrings
, C++Builder .
TObject TPersistent
, , , ,
1143
classes
TStringff ,
:
>
, Strings.
Capacity
int
,
. TStrings Capacity Count, Capacity
. , TStrings, Capacity
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
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
S
Index. Index = 0,
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
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
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
, , , ,
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
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