Delphi , . Delphi : 70 , 150, Delphi 4 170 . VCL Delphi 3 . , . .
Standard Additional. Windows 95/98 Win32. Win 3.1 .
Standard Delphi , Windws.
TMainMenu
, , Windows-. TainMenu (. . 20). , , Menu .
, , Tenu. , . , ( ) .
:
SomeMenu.Items[1].Caption:= Edit;
. Images: TImageList. TImageList.
Items . Caption (. 21). Enter .
(. 22). , . , .
& , .
, , , Ctrl + .
Break . mbNone. .
|
|
Count .
Default , . Default True, .
Hint , .
Checked = True, .
RadioItem , GroupIndex. True Checked. .
OnClick. , , , , . F10 ( Windows).
. , . , , :
Procedure TForm1.Button1Click(Sender: TObject);
Begin
NewMenuItem:= TenuItem.Create(File1);
NewMenuItem.Caption:= ;
File1.Insert(0, NewMenuItem);
End;
Create (File1), . . Insert . , Add.
NewMenuItem TMenuItem:
Var
NewMenuItem: TMenuItem;
TPopupMenu
, , . . , PopupMenu -. AutoPopup: Boolean .
TMainMenu.
. 23 . , .
. 23. TLabel
:
TLabel. AutoSize False. . TPopupMenu : N1, N2, N3. N1, N2, N3 Name . . Alignment Label1:
//
Procedure TForm1.N1Click(Sender: TObject);
Begin
Label1.Aligment:= taCenter;
End;
//
Procedure TForm1.N2Click(Sender: TObject);
Begin
Label1.Aligment:= taLeftJustify;
End;
//
Procedure TForm1.N3Click(Sender: TObject);
|
|
Begin
Label1.Aligment:= taRightJustify;
End;
TLabel
. , , , , Caption. , , TEdit TMemo.
Autosize , Caption : True .
Layout (tlTop, tlCenter, tlBottom).
Transparent .
WordWrap / . : AutoSize=False, WordWrap=True.
TEdit
, . TEdit . ReadOnly True.
:
AutoSelect , .
AutoSize = True Border Style = bsSingle, Font.Size.
BorderStyle .
MaxLength . 0, .
OEMConvert True, MS-DOS Windows .
PasswordChar , . .
ReadOnly = True, .
OnChange .
Tdit :
Clear .
ClearSelection .
CopyToClipboard Clipboard.
CutToClipboard Clipboard, .
PasteFromClipboard Clipboard, , Clipboard .
SelectAll .
, , . , . . . ,
If Edit1.Text = Then Begin Edit1.SetFocus; Exit End;
Edit1 , , .
, . OnKeyPress. OnKeyPress . :
Procedure Tform1.Edit1KeyPress (Sender: Tbject; Var Key:Char);
Begin
If Not (Key in [0.. 9]) Then Key #27;
End;
, .
TMemo
Temo , / . TStrings , , . , Text Lines. Text , Lines .
Tdit. WordWrap, TLabel.
: ScrollBars ; WantReturns = True, Enter , ; WantTabs Tab
|
|
Add, Delete Insert , . CopyToClipboard, CutToClipboard PasteFromClipboard. , SelectAll, SelText. Memo , LoadFromFile:
If FileExists(c:\autoexec.bat) Then
Memo1.Lines.LoadFromFile(c:\autoexec.bat);
, Memo.
, .
: TLabel ; TMemo ; TButton (. 24).
:
{ }
Function GetLine(st:string; { }
n:integer) { }
:string; { }
var p:integer;
begin
{ , }
while (pos( ,st)=1)and (length(st)>0) do
delete(st,1,1);
if n>1 then
repeat
p:=pos(#13,st);
if p <> 0 then
begin
st:=copy(st,p+2,Length(st)-p); // - :
//13 10; , }
while (pos( ,st)=1)and (length(st)>0) do
delete(st,1,1); n:=n-1;
end;
until (n=1)or(p=0);
{ st }
if n>1 then result:=
else
begin
p:=pos(#13,st);
if p <> 0 then result:=copy(st,1,p-1) else result:=st;
end;
end;
:
procedure TForm1.Button1Click(Sender: TObject);
const
SIZE=5; { }
Var a:array[1..SIZE]of string[30]; i:integer; st:string;
begin
{ }
for i:=1 to SIZE do
a[i]:=GetLine(Memo1.Text,i);
{ }
st:=;
for i:=1 to SIZE do
st:=st+IntToStr(i)+ + a[i]+#13;
ShowMessage(st);
end;
TButton
TButton . , . .
, OnClick Enter. , Default True. Cancel , OnClick Esc. Cancel, Cancel True.
, , , . , . . ModalResult, ModalResult . Delphi ModalResult:
mrNone ; mrOk OK;
mrCancel Cancel; mrAbort Abort;
mrRetry Retry; mrIgnore Ignore;
|
|
mrYes Yes; mrNo No;
mrAll All;
TCheckBox
TheckBox , / // . State ( : cbUnchecked ; cbhecked ; cbGrayed ), , . . Checked /.
. Memo (. 25).
. 25.
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
If CheckBox1.State = cbChecked Then // ,
Memo1.Font.Style:= [fsItalic] // ,
Else Memo1.Font.Style:= [ ]; // .
end;
procedure TForm1.CheckBox2Click(Sender: TObject);
begin
If CheckBox2.State = cbChecked Then
Memo1.Font.Color:= clBlue
Else Memo1.Font.Color:= clBlack;
end;
TRadioButton
TCheckBox TRadioButton , . , , . Checked True, , , False.
TListBox
, .
, , .
:
OnDrawItem , . Control, Index, Rect State. Canvas.
OnMeasureItem Style=lbOwnerDrawVariable. OnDrawItem .
Items. Add, Delete Insert . Items ( TString), , . , , ItemIndex, , - Selected. , Sorted True. ItemHeight. , IntegralHeight True. MultiSelect . SelCount , . Columns.
Canvas .
Style : lbStandart Windows; . (Fixed ).
OnClick. (. 26).
procedure TForm1.ListBox1Click (Sender: TObject);
Var F: String;
begin
F:= ListBox1.Items[ListBox1.ItemIndex];
Label1.caption:= F;
end;
. 26. TListBox
TComboBox
, , . TListBox Tdit. .
(. . 27), Style: csSimple, csDropDown, csDropDownList, csOwnerDrawFixed csOwnerDrawVariable. , . csDropDownList ( ). csOwnerDrawFixed csOwnerDrawVariable .
DropDownCount , .
|
|
DroppedDown , . , .
OnDropDown .
TScrollBar
, . .
:
Kind .
LargeChange .
Max .
Min .
Position .
SmallChange .
SetParams (Aposition, Amax, Amin:integer) Position, Max Min.
OnScroll Position.
OnChange SetParams.
(. 28):
procedure TForm1.ScrollBar1Change(Sender: TObject);
Var x: integer;
begin
x:=ScrollBar1.Position;
Label1.Caption:= IntToStr(x);
end;
. 28. TScrollBar
TGroupBox
. , ( ). ( ) Caption.
TRadioGroup
GroupBox RadioButton. TRadioGroup TRadioButton. Items , .
(. 29) Label1, Panel1. Align alTop, RadioGroup1 alClient.
. 29. TRadioGroup
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
With RadioGroup1 Do
Begin
If Itemindex = 0 then Label1.Caption:= ;
If Itemindex = 1 then Label1.Caption:= ;
If Itemindex = 2 then Label1.Caption:= ;
End;
end;
:
Columns ;
ItemIndex ;
Items .
TPanel
. Align .
:
BevelInner .
BevelOuter .
BevelWidth .
BorderStyle .
BorderWidth .
FullRepaint / .
C OnResize .