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

1.

2.

C++ Builder

3.

C++ Builder

4.

3.1.

3.2.

3.3.

3.4.

3.5.

++ Builder

++ Builder
4.1.

4.2.

4.3.

4.4.

TForm
4.1.1.

4.1.2.

4.1.3.

TButton
4.2.1.

TButton

4.2.2.

TButton

4.2.3.

TButton

TPanel
4.3.1.

TPanel

4.3.2.

TPanel

4.3.3.

TPanel

TLabel
4.4.1.

TLabel

4.5.

TEdit
4.5.1.

TEdit

4.5.2.

TEdit

4.5.3.

TEdit

4.6.

TLabelEdit

4.7.

4.8.

4.9.

4.10. TMainMenu
4.10.1. TMainMenu
4.11. TPopupMenu
4.11.1. TPopupMenu
4.11.2. TPopupMenu
4.12. TMemo
4.12.1. TMemo
4.12.2. TMemo
4.13. TListBox
4.13.1. TListBox
4.13.2.
4.13.3. TListBox
4.13.4. TListBox
4.13.5. TListBox

4.13.6.
4.14. TComboBox
4.15. TStringGrid
4.16.

4.17.
4.18. TMaskEdit
4.19. TCheckBox
4.20. TRadioButton
4.21. TRadioGroup
4.22. TCheckListBox
4.23. TImage
4.23.1.

TImage

4.24.
4.25.
5. TComboBox
5.1.

Borland C++ Builder - Borland


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

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

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

.1. C++ Builder

C++

Builder.


C++ Builder, .

C++

Builder

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

.
,
(, ,
Windows .)

. 2.

. ,
, .

C++

Builder

: , .
,
,
.
,
.

.3.

,
.

(, ).
(Properties).

(published)

published-,
(public), ,
.

.
.


.

,
,
( ,
, , ..).

(Events)
, (

, , Windows
,

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

,
C++ Builder

.
, ,
. { ... }.
, .
,
.

.4. .

, ,
.
,

: ->, :
Edit1->Show();
,
*.h ,

(, ).
,
,
.

, - -
.
.
,
View/Project Manager.
Project1.cpp.

.5.

.
. ,
New Form
.
, Add
, .
. , -
, ,
, , .
, Remove
.
Options ,
,
, , ,

( Delphi 2.0,
C++ Builder ) .

. 6.
C++ Builder
,

.
, C++ Builder ,
C++ Builder.
++ Builder
C++ Builder
.
,
,
. ,
File/New Application.

C++ Builder Project1.cpp,


make- Project1.mak.
, , , C++ Builder
.

.7
.
:
.DFM,

.CPP, C++.
.H,
.
,
.
,
File/New Form. ,
. File/New,
Forms .

.8
, ,
Compile Compile. ,

, Run Run.
(
).

, C++ Builder
, ,
.
, , Run
Run, ,
.
Windows.
TForm
, ,
, .
C

.
, (
, published). ,
, ,
(
<F1>).
Caption .
Form1, Form2 . .
ActiveControl , ,
, (,
, ).
AutoScroll ,
,
(. . ,
""). true,
, false .
Autosize true,
, .
, false, "" .
BorderStyle
; ,
.
BorderWidth
, . .

, .
, . . , .
Canvas
. ,


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

<Enter>. ,
, ,
.
Constraints
( ).
, . .
Align (
) Anchors (),
.
,
, .
,
. .
Cursor
.
. ,
no .
Docksite
.
DragKind

. :
dkDrag,
, dkDock,
. DragKind

dkDock, DragMode dmAutomatic,

:
( ),
. DragMode = dmManual.
, ,
.
DragKind dkDock,
:
, .

. ,
Windows
.
Enabled ( Action) :
true , , false .
, false,
:
, .
Font . ,
, .
Font, ,

.
FormStyle :
MDI-.

(SDI) FormStyle DefaultMonitor
.

Hint . ,
, , ShowHint
( ) true.
HorzScrollBar, VertScrollBar ,

.
KeyPreview ,
, .
KeyPreview true,
,
(
ActiveControl). KeyPreview
false,
.

(<b>,

. .) KeyPreview,
.
KeyPreview false. ,
,
, ,
. KeyPreview true

, 6

Menu MainMenu,
,
.
ModalResult ,
.
ModalResult mrNone.
Name .

PopupMenu PopupMenu
( ), ,
, .
.
Position .
Tag ,
.
Visible false,
.

onActivate , .
onClick .
onClose , .
onCreate , .
onDeactivate , .
onKeyDown ,
.
, (<F1><F12>)
<Shift>, <Alt> <Ctrl>.
onKeyPress ,
( ) , .
onKU- , ,
. ,
<Shift>, <Alt>
<Ctrl>, .
onMouseDown ,
<Shift>, <Ctrl> <Alt>
.
.

onMouseMove ,
, (
). Y
.
onMouseUp ,
, .
Y .
onPaint , .
onShow , .

,
, <F1>
.
lose() . ,
.
Hide() visible false
.
Print() .
Release()

.
SetFocus() : visible Enabled
true: .
Show() : visible
true,
.
ShowModal() .
, ,
. ,
ModaiResult .

TButton
TButton () -
.
TButton ,
.
TButton
TButton:
Cancel true, ,
<Esc>,
OnClick.
(Cancel), OnClick
( TabOrder) .
Caption (
).
Cursor .
Enabled
.
Font .
ModalResult ,
, .
.
, ModalResult ,
, ,
.

ModaiResuit :
ModalResult ,
,
.

, .

Form1->Close()

PopupMenu
. ,
PopupMenu.

(
), ,
.
TabOrder .
TabStop
<b>. TabStop
true, ,
TabOrder. TabStop false,
,
<>.
Visible
(
).
WordWrap true,
( caption) .
TButton
onClick , .
onEnter , , . .
: .
onExit , .
TButton

-.
.

Click() .

ModalResult

ModalResult OnClick.
Focused() true,
(. . : ).
.
Hide () : .
SetFocus () : .
Show() : visible
true.
TPanel
Standard .
, , ,
.

()

TCustomPanel.
TCustomPanel

.
, .

, .
.
Align,
,
. ,
, ,
.
,
.

TPanel
, .
BevelInner .
bvLowred,
, bvNone, ,
bvRaised,
.
BevelOuter

, BevelInner.
BevelWidth
BorderWidth
.
BorderStyle .
bsSingle, bsNone.
Align
: alTop , alBottom
, alLeft , alRight , alNone
, , alClient
.
Alignment , caption,
, :
, . ,

( Caption ),
Alignment taLeftJustify,
.
TPanel
onEnter (, ,
, ),

onExit (
),
onClick ( ).

,
,
.
TPanel
, .
,
<F1> .
TLabel
Standard .
,
.

, ""
.
TLabel
Alignment () ,

Caption:

,
.
FocusControl ,
,
(, TEdit, TButton .).
,
, Caption
(&) ,

"" , .

, FocusControl
( ,
ShowAccelChar true).
Align .

: ,
, . .
Layout , Caption,
. ,
: ,
(
, ).
Transparent
, . ,
, . . true.
WordWrap true, AutoSize false,
( , )
Caption (
).
TEdit
Standard .
:
.
TEdit

AutoSelect ,
,
( true),
( false).
BorderStyle ,
.
.
CharCase ,
. :
ecLowerCase ;
ecNormal ;
ecUpperCase .
HideSelection

,
(true , false
).
PasswordChar , TEdit
, ,
,
. , :
Editl->PasswordChar='*'
TEdit .
ReadOnly ,
: true ,
false .
Text - , .
TEdit,
, Text..
TEdit, ,

Text,
.
TEdit

onKeyDown: ,
,
.
. , ,

<Enter>.
<Enter>
TEdit
: .
Clear () : .
SelectAll () .
SetFocus () :
.
GetTextLen () .
Hide () .
Show () : .
TLabeledEdit
Additional .
TEdit TLabel.
/,
TEdit, TLabel .

/
Caption LabeledEdit.

,
, C+
+Builder
.
ShowMessage(AnsiString Msg)
.
, Msg .
:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ShowMessage(" ");
}
int

MessageDlg

(AnsiString

Msg,

TMsgDlgType

DlgType,

TMsgDlgButtons Buttons, int HelpCtx)


.
Msg .

,
:
mtWarning (
Warning);
mtError (
Error;
mtInformation ( "i"
Information);
mtConfirmation ( "?"
Confirmation);
mtCustom ( ,
).

AButtons
:
mbYes ( Yes)

mbAbort ( Abort)

mbNo ( No)

mbRetry ( Retry)

mbOk ( OK)

mbignore ( Ignore)

mbCancel ( Cancel)

mbAll ( All)

mbHelp ( Help)

AButtons

mbYesNoCancel mbOKCancel,
: mbYesNoCancel =[mbYes, mbNo, mbCancel]
mbOKCancel = [mbOK, mbCancel]
( Help)
, ( ModalResuit)
MessageDlg.
Helpctx () ,

<F1>.
. MessageDlg:
void __fastcall TForm1::Button2Click(TObject *Sender)
{
TModalResult rez;
if (Edit1->Text.Length() < 8){
rez

MessageDlg("

\n!

?",mtWarning,TMsgDlgButtons()<<mbYes<<mbNo,0);
if (rez == mrYes) Edit1->Text = DateToStr(Date());
if (rez = mrNo) Edit1->SetFocus();
}
}
:Button2
.

Edit1,

. ,

. ,
,
.
int MessageDlgPos (AnsiString Msg, TMsgDlgType DlgType,
TMsgDlgButtons Buttons, int HelpCtx, int X, int Y)
MessageDlg ,
.
AnsiString InputBox (AnsiString ACaption, AnsiString APrompt,
AnsiString ADefault)
.
, Cancel. ACaption
, APrompt
. ADefault ,
(
Cancel <Esc>).
InputBox:
void __fastcall TForm1::Button3Click(TObject *Sender)
{
AnsiString soname ;
soname

InputBox("",

"

",

"");
}

. .
bool

InputQuery

(AnsiString

ACaption,

AnsiString

APrompt,

AnsiString & Value) InputBox ,

value,
.
,
, .
, True,
Cancel <Esc> False.
void __fastcall TForm1::Button4Click(TObject *Sender)
{
AnsiString soname;
soname= "";
InputQuery("", " ", soname);
}
InputQuery .
InputQuery .

.
Edit Label
.

().

//
void__fastcall TForml::EditlKeyPress(TObject *Sender, char &Key)

{
// ,
//
// Key -
// ,
if ( (Key >= ' 0 ' ) && (Key <= ' 9 ' ) ) //
return;
// DecimalSeparator
// ,
//
if (Key == DecimalSeparator)
{
if ((Editl->Text).Pos(DecimalSeparator) != 0)
Key = 0; //
return;
if (Key == VK_BACK) // <Backspace>
return;
if (Key == VK_RETUKN) // <Enter>
{
Edit2->SetFocus();
return;
}
//
Key = 0;
//
}
//
void __fastcall TForml::Edit2KeyPress(TObject *Sender,char &Key)
{
if ((Key >= ' 0 ') && (Key <= ' 9 ')) //

return;
if (Key == DecimalSeparator)
if ((Edit2->Text).Pos(DecimalSeparator) != 0)
Key =0; //
return;
if (Key == VK_BACK) // <Backspace>
return;
if (Key == VK_RETURN) // <Enter> .
Buttonl->SetFocus();//
// <Enter>
//
return;
}
//
Key =0;
//
}
//
void__fastcall TForml::ButtonlClick(TObject *Sender)
{
float usd; //
float ; //
float rub; //
// ,
if (((Editl->Text).Length() ==0) || ((Edit2->Text).Length() == 0))
{
MessageDlg('Ha

TMsgDlgButtons() << mbOK, 0)


if ((Editl->Text).Length() == 0)
Editl->SetFocus(); //

",mtInformation,

else
Edit2->SetFocus(); //
return;
}
//
usd = StrToFloat(Editl->Text);
k = StrToFloat(Edit2->Text);
//
rub = usd * k;
//
Label4->Caption

FloatToStrF(usd,ffGeneral,7,2)

+"$

"+FloatToStrF(rub,ffGeneral,7,2) + " .
}
//
void__fastcall TForml::Button2Click(TObject *Sender)
{
Forml->Close(); //
}

-
-,
. ,
,
.

__fastcall TForml: :TForml (TComponent* Owner) : TForrri(Owner)


{
/* Editl (
),
*/
Buttonl->Enabled = False;
}
// Editl
void__fastcall TForml::EditIKeyPress(TObjt *Sender, char &Key)
// ,
//
// Key -
// ,
if ((Key >= '0') && (Key <= '9')) //
return;
// DecimalSeparator.
// ,
//
if (Key == DecimalSeparator)
{
if ((Editl->Text).Pos(DecimalSeparator) != 0)
Key =0; //
return;

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


return;
if (Key == VK_RETURN) // <Enter>
{
Buttonl->SetFocus();
return;
//
Key =0;
//
}
// Editl
void__fastcall TForml::EditlChange(TObject *Sender)
{
// , Editl
if ( (Editl->Text).Length() == 0)
Buttonl->Enabled = False; // .
else Buttonl->Enabled = True; // .
Label2->Caption=;
}
//
void__fastcall TForml::ButtonlClick(TObject *Sender)
{
double funt; //
double kg; //
// ,
// Editl . ,
// .
funt = StrToFloat(Editl->Text);
kg = funt * 0.4995;
Label2->Caption = FloatToStrF(funt,ffGeneral,5,2) +

" . - " +FloatToStrF(kg,f fGeneral,5,2) + " ;


}
TMainMenu
Standard .
,
.

, .
.
.
,
.
Menu, TMainMenu.
,

, .
(
), : .

. :
MenuDesigner ,
,
items .
, .
,
.
- .
, ,
, ,

. (. .
), , ,
, Events
OnClick, ,
, , .
TMainMenu
Images
.
, TImageList
( Win32 ),
.
ImageList ImageList Editor.
..
ImageList , Images
. , ( ),
ImageIndex.
, MainMenu Items
. File.
ImageIndex.
, . ,
.
Items ,
.
TMenuItem.
TMainMenu
Bitm
. .
Checked ,
:
OnClick Checked

true. , false,
.
.
RadioItem true, Checked
false, . RadioItem=true
Checked=true ,
GroupIndex (
, ) ,
GroupIndex .
.
ShortCut
,

,
.
.
,
.

,

, Visible Enabled
. ,
Enabled false (, : N111>Enabled=false;), ,
Visible false.

Standard .

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

, .
, ,
.
, .
, Popup(),
.
T Left.
(m, n),
:
Form1->PopupMenul->Popup(Forml->Left+m,Forml->Top+n);
,
,
:
Form1->PopupMenul->Popup (Forml->Left, Forml->Top+25);

. ,
,

CreateSubMenu.

.

, ,
TMainMenu

n .
.
Alignment ,
( ,
( ,
Right
)).
AutoPopup AutoPopup false,
-
(), ,
, .
MenuAnimation
: ,
, - . . ,
.
TrackButton ,
. .

OnPopup .
Checked, Enabled
Visible .

.
Popup() PopupMenu

Standard .

.Tm

TStrings.
Lines, i-
:
Memol->Lines->Strings[i];
,
, ,
Lines. Lines
TStrings. Lines
. , Count,
.
Memol->Lines->Count
Memo-.

Lines .
,
Windows, .
Memo. Lines

Memo-.

i- : Memol->Lines->Strings[i].Length();
Lines TStrings,,
,

AnsiString:

AnsiString TStrings[int n]; To strings [i]


AnsiString
,
Length (). . . ,
,
, .
TStrings LoadFromFile ("_")
SaveToFile ("_"), Memo-

.
, ,
Memol->Lines->LoadFromFile("a.txt");
Memo-: Memol->Lines->Clear() ;
MaxLength- ,
Memo-. (
), ,
.
ScrollBars Memo-.
WantTabs false (
), <b>
TabOrder.
WantTabs true, Tm,

.

nChange.
.
,

.
CopyToClipBoard() Memo-
Windows - .
CutToClipBoard() , .
PastFromClipBoard() ( Memo- ).
TListBox
Standard .

.
, .


,

, . .
.
.
,
Tmemo, Lines,
Items. TListBox Items
, Lines Tmemo.
TListBox
Iitems, ItemIndex. Items, Lines
Tmemo, Tstrings,
, , Strings,
AnsiString. , -,
Tstrings count,
strings, . . ListBoxl->Items->Count;
. -, TListBox
ItemIndex,
,
, ListBoxl->Items>Strings[ListBoxl->ItemIndex]; ,
ItemIndex . .
TStrings, TListBox,
. -: . .
Ansistring,

.
TStrings, Items,
Add() , Delete()
, ,
ListBox. ,
ListBoxl->Items->Add(" ");
: ListBoxl->Items->LoadFromFile("a.txt");
Sorted ,
.
Multiselect
. MuitiSeiect=true,
. MuitiSeiect=faise,
. Multiselect ,
, ,
ExtendedSelect. MultiSelect=true ,
ItemIndex, ,
, , . . .
TListBox
( ) .
-
. .
TListBox
Clear () .
SetFocus () ( ).
Hide () .
Show () .
Sort () .

TListBox

. ,
.
, Perform()
Windows API.
int MaxWidth=1000;
,

ListBox1-

>Perform(LB_SETHORIZONTALEXTENT,MaxWidth, 0) ;
,
Perform.
void __fastcall TForml::ButtonlClick(TObject *Sender)
{
int MaxWidth=1000;
ListBoxl->Perfom(LB_SETHORIZONTALEXTENT,MaxWidth,

0)

ListBoxl->Items->LoadFromFile("c:\\a.txt");
}
.
, .
,
...: ...,
,
:
if (ListBoxl->ItemIndex < 0)
ShowMessage (" ");
else ShowMessage (" " +
IntToStr (ListBoxl->ItemIndex + 1) + ": " +
ListBoxl->Items->Strings [ListBoxl->ItemIndex] ) ;

TComboBox
Standard .

TListBox:
.
:
( ),
. ,

AutoComplete,

.
,
, .
, ,
, . .
.

),
Text. :
drop-down ( ), drop-down list simple.
style.
csDropDown ,
, . ,
. ,
AutoDropDown,
.
csDropDownList
,
. , ,
,
DropDownCount.

csSimple ,
, (

, Text).

. , Height,
, (
), ,
. ,

, .
TListBox.
, TListBox.

TStringGrid
TStringGrid ( )
, .

,
.
, .
,
.
.
ColCount RowCount
int, .

,

. ColCount RowCount
5, 5*5.
DefaultColWidth
DefaultRowHeight

int.

,
.
DefaultColwidth

64

DefaultRowHeight 24 .
ColWidths [int Index] RowHeights [int Index] int

, index.

. StringGridl.ColCount++;
StringGridl
.
,


ScrollBars

TScrollStyle,

, ,
.
FixedCols FixedRows
.
.
1.

.

.

VisibleColCount VisibleRowCount,

.
, .
LeftCol TopRow.
,
.

Cells[int ACol,ARow] AnsiString,
, .
.
,
.

Options
TGridOptions.
, .
goFixedVertLine -

goFixedHorzLine -

goVertLine -

goHorzLine -

goRangeSelect - .
, True
goEditing

goDrawFocusSelected -
,
. goDrawFocusSelect
( False) , ,

goRowSizing -
goColSizing -

goRowMoving -

goColMoving -

goEditing -
.

goEditing

goRangeSelect
goTabs -
<b> <Shift+Tab>
goRowSelect - .
, goAlwaysShowEditor
goAlwaysShowEditor ,
<F2> . goEditing,
.
goRowSelect, goAlwaysShowEditor
goThumbTracking -
. ,


,
goEditing.
:

, goAlwaysShowEditor;
;
<F2> <Enter>, EditorMode
True.

.
.
Row Col
.
,
.
Cols [int Index] Rows [int Index] AnsiStrings

.


:
1. ,
,
.
2. ,
,
.
3. .

, :

, ,
(Button1).
StringGrid1.

(Label2).

#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//--------------------------------------------------------------------------#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)


{
int SIZE=10;
int a[10];
int min; // i
//
int j; // ,
int buf;// ,
int i,k;
//
for (i=0; i<SIZE;i++)
a[i]=StrToInt(StringGrid1->Cells[i+1][1]) ; Label2->Caption="";
for (i=0; i<SIZE-1;i++)
{
// [1] a[SIZE]
min=i;
for (j=i+1;j<SIZE;j++) if (a[j] < a [min])
min=j;
// a [min] a[i]
buf=a[i]; a[i]=a[min]; a[min]=buf;
//
for (k=0;k<SIZE;k++)
Label2->Caption=Label2->Caption+' '+IntToStr(a[k]);
Label2->Caption=Label2->Caption+'\n'; }
Label2->Caption=Label2->Caption+'\n'+"Macc ";
}
//--------------------------------------------------------------------------
.


.
, , ,
, . ,

(), ().

"". ,
, .
1
, 2
, . .


, ,
(Button1).
stringGrid1. ,
,
Label2.

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//--------------------------------------------------------------------------#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)
{
}
//--------------------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
int SIZE=10;
bool changed;
int a[10];
int min; // i
//
int j; // ,
int buf; // ,
int i,k;
//
for (i=0; i<SIZE;i++)
a[i]=StrToInt(StringGrid1->Cells[i+1][1]) ; Label2->Caption="";
do
{
changed=False; //
for (k=0;k<SIZE-1;k++)
if (a[k] > a[k+1])
{
// k- k+1-

buf = a[k]; a[k] = a[k+1]; a[k+1] = buf;


changed = True;
}
//
for (k=0;k<SIZE;k++)
Label2->Caption=Label2->Caption+' '+IntToStr(a[k]);
Label2->Caption=Label2->Caption+'\n';
}
while (changed);
Label2->Caption=Label2->Caption+'\n'+"MaccMB ";
}
,

. ,
. , 5 1 2 3 4,
,
, .
changed,
FALSE.
,

, , .


TMaskEdit
Additional .

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

,
. ,
.

:
! ,
.

.
> , ,

<.
< , ,

>.
<> , ,
, .
\ , ,
, , ( ).
L , ,

Z, z.
- .
l , ,
. ,
.
A , , . Z,
z, 09
A,
.
,
.

,
.
0 ,
.
9 0,
.
# (+, -),
.
: ,
.
, .
/ , .

, .
; .
_ :
,
_.
, ,
(. . )
. .
,
. , ,

\,

"" (
).
, ,
- . ,
: (000)_000-0000;0;*.

(0) (, )
, Text
10 14-, . . ()
.
EdittMask.
,
, .
_, .
, _
, , .
| 0955551212 | ! \ ( 9 9 9 \ ) 000-00-00;0;_
| 123456 | 10000000;1;_
! VII123456 | 1L-LL 999999;0;_
| 010302 | !99/99/00; 1;_
| 0302 | ! 99/00;1;_
| 210515 | ! 90 : 00 : 00 ; 1;_
| 1345 | ! 90:00;1;

( ) ,

EditMask. ,
.

Input Mask .

Sample

Masks,

.
Character for Blanks ,
.

Save Literal Characters,

.

Input , .
Masks ,
, .
, , ,

Text.

) EditText.
TCheckBox
Standard .
,

Caption.
Checked
: false, ,
true, . State
: (cbChecked), (cbUnchecked)
(cbGrayed). , , , , ,
, .
, AllowGrayed .
________________________________________________________
void __fastcall TForml::CheckBox1Click(TObject *Sender)
{
if (CheckBoxl->State==cbChecked)
Lbl1->ti=" ! ";
else if (CheckBoxl->State==cbUnchecked)
Labell->Caption="ao !";

else
Labell->Captio="ao ";
}
onClick .

.
TRadioButton
,
, .
TCheckBox, (,
) ,

, .
TRadioGroup

TRadioGroup.
TRadioGroup ,
. TRadioGroup
, .

,
.
,
.

TRadioGroup, Items
( TListBox). Items

. ItemIndex

RadioGroup1-

>ItemIndex==0, , .
,
ItemIndex, : RadioGroupl
->Items->Strings[RadioGroupl->ItemIndex]="";


Columns.
TCheckListBox
TCheckListBox .

TheckListBox TListBox. ,
, .
,
. , .
, . ,
.
.
void __fastcall TForm1::CheckListBox1ClickCheck(TObject *Sender)
{
switch (CheckListBox1->ItemIndex) {
case

0:Edit1->Text=CheckListBox1->ItemIndex;if

(CheckListBox1-

>Checked[0]==true) Edit1->Text=6;else Edit1->Text=-6; break;


case

1:Edit1->Text=CheckListBox1->ItemIndex;if

(CheckListBox1-

>Checked[1]==true) Edit1->Text=5;else Edit1->Text=-5; break;


case

2:Edit1->Text=CheckListBox1->ItemIndex;if

>Checked[2]==true) Edit1->Text=2;else Edit1->Text=-2; break;


default:

(CheckListBox1-

;
}
}

TImage
Additional .

. ,
Picture.
,
BMP, JPEG, . TImage

( TImage
).
Tlmage
Picture , .
TPicture,
, , ,
Picture.^
,
.

TPicture:
LoadFromFile () .

>LoadFromFile("_");

Imagel->Picture-

SaveToFile () .
: Imagel->Picture->SaveToFile("_");
Stretch ,
,
,

stretch true,
. ,
. stretch
.

,
AutoSize Stretch.
Picture , Stretch .
AutoSize false,
.
Autosize=true. :

AutoSize=true,


, .
Stretch

(AutoSize=false), Stretch.
Canvas
.

. Pen, Brush .
Canvas , Picture
bmp-.

TShape
Additional .
,
Shape.
Brush olor Style.

Pen. ,
Strush.
TBevel
Additional .
:
, ,
,

Shape, Style
, .
TPageControl
Win32 .
,
.
, ,
TPageControl,
, .
,
.

, ,

TPageControl,

.
,


. .
, .

TPageControl
,
New Page, Next Page, Previous Page, Delete Page,
.
New Page ,

.
, .
TTabSheet
TPageControl
TTabSheet
. :
PageIndex ( )
, TPageControl.
, ,
.
,

PageIndex

, .
, TabSheet1->PageIndex
.
TabIndex
( TabVisibie).
0 , 1
. . TabIndex
PageIndex . TabVisible

false, a TabIndex -1,


Tablndex=-1.
TPageControl
ActivePage (. . ,
). ,

(.. ):
PageControl1->ActivePage=TabSheet5;
RaggedRight, true,
.
TabPosition

: (T), (Bottom), (Left)


(Right).
ScrollOpposite , (

ScrollOpposite false, :

, .

ScrollOpposite
:

true,

.
ActivePageIndex
.
[] .
ActivePageIndex .
,
Pages:
ActivePageIndex
ActivePage, . .
ActivePageIndex.

, ActivePageIndex
-1. ActivePageIndex ,
(
),
. .
Pages :
TTabSheet.
, ( ). ,
: PageControll->Pages[4].
PageCount
TPageControl. MultiLine
false, ,
, PageCount
: .
Canvas ,
, OnDrawTab.
TOpenDialog
Dialogs .


, Windows,
.
Windows .

Execute ().
( On -
Windows) ,
Execute () true,
FileName .

, ,
, TOpenDialog,
:
if (OpenDialog1->Execute() ) ;

Windows .
, ,
FileName. .
, Memo-.
TMemo :
Memol->Lines->LoadFromFile(OpenDialogl->FileName);

InitialDir.

Execute ().
, .
Filter.
,
Filter Editor,
. , Filter Editor,
Filter. Filter
| ().
,
. ,
, :
OpenDialogl->Filter="Pascal files | *.pas;*.dpk;*.dpr";
Filter ,
,
.
TOpenDialog

Options .
.

ofReadonl

y
ofOverwri

tePrompt


(
ofHideRea

TSaveDialog TSavePictureDialog)
" "

dOnly
ofNoChan

geDir

, ,

(

ofShowHe

TSaveDialog SavePictureDialog)

lp
ofNoValid

ate
ofAllowM

(, &)

ultiSelect
fPathMu

stExist

ofFileMus

tExist

(
ofCreatePr

ompt

TSaveDialog
ofShareA

TSavePictureDialog)

ware


Files .
DefauitExt .

, .
, DefauitExt
. ,
, .
. ().
FileIndex ,
, .
. .
FilterIndex 1,
, FilterIndex
2 . . FilterIndex
( ),
.
Title .
, (Open).
TOpenDialog
OnCanClose ,
.
Onlose .

OnFolderChange ,
, (. .
).
OnIncludeItem ,
(
). ,
.
- :
OpenDialog1IncludeItem(const TOFNotifyEx &OFN, bool &Include);

OFN

Windows-,

. include
false, .
, Options
ofEnablelncludeNotify.
OnSelectionChange ,
- (,
).
OnShow , .
OnTypeChange ,
,
.
TSaveDialog
Dialogs .

.

TOpenDialog. ,
Execute () .

Windows .

(Save) , Execute ()
true, FileName
.
. ,

.
,

,

SaveDialog.
void__fastcall TForm1::ButtonlClick(TObject *Sender)
{
if (OpenDialogl->Execute())
Memol->Lines->LoadFromFile(OpenDialog1->FileName);
if (SaveDialogl->Execute())
Memol->Lines->SaveToFile(SaveDialogl->FileName);
}
OpenDialog1
(, LoadFromFile
()).
, Execute () true,
FileName

. Execute ()
true if,
Memo-
( ).
SaveDialogl.

, Memo-,
, .
,
FileName SaveDialogl, Execute ()
true. SaveDialog1 .
.
Execute() true, if
. if SaveToFile()
, (
).
TOpenPictureDialog
Dialogs .

bmp

), jpg ( ), ico () wmf, emf


().
TOpenDialog,

.
TSavePictureDialog
Dialogs .
TSaveDialog. TSavePictureDialog

.
TFontDialog
Dialogs .
:


(, , . .).
Font . Device
,
( ).
,
Execute(). ,
:
if(FontDialogl->Execute())
Panell->Font=FontDialogl->Font;
Options
,
TFontDialog .
fdAnsiOnly ,
Windows.
fdApplyButton (Apply)
onAppiy.
fdEffects
( ) .
fdFixedPitchOnly

.
fdForceFontExist
, ,
.
,
.
fdLimitSize MaxFontSize
( ) MinFontSize (

),
.
fdNoFaceSel
:
.
fdNoOEMFonts OEM- (,
)
. , OEM.
fdScalableOnly
. ()
.
fdNoSimulations
,
.
.
fdNostyleSel
.
fdsHowHelp .
fdTrueTypeOnly TrueType.
fdWysiwyg ,
, . ,
, .
, fdEffects, .
TFontDialog
OnApply- ,
(Apply) .
OnClose , .
OnShow , .

TColorDialog
Dialogs .
.
,
:
Execute(),
Color , .
,
, :
if(ColorDialogl->Execute())
Panell->Color=ColorDialogl->Color;
TColorDialog
CustomColors , ,
.
Colorx= HexValue
( ). , ColorA=808022.
16 ( ColorA ColorP).
,
.
Execute() ,
:

Color

TColorDialog

CustomColors.
Options ,
:
cdFullOpen

cdPreventFullOpen

;
cdShowHelp ;
cdSolidColor Windows
;
cdAnyColor
(
).
.
TColorDialog
OnClose , ;
OnShow , .
TPrintDialog
Dialogs .

,
, Execute()
, true,
, false (Cancel).
TPrintDialog
Collate , .
,
Collate true.
Copies

.
.
FromPage , .

MaxPage, MinPage .
Options ,
.

TPrinterSetupDialog
Dialogs .

. Execute(),
.
, Execute()
, , true.
(Cancel),
Execute() false.
OLE-
System . OLE
, ,
. ,
Word Excel,
Word.
Word Excel,
OLE.

. ,
: ,
OLE,
, OLE-. ,
, , ,
.

Insert
Object.
, OLE-.
OLE-
Iconic , ,
OLE. Iconic=faise ( ),
OLE
. Iconic=true,
. ,
, .
.
Align ,
, .
AllowInPlace ,
OLE . AllowInPlace true,
Iconic false, OLE-
, . AllowInPlace
false, OLE- .
true.
AutoActivate , OLE:
aaManual OLE- ,
DoVerb() ovShow
(Doverb(ovShow))

ovPrimary

(DoVerb(ovPrimary)).
aaGetFocus OLE- , OLE-
(
<b>).

aaDoubleClick ( ) OLE-
<Enter>,
.
AutoVerbMenu

OLE-

,
OLE . AutoVerbMenu
true

),

Mnu,

AutoVerbMenu=false,

.
CopyOnSave ,
SaveToFile() SaveToStream() OLE-.
CopyOnSave true,
SaveToFile () SaveToStream() OLE-,
.
.
CopyOnSave false, OLE-
.
CopyOnSave false , OLE ,
.
true.
Iconic , OLE-
(. . ),
. , OLE
WordPad, true Iconic
OLE WordPad.
,
, false Iconic
OLE WordPad.

SizeMode OLE- OLE:


smClip ( ) OLE-,
OLE-;
smCenter OLE-,

;
smScale OLE-
;
smStretch OLE- ,
,
;
smAutoSize OLE- ,
, OLE-.
TUpDown
Win32 .
. TUpDown
,
, .
Associate.
, Position () ,
, :
. Position
,
. , ,
TUpDown TEdit,
Position ( ).
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
UpDown1->Associate=Edit1;
}
TUpDown
ArrowKes , <>
<>. ArrowKeys true,
,
. ArrowKeys
false, .
Increment Position
. Position
, Min M.
Thousands , ,
.
Wrap true, ,

Position ,

Max Position
Min.

Position, Min, Position


M.
TTimer
System .
. Enabled

Interval

, onTimer.

onTimer

, OnTimer
,
. ,
, ,
Interval.
TProgressBar
Win32 .
,
.

-

TProgressBar. Min, M
. Position ( UpDown,
, )
MinM. StepIt() Position
Step. StepBy(n)
Position n.

TProgressBar no
, TTimer:
(Timerl->Enabled=true;),
Position TProgressBar
(ProgressBarl->Position=0;), OnTimer
Position (ProgressBarl->Position++;).

(ProgressBarl->Visible=false;).
TDateTimePicker
Win32 .
(

Kind)

. TDateTime
Date,
.
. DateMode
:
TUpDown
TCmb. TComboBox,
,
TMonthCalendar
.
(
),
. ,
TDateTimePicker
OnCloseUp
.
TDateTimePicker

CaliAlignment

:
.
CalColors

(, . .).
Checked ,
().
ShowCheckBox. Checked true,
.

Checked

true

.
Date , .
,
MaxDate MinDate. MultiSelect
TMonthCalendar true,
,
EndDate .
TMonthCalendar.
DateTime.
DateFormat ,
: "" ( ,
, ) "", ,
.
Kind ,
. ,
,
.
Time , (
Kind
).

ParseInput OnUserInput.
,
( , ParseInput=true),
.

++Builder TDateTime,
.
double,
,
30.12.1899. 12 00 .
. .
: (.
).
:
DateToStr() Ansistring;
DateTimeToStr ()
Ansistring;
TimeToStr () Ansistring.
/,
TDateTime. :
TDateTime dl,d;
.
CurrentDate() -
TDateTime. .
CurrentDateTime ()
TDateTime.
CurrentTime ()
TDateTime .

DayOfWeek() - 1 7.
, .
DecodeDate() TDateTime ,

: year, month, day.
DecodeTime () , ,

hour, min, sec, msec.
FormatString() TDateTime-,
:
, ,
ShortDateFormat,
LongTimeFormat.
, TDateTime
;
d ;
dd ;
ddd (Sun-Sat),
, ShortDayNames;
dddd- (Sunday-Saturday),
LongDayNames;
ddddd , ,
ShortDateFormat;
dddddd , ,
LongDateFormat;
m ;
mm ;
mmm (Jan-Dec)

ShortMonthNames;

mmmm (January-December)
,
LongMontNames;
yy (0099);
yyy (00009999);
h (023);
hh (0023);
n (059);
nn (0059);
s (059);
ss (0059);
t ,

ShortTimeFormat

:);
tt ,

LongTimeFormat ( :

:);
am/pm 12-
h hh 'am' 'm'
. am/pm ,

;
a/ am/pm, ;
ampm am/pm, ,

TimeAMString

TimePMString;
/ ,
DateSeparator;
; ,
TimeSeparator;

/"" ,
,
. ,
TDateTime "".
operator int TDateTime- .
:
TDateTime df;
int i =df.CurrenTDateTime().operator int();
operator (), . .
TDateTime, : , double,
int.

.
1.
,
.
.
Void __fastcall TForml::ButtonlClick(TObject *Sender)
(
TDateTime dl,d;
dl=d.CurrentDate() ;
AnsiString s = DateToStr(dl)
ShowMessage(s);
dl=d.CurrentDateTime() ;
s = DateTimeToStr(dl);
ShowMessage(s);
dl=d.CurrentTime();
s = TimeToStr(dl) ;
ShowMessage(s);
}

2.
, ,
. ,
.
void__fastcall TForml::ButtonlClick(TObject *Sender)
{
TDateTime dt,d;
dt=d.CurrentDate ();
Word yl,ml,dl;
DecodeDate(dt,yl,ml,dl);
AnsiString s=IntToStr(yl)+
"**" + IntToStr(ml)+
"**" + IntToStr(dl) ;
ShowMessage(s) ;
Word ms;
dt=d.CurrentTime ();
DecodeTime (dt,yl,ml,dl,ms) ;
s=IntToStr(yl)+
"**" + IntToStr(ml)+
"**" + IntToStr(dl);
ShowMessage(s);
}
.
.
.
Using namespace std; /* Borland C++Builder BDS
2006 FormatDateTime() ,
Delphi, . */
TdateTime df;

AnsiString ss=FormatDateTime(d mmmm yyyy *** h:mm,


df. CurrentDateTime());
ShowMessage(ss) ;
4.
(VCL )

Now() Sysutils.hpp.
(Button1 -
):
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->Caption = DateTimeToStr(Now());
}
5.
(VCL )

Time() Sysutils.hpp .
(Button1 - ):
void

__fastcall

TForm1::Button1Click(TObject

*Sender)

{
Form1->Caption

DateTimeToStr(Time());

}
6.
(VCL )

DayOfWeek() Sysutils.hpp, .
DayOfWeek 1 7, 1 - , 2 , . .

int Day = DayOfWeek(Date());


7.

void

__fastcall

TForm1::Timer1Timer(TObject

*Sender)

{
Label1->Caption

Timer1->Interval=10000;//

FormatDateTime("hh:nn",Time());

}
8.

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Label1->Caption=Time().FormatString("hh:mm:ss:zz");
Timer1->Interval=1;
}
9

DWORD

start=GetTickCount();

// -
Edit1->Text=FloatToStr((GetTickCount()-start)/1000.);

:
,

.
File/New Application
samp1.cpp, samp.mak.

Button, Edit ListBox


Standard .


Edit
Text. Caption Button1
"".
OnClick ,
,

OnClick. .
C++ Builder
.
{ ... } :
void

__fastcall

TForm1::Button1Click(TObject

*Sender)

{
if

(!(Edit1->Text

==

""))

""

{
ListBox1->Items->Add(Edit1->Text);
Edit1->Text
}
}

Run Run.
- ,
,
.

.
, .
, Caption
, :


:
void

__fastcall

TForm1::Button2Click(TObject

*Sender)

{
if

(!(ListBox1->ItemIndex

==

-1))

ListBox1->Items->Delete(ListBox1->ItemIndex);
}
:
Close();
, .


C++ Builder


Edit.
, ,
.
:

.
, Tab.
:
Shift,




,
(, Visible, Width, Left).

:
1. .
,
.


2. , .


, .

. ,
,
, .
,
.

.

, .

,
.

.
Edit/Size. Size. .
Width
Height. OK.

EDIT/SIZE
,
Shift.
, .

. ,
(
).


:
Shift +

Shift +

Ctrl

Ctrl

,
View/Alignment Palette. :
.
View/Alignment Palette.
.

View/Alignment Palette
, Edit/Align.
:
.
Edit/Align.
Alignment.
OK.

Edit/Align
,
Options/Environment. :

1.

Options/Environment.

Environment Preferences.
2. Form designer :
Display grid -

Snap to grid -
.
3. , ,
.
-- 8 X ( ) Y (
).
4. OK.

Preferences
Environment
:

,
, ,
,

, Edit1.cpp.
Edit.mak.

TPanel

. Align
Panel1 alTop, Caption -
.
TMemo
Align alClient, ScrollBars - ssVertical,
Lines - ( ,
, , ).

,
Windows, comdlg32.dll.
Dialogs: TOpenDialog TSaveDialog.
Filter OpenDialog1,
Filter Editor OK.

Filter OpenDialog1.

,
Filter, SaveDialog1
Filter.
Filter .
(
Caption) ( Options).
, , StatusBar Win.
Panels (
-,
). .
, .
New Width ,
100. Text " ".
.

Panels StatusBar1.
Panel1
TSpeedButton. ,
Shift SpeedButton Additional
.
.
Glyph .
, ++ Builder (

CBuilder\images\Buttons).
Doorshut.bmp,Filenew.bmp, Fileopen.bmp, Fileclose.bmp,
Filesave.bmp, Cut.bmp, Copy.bmp, Paste.bmp, Help.bmp.

Glyph

SpeedButton1,...,SpeedButton9.
, ,
. ShowHint
True, Hint - "", "", "",
"", " ...", "", "", "", "
".
, .

.

OnClick .
SpeedButton3
:
void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
if (OpenDialog1->Execute()) Memo1->Lines->LoadFromFile(OpenDialog1FileName);
StatusBar1->Panels->Items[0]->Text=OpenDialog1->FileName;
}
SpeedButton5
.
void __fastcall TForm1::SpeedButton5Click(TObject *Sender)
{
if

(SaveDialog1->Execute())

Memo1->Lines->SaveToFile(SaveDialog1-

>FileName);
StatusBar1->Panels->Items[0]->Text=SaveDialog1->FileName;
}
SpeedButton2 .
, ,
, .
, -
.
Windows API MessageBox, :

- (,

0)

n
d
l

( )

p
T
e
x
t
l

( )

p
C
a
p
t
i
o
n
u

( ,

, MB_OK, MB_ABORTRETRYIGNORE .) -

Borland C++ Builder

e
MessageBox -
, : IDABORT,
IDCANCEL, IDIGNORE, IDNO, IDOK, IDRETRY IDYES.
""
"" ,
"" ( - "" "Yes" ).

SpeedButton5Click.
SpeedButton2 :
void

__fastcall

TForm1::SpeedButton2Click(TObject

*Sender)

{
if (Memo1->Lines->Count>0)
{
if

(MessageBox(0,"

"

",

",MB_YESNO)==IDYES)

{
SpeedButton5Click(Sender)
}
};
Memo1->Clear();
StatusBar1->Panels->Items[0]->Text="

";

}
SpeedButton1 .

SpeedButton2Click:
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{ SpeedButton2Click(Sender);

Close();
}
SpeedButton4 :
void

__fastcall

TForm1::SpeedButton4Click(TObject

*Sender)

{
if (StatusBar1->Panels->Items[0]->Text=="

")

SpeedButton5Click(Sender);
else Memo1->Lines->SaveToFile(StatusBar1->Panels->Items[0]->Text)
}
.
-
, (StatusBar1),
.
( ),
, SpeedButton5Click.
SpeedButton6 SpeedButton7
.
void __fastcall TForm1::SpeedButton6Click(TObject *Sender)
{
Memo1->CutToClipboard();
}
//-------------------------------------------------------void __fastcall TForm1::SpeedButton7Click(TObject *Sender)
{
Memo1->CopyToClipboard();
}
SpeedButton8 :
void __fastcall TForm1::SpeedButton8Click(TObject *Sender)
{
Memo1->PasteFromClipboard();

}
SpeedButton9 "
".
.
About C++ Builder.
File/New Forms ,
New Items, AboutBox Copy.
:

About..
.
Form1.
,
. , ,
,
. , ,
,
, .

Options/Project) AboutBox Available Forms.

.
SpeedButton9
:
void __fastcall TForm1::SpeedButton9Click(TObject *Sender)
{
Application->CreateForm(__classid(TAboutBox), &AboutBox);
AboutBox->ShowModal();
AboutBox->Free();
}

AboutBox.
(,
, ).
(
SpeedButton9Click),

AboutBox, .

, ,
.
, (
Windows-
-
, Microsoft). ,
TSpeedButton (
).
.

, .
TMainMenu
Standard. ,
Menu Designer.
, ,
Caption.
: "&" ( "&",
"&...", "&", " &...", '"-","&"), "&"
( "& "), "&" (
"&" "&", "&") "&?" "&
".
Caption - "-",
.
"&"
"" . -
,
,
Alt

. , ""
, C++ Builder .
,
.
, ShortCut.

Menu Designer.

SpeedButton1Click,

...

SpeedButton9Click

.
" ".
Checked true.
" "
OnClick:
void __fastcall TForm1::N9Click(TObject *Sender)
{
N9->Checked=!N9->Checked;
Panel1->Visible=N9->Checked;
}
,
.
TPopupMenu - "", "", "",
- "".

OnClick . , ,

Memo1

Panel1

.
, ,
" ".