COM ActiveX   3GL   4GL

- : , . Delphi. , , . , , , Delphi.

. , (, ). 2.8.

2.8
TMyButton = class(TButton)
private
{ Private declarations }
FMyCount: Integer;
FStirngOfText: String;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property MyCount: Integer read FMyCount write FMyCount;
property StringOfText: String read FStringOfText write FStringOfText;
end;


TMyButton : integer, string. , . ( published) .


F (, field), (, type).


, , . Align, Borderstyle, color . , , :
TMyEnumType = (eFirst, eSecond, eThird);
, , . TMyButton 2.9.

2.9
type
TMyEnumType = (eFirst, eSecond, eThird);
type
TMyButton = class(TButton)
private
{ Private declarations }
FMyEnum: TMyEnumType;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property MyEnumProp: TMyEnumType read FMyEnum write FMyEnum;
end;


, , MyEnumProp, , : eFirst, eSecond eThird (. 2.15).

 2.15
. 2.15. MyEnumProp TMyButton
-
Object Pascal, Delphi . set, , , .
- :
TMySetTypeFirst = (poFirst, poSecond, poThird); TMySetType = set of TMySetTypeFirst;
TMySetTypeFirst, , - TMySetType.
- TMyButton 2.10.

2.10.
type
TMyEnumType = (eFirst, eSecond, eThird); TMySetTypeFirst = (poFirst, poSecond, poThird); TMySetType = set of TMySetTypeFirst;
type
TMyButton = class(TButton)
private
{ Private declarations } FMyEnum: TMyEnumType; FMyOptions: TMySetType;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property MyEnumProp: TMyEnumType read FMyEnum write FMyEnum;
property MyOptions: TMySetType read FMyOptions write FMyOptions;
end;

, TMyButton.
, - , . 2.16.

 2.16
. 2.16. - MyOptions TMyButton
-
-. - Delphi. , - , . , - TPersistent. , - . - TMyButton.
, TPersistent ( 2.11).

2.11
type
TMyObject = class (TPersistent}
private
{ Private declarations }
FPropertyl: Real;
FProperty2: Char;
protected
{ Protected declarations }
public
{ Public declarations }
procedure Assign (Source: TPersistent);
published
{ Published declarations }
property Propertyl: Real read FPropertyl write FPropertyl;
property Property2: Char read FProperty2 write FProperty2;
end;


TPersistent, . TMyObject, - Propertyl Property2. , Assign. TMyButton. 2.12, TMyButton -.

2.12
type
TMyButton = class (TButton)
private
{ Private declarations }
FMyObject: TMyObject;
procedure SetMyObject (Value: TMyObject);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property MyObject: TMyObject read FMyObject write SetMyObject;
end;


, .
TMyButton, , TMyButton, TMyObject. setMyObject, TMyObject. , , Assign TMyObject. 2.13. , , .

2.13
type
TMyObject = class (TPersistent)
private
{ Private declarations }
FPropertyl: Real;
FProperty2: Char;
protected
{ Protected declarations }
public
{ Public declarations }
procedure Assign (Source: TPersistent);
published
{ Published declarations }
property Propertyl: Real read FPropertyl write FPropertyl;
property Property2: Char read FProperty2 write FProperty2;
end;

type
TMyButton = class (TButton)
private
{ Private declarations }
FMyObject: TMyObject;
procedure SetMyObject (Value: TMyObject);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property MyObject: TMyObject read FMyObject write SetMyObject;
end;

procedure Register;
implementation
procedure TMyButton.SetMyObject (Value: TMyObject);
begin
if Assigned (Value) then FMyObject.Assign (Value);
end;

constructor TMyButton.Create (AOwner; TComponent);
begin
inherited Create (AOwner);
FMyOb j ect:=TMyObject.Create;
end;

destructor TMybutton.Destroy;
begin
FMyObject.Free;
inherited Destroy;
end;

procedure TMyObject.Assign (Source: TPersistent);
begin
if Source is TMyObject then
begin
FPropertyl:=TmyObject (Source).Property1;
FProperty2:=TmyObject (Source).Property2;
inherited Assign (Source);
end;
end;


TMyObject.Assign. , TMyObject. , (Source) FPropertyl FProperty2 TMyButton. TMyButton, - TMyObject. , . 2.17.

 2.17
. 2.17. - MyObject TMyButton
-
, Object Pascal. . . Lines, TDBGrid. columns . . , ( ). Tweek, : Month Number. Month , 1 12. Number - , , .
, 2.14 TWeek.

2.14
unit Week; interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TWeek = class(TComponent)
private
{ Private declarations }
function GetMonthName (const AIndex: Integer): String;
function GetMonthNumber (const AMonthNarae: String): Integer;
protected
{ Protected declarations }
public
{ Public declarations }
property MonthName[const AIndex: Integer]: String read GetMonthName; default;
property MonthNumber[const AMonthName: String]: Integer read GetMonthNumber;
published
{ Published declarations }
end;

procedure Register;
implementation
const
MonthNames: array[1..12] of String[8]= ('','','','','', '','','','', '', '','');

function TWeek.GetMonthName(const AIndex: Integer): String;
begin
if (AIndex<=0) or (AIndex>12) then
raise Exception.Create(' 1 12')
else Result:- MonthNames[AIndex];
end;

function TWeek.GetMonthNumber(const AMonthName: String): Integer;
var i:integer;
begin
Result:=0;
for i:=l to 12 do begin
if Uppercase(AMonthName)=UpperCase(MonthNames[i]) then
Result:=1;
end;
end;
procedure Register;
begin
RegisterComponents('Samples', [TWeek]);
end;
end.


. , Array . MontnName Aindex, MonthNumber - AMonthName. . . Array , - . , .
GetMonthName , , 1 12, . , , raise ( 2).
, GetMonthNumber 1 12, , . , MonthNames, .
, TWeek weeki, ShowMessage (Weekl.MonthName[5]}; .

, Delphi . , - . , Color , . , , , Caption, Height, Enabled. , " ", . . , width, - .
. .
TPropertyEditor. . , TColorProperty , TlntegerProperty , integer . . 2.15 , TPropertyEditor.

2.15
TPropertyEditor = class
private
FDesigner: TFormDesigner;
FPropList: PInstPropList;
FPropCount: Integer;
constructor Create(ADesigner: TFormDesigner; APropCount: Integer);
function GetPrivateDirectory: string;
procedure SetPropEntry(Index: Integer; AInstance: TComponent;
APropInfo: PPropInfo};
protected
function GetPropInf: PPropInfo;
function GetFloatValue: Extended;
function GetFloatValueAt(Index: Integer): Extended;
function GetMethodValue: TMethod;
function GetMethodValueAt(Index: Integer): TMethod;
function GetOrdValue: Longint;
function GetOrdValueAt(Index: Integer): Longint;
function GetStrValue: string;
function GetStrValueAt(Index: Integer): string;
procedure Modified;
procedure SetFloatValue(Value: Extended);
procedure SetMethodValue(const Value: TMethod);
procedure SetOrdValue(Value: Longint);
procedure SetStrValue(const Value: string);
public
destructor Destroy; override;
procedure Activate; virtual;
function AllEqual: Boolean; virtual;
procedure Edit; virtual;
function GetAttributes: TPropertyAttributes; virtual;
function GetComponent(Index: Integer): TComponent;
function GetEditLimit: Integer; virtual;
function GetName: string; virtual;
procedure GetProperties(Proc: TGetPropEditProc);virtual;
function GetPropType: PTypelnfo;
function GetValue: string; virtual;
procedure GetValues(Proc: TGetStrProc); virtual;
procedure Initialize; virtual;
procedure SetValue(const Value: string); virtual;
property Designer: TFormDesigner read FDesigner;
property PrivateDirectory: string read GetPrivateDirectory;
property PropCount: Integer read FPropCount;
property Value: string read GetValue write SetValue;
end;


, , .
Activate , .
AllEqual .
Edit (...) . , , Font.
GetAttributes TProperyAttributes, , .
Getcomponent ( index), , .
GetEditLimit , .
GetName . , , .
GetPropType .
Getvalue .
initialize () .
setvalue .
, - TPropertyEditor. , .
Hint, . . Hint . 2.16 , THintProperty. - TStringProperty.

2.16
THintProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue : String; override;
procedure Edit; override;
end;

function THintProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog, paReadOnly];
end;

function THintProperty.GetValue : string;
var i : Byte;
begin
result:=inherited GetValue;
for i:=l to Byte(resultt0]) do
if result[i]<#32 then result[i]: = '>';
end;

procedure THintProperty.Edit; var
HintEditDlg : TStrEditDlg; s : string;
begin
HintEditDlg:=TStrEditDlg.Create(Application);
with HintEditDlg do
try
Memo.MaxLength := 254;
s:=GetStrValue+#0;
Memo.Lines.SetText(@s[1]);
UpdateStatus(nil);
ActiveControl := Memo;
If ShowModal = mrOk then begin
s:=StrPas(Memo.Lines.GetText);
if s[0]>#2 then Dec(Byte(s[0]),2);
SetStrValue(s);
end; finally
Free;
end;
end;


:
- GetAttributes paDialog ( (...) ) paReadOnly ( , );
- Getvalue (#10) - (#13) (>).
, Edit .
Register. implementation ( 2.17).

2.17.
procedure Register;
begin
RegisterPropertyEditor (Typelnf(String), TControl, 'Hint', THintProperty);
end;


, . , RegisterPropertyEditor. ( - string), - . . .
Delphi, :
1. Options/Install Components (/ ).
2. Add.
3. .
, - . showHint true (...) Hint. Hint.
Default NoDefault
, . , , . , :
FMyProperty := 10;
, Myproperty 10.
Default NoDefault . ,
property MyCount: Integer read FMyCount write FmyCount Default 0;
MyCount. Default : , , MyCount , , .


Default , , .

NoDefault Default. Default -. NoDefault:
TSecondComponent = class (TMyButton)
published
property MyCount NoDefault 0;


. , .
, - , , , .
"" - . - -. , - , . . - .
, Onclick. , , (event-dispatching methods). , , . (protected). , Onciick click ( 2.18).

2.18
TControl = class (TComponent)
private
FOnClick: TNotifyEvent;
protected
procedure Click; dynamic;
property OnClick: TNotifyEvent read FOnClick write FOnClick;
end;

implementation
procedure TControl.Click;
begin
if Assigned (FOnClick) then FOnClick (Self);
end;

2.19
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Canvas.TextOut(X, Y, '('+IntToStr(X)+', '+IntToStr(Y)+')');
end;


 2.18
. 2.18. OnMouseDown

. , VCL Delphi. , , 30 . , Timer, System Delphi. , , . 2.20.

2.20
unit halfmin; interface
uses
Windows, Messages, SysUtils, Classes,Graphics, Controls, Forms,
Dialogs,
ExtCtrls;
type
TTimeEvent = procedure (Sender: TObj'ect; TheTime: TDateTime) of object;
THalfMinute = class (TComponent)
private
FTimer: TTimer;
FOnHalfMinute: TTimeEvent;
FOldSecond, FSecond: Word;
procedure FTimerTimer (Sender: TObject);
protected
procedure DoHalfMinute (TheTime: TDateTime); dynamic;
public
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
published
property OnHalfMinute: TTimeEvent read FOnHalfMinute write FOnHalf-Minute;
end;

implementation
constructor THalfMinute.Create (AOwner: TComponent);
begin
inherited Create (AOwner);
if not (csDesigning in ComponentState) then begin
FTimer:=TTimer.Create(self);
FTimer.Enabled:=True;
FTimer.Interval:=500;
FTimer.OnTimer:=FTimerTimer;
end;
end;

destructor THalfMinute.Destroy;
begin
FTimer.Free;
inherited Destroy;
end;

procedure THalfMinute.FTimerTimer (Sender: TObject);
var
DT: TDateTime;
Temp: Word;
begin
DT:=Now;
FOldSecond:=FSecond;
DecodeTime (DT,Temp,Temp,FSecond,Temp);
if FSecond <> FOldSecond then
if ((FSecond=30) or (FSecond=0)) then
DoHalfMinute (DT);
end;

procedure THalfMinute.DoHalfMinute(TheTime: TDateTime);
begin
if Assigned (FOnHalfMinute) then
FOnHalfMinute (Self, TheTime);
end;
end.


ThalfMinute, interface- :
procedure Register;
:
procedure Register;
begin
RegisterComponents('Samples', [THalfMinute]);
end;

. TEdit. onHaifMinute ( 2.21).

2.21
procedure TForml.HalfMinutelHalfMinute(Sender: TObject; TheTime: TDateTime);
begin
Editl.Text: = (' '+TimeToStr(TheTime)) ; Editl. Refresh;
end;


Editl 30 .

- . , .
-, , , . . . -, . , -, , .
, private, public protected. , , , , , . . 2.10 .
2.10.



Private

, -.

Protected

, -

Public

, . , , . .

Published

,


Delphi
.
Delphi -. , :
1. Options/Install Components (/ ).
2. Add.
3. (, ).
.
, . interface :
procedure Register;
implementation , :
procedure Register;
begin
RegisterComponent ('Samples', [TMyComponent]);
end;

, TMyComponent samples .
, . . Image Editor, Delphi. .
24x24 . DCR. - , - . , TMyButton TMYBUTTON.DCR. , . , .

  COM ActiveX   3GL   4GL

, , Class - - , , .
{DATA}




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution