.


:




:

































 

 

 

 


With ASomeType As TAnotherType Do




, , , . EInvalidCast.

As Sender, , Sender :

(Sender As TControl).Visible:=True;

, () :

With TAnotherType(ASoineType) Do...

As . - . Sender TObject, , .

, - .

, , - . , , , , , .

 

RTTI " " . RTTI , , () (Class reference). Class Of , TObject System TClass:

Type TObject=Class;

TClass=Class Of TObject;

TComponentClass, TControlClass ..

:

- , , .

:

;

, :

(Is As).

.

, . , , .

- , .

Type

TMyClass=Class(TObject)

...

End;

TObjRef=Class Of TObject;

Var ObjRef: TObjRef;

S: String;

Begin

ObjRefs^TMyClass; // ,

S:=ObjRef.ClassName; // S "IMyClass'

...

S:=Sender.ClassName; // S

, .

Type

TMyControl=Class OfTControl;

...

Implementation

Function MyCreate(MyClass: TMyControl; Const MyName: String;

X, Y, W, H: Integer): TControl;

Begin

// , MyClass

Result:=MyClass.Create(Forml);

With Result Do Begin

Parent:=Fonnl; // Parent: =Forml.Panell; -

Name:=MyName;

SetBounds(X. Y, W, H);

Visible:=True;

End;

End;

Begin

//

MyCreate(TEdit, 'Editi', 10,10,100,20);

ComponentCount Components [Index] Is FindComponent.

For I:=0 To ComponentCount-l Do

lfComponents[I| Is TEdit Then Components|I].Free;

FindComponent('Editl').Free;

FindComponent(TControl(Sender).Name).Free;

Delphi , .

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

- , VMT, - VMT . , , . , , - (late binding). . VMT DMT.

, - ,

.

- :

-, () . ,

() -;

-, . , -.

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

, , :

, ;

, ;

, , -, .

Type

TBaseClass=CIass //

FDate: TDateTime;

Function GetDate: String; Virtual; Abstract;

End;

TDateCIass=Class(TBaseClass) //

Function GetDate: String; Override;

End;

TTimeCIass=Class(TBaseClass) //

Function GetDate: String; Override;

OnClick FormClick.

, ( - Repaint), , .

:

(Sender As TControl).Hint:=' !';

ShowHint True, . . .

TControl, , .. .

, , , , . , , .

VMT (DMT). VMT (, VMT - , ). , VMT , VMT .

, . .

(PROPERTIES)

(property) - , , , . , Visible , . Enable , . - , / .

, . , . , , ; / . .

, . , , . .

:

Property < >: < > [Index < >} [Read < \ >] [Write < \ >} [Stored < >] [Default < >|NoDefault] [DispID < >] [Implements < >

:

Delphi :

, , Width, Height, , ( , ), (False, True) ;

, (Name), (Caption),

(Text):

, Borderlcons (biSystemMenu, biMinimize, biMaximize, biHelp). (Published) 32 (0..31). Public;

, , Lines (TStrings). Published. ;

;

, , TFont. . - TPersistenf.

, .

, . , Read Write .

/ , .

, , , , , . , , ( Var ), @.

Read Write. Read , , , , , Write, .

, . Read.

Protected, , , . , , (Abstract) (Overload).

Read Write , . .

, , .

, Automated , Read, Write DispID.

Type

TAnyClass=Class(TComponent) //

Private

FCount: Integer; //

Protected

Function GetCount: Integer; //

Procedure SetCount(Value: Integer); //

Public

Property Count: Integer Read GetCount Write SetCount Default. 1; //

End;

Var AnyObject: TAnyClass; //

Function TAnyClassGetCount: Integer; //

Begin

GetCount:'=FCount; //

End;

Procedure TAnyClass.SetCount(Value: Integer); //

Begin

If Value>=0 Then FCount:=Value Else FCount:=0; //

End;

Count GetCount SetCount. , :

AnyObject.Count:=123;

AVariable:=AnyObject.Count;

. , . , , . , "" "", , .

. , .

. .

Type

TAnyComponent=Class(TConiponent) //

Private

FCount: Integer; //

Procedure SetCount(Value: Integer); //

Public

Property Count: Integer Read FCount Write SetCount; //

End;

Delphi , . Delphi , , , Private .

. .

6.2. -

- , .

- :

Property < coucma>[[Const] <1>:< >

[; [Coast] <2>:< >] ]: < >

[Read < >]

[Write < >][; Default];

:

- , .

- Const.

Default - .

- .

Property FieldValues[Const FieldName: String]: Variant; Default;

// Table, Query u TSoredProc, . TStrings. Values.

Function GetValue(Const Name: String): String;

Procedure SetValue(Const Name, Value: String);

Property Values[Const Name: String]; String Read GetValue Write SetValue;

Type

ArrStr=Array[1..7] Of String[10]; // -

TAnyClass=Class //

Private

FArr: ArrStr; // - Function GetIntArr(iIndex: Integer): String; // Function GetStrArr(sIndex: String): Integer; // Public

Property Plnt[ilndex: Integer]: String Read GetIntArr;

Property PStr[sIndex: String]: Integer Read GetStrArr;

End;

. , -.

Function TAnyCIass.GetStrArr(sIndex: String): Integer;

Var I: Byte;

Begin

Result:=-l;

For I:=l To 7 Do IfUpperCase(FArr[I])=UpperCase(sIndex) Then Result:=I;

End;

Read

, . ( ) ( ). , , .

:

, .

, , .

- , -, .

-. - Get.

Write

, . ( ) ( ). , , .

:

- .

, , - .

- , . - , - , .

, Const.

Update, .

-. - Set.

, ( -).

Write :

- .

Write Nil , - , Assigned:

If Assigned(Value) Then FSomeObject.Assign(Value).

, , .

- TPersistent, , Delphi. Tobject.

-, TPersistent, . :

, -:

TAnyClass=Class Private

FFId: String; //

Public

Procedure Assign(0bj: TObject);

Property Fid: String Read FFId Write FFId; //

End;

, -:

TPropClass=Class Private

FProp: TAnyClass; // -

Procedure SetPropObj(Obj: TAnyClass);

Public

Constructor Create;





:


: 2016-10-30; !; : 305 |


:

:

, .
==> ...

1820 - | 1587 -


© 2015-2024 lektsii.org - -

: 0.087 .