T22-23 Components Firing Event

 —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —















Sup­port trans­la­tion: http://amzn.to/1Z7d5oc
 — —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

T22-23 Com­pon­ents Fir­ing Event
unit Unit1;
inter­face
uses
Win­dows, Mes­sages, SysUtils, Vari­ants, Classes, Graph­ics, Con­trols, Forms, Dia­logs,
StdCtrls, Date3;

type TForm1 = class(TForm) But­ton1: TBut­ton;
MyDate: TDate3;
But­ton2: TBut­ton;
pro­ced­ure Button1Click(Sender: TOb­ject);

pro­ced­ure MyDateChange(Sender: TOb­ject); {user declared hand­ler (any name). The Hand­ler is called when “OnChange” event is fired by the MyDate (TDate3) com­pon­ent}
pro­ced­ure Button2Click(Sender: TOb­ject);
private
{Private declar­a­tions}
pub­lic
{Pub­lic declar­a­tions}
end;

var
Form1: TForm1;

imple­ment­a­tion
{$R *.dfm}
pro­ced­ure TForm1.Button1Click(Sender: TOb­ject);
begin
MyDate:= TDate3.Create(self); // con­struct TDate3 object MyDate.OnChange := MyDat­e­Change; {asso­ci­ate hand­ler with the stand­ard “OnChange” event }
ShowMes­sage (IntToStr(today.Day)):
ShowMes­sage (IntToStr(today.Month)):
ShowMes­sage (IntToStr(today.Year)):

end;
pro­ced­ure TForm1.myDateChange(Sender: TOb­ject); {actu­al event hand­ler} begin ShowMessage(‘The day has changed’); end;
pro­ced­ure TForm1.Button2Click(Sender: TOb­ject); begin MyDate.Day:=29; {writes to Day prop­er­ty, using Set­Date() which from inside invokes DoChange() fir­ing the event} end;
end.
unit Date3;
inter­face uses SysUtils, Classes;
TYPE TDate3 = class(TComponent) private FDay, FMonth, FYear : Word; Dummy­Word : word; { — event prop­er­ty —}
{1} FOn­Change : TNo­ti­fyEvent; {sys­tem event type declared as: pro­ced­ure (Sender:TObject) of object;}
pro­tec­ted pro­ced­ure SetDay(newDay: Word);
{3} pro­ced­ure DoChange; dynam­ic; {when invoked fires the event}
pub­lic con­struct­or Create(AOwner: TCom­pon­ent);
pub­lished prop­er­ty Day:word read FDay write Set­Day; prop­er­ty Month:word read FMonth write Dummy­Word; prop­er­ty Year:word read FYear write Dummy­Word;
{2} prop­er­ty OnChange: TNo­ti­fyEvent read FOn­Change write FOn­Change; end;
pro­ced­ure Register;
imple­ment­a­tion
pro­ced­ure Register; begin RegisterComponents(‘Samples’,[TDate3]); end;
con­struct­or TDate3.Create(AOwner: TCom­pon­ent); Begin inher­ited Create(AOwner);
DecodeDate(SysUtils.Date, FYear, FMonth, FDay); end;
{4} pro­ced­ure TDate3.SetDay(newDay: Word); {invokes event – day is changed}
Begin FDay := newDay; {this is the event to be noti­fied}
{4} DoChange; {this fires the event by invok­ing its asso­ci­ated pro­ced­ure

FOnChange(self) which is actu­ally call to the assigned event hand­ler} end;
{3a} pro­ced­ure TDate3.DoChange; Begin if Assigned (FOn­Change) then FOnChange(self); {invokes asso­ci­ated event hand­ler while passing it object which raised the event} end; end.

“ —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

Appoġġ traduzz­joni: http://amzn.to/1Z7d5oc
 — —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

T22-23 Kom­pon­enti Fir­ing Avveni­ment
unità Unit1;
inter­face
użi
Twieqi, Mes­saġġi, SysUtils, Var­janti, Klassiji­et, Grafika, Kon­trol­li, For­moli, Dia­logs,
StdCtrls, Date3;

tip TForm1 = klassi (tform) But­ton1: TBut­ton;
MyDate: TDate3;
But­ton2: TBut­ton;
Proċed­ura But­ton1Click (Sender: TOb­ject);

Proċed­ura MyDat­e­Change (Sender: TOb­ject); {Hand­ler (kwalunk­we isem) utent iddikjar­at. Il Hand­ler huwa mse­j­jaħ meta avveni­ment € € œOn­Changeâ jiġi spar­at tir mill-MyDate (TDate3) kom­pon­ent}
Proċed­ura But­ton2Click (Sender: TOb­ject);
privata
{dikjarazz­jon­iji­et privati}
pubb­liku
{dikjarazz­jon­iji­et pub­bliċi}
tmiem;

var
Form1: TForm1;

impli­mentazz­joni
{$ R * .dfm}
Proċed­ura TForm1.Button1Click (Sender: TOb­ject);
tib­da
MyDate: = TDate3.Create (awto); // Jin­bena TDate3 oġġett MyDate.OnChange: = MyDat­e­Change; {Hand­ler jas­soċ­jaw mal-istand­ard avveni­ment € € œOn­Changeâ}
ShowMes­sage (Int­To­Str (today.Day)):
ShowMes­sage (Int­To­Str (today.Month)):
ShowMes­sage (Int­To­Str (today.Year)):

tmiem;
Proċed­ura TForm1.myDateChange (Sender: TOb­ject); {Hand­ler avveni­ment attwali} jib­da ShowMes­sage (kuljum € ~ Il ikun changedâ € ™); tmiem;
Proċed­ura TForm1.Button2Click (Sender: TOb­ject); jib­dew MyDate.Day:=29; {Jikteb lill-pro­prjetà Jum, bl-użu Set­Date () li minn ġewwa tin­voka DoChange () isparar F’każ} aħħar;
tmiem.
unità Date3;
inter­face użi SysUtils, Klassiji­et;
TIP TDate3 = klassi (TCom­pon­ent) privat FDay, FMonth, FYear: Kel­ma; Dummy­Word: kel­ma; {- Pro­prjetà avveni­ment —}
{1} FOn­Change: TNo­ti­fyEvent; {Sis­tema tip avveni­ment ikun iddikjar­at li: Proċed­ura (Sender: TOb­ject) tal-oġġett;}
Proċed­ura pro­tet­ti Set­Day (Newday: Word);
{3} DoChange proċed­ura; din­amiku; {Meta invokat niri­en l-avveni­ment}
kostrut­tur pubb­liku Oħloq (AOwn­er: TCom­pon­ent);
Jum pro­prjetà ppubb­likati: kel­ma aqra FDay write Set­Day; pro­prjetà Xahar: kel­ma jaqraw FMonth jikt­bu Dummy­Word; Sena pro­prjetà: kel­ma taqra FYear ikteb Dummy­Word;
{2} pro­prjetà OnChange: TNo­ti­fyEvent jaqraw FOn­Change jikt­bu FOn­Change; tmiem;
Reġis­tru proċed­ura;
impli­mentazz­joni
Reġis­tru proċed­ura; tib­da Register­Com­pon­ents (â € ~Samplesâ € ™, [TDate3]); tmiem;
TDate3.Create kostrut­tur (AOwn­er: TCom­pon­ent); Tib­da wiret Oħloq (AOwn­er);
DecodeD­ate (SysUtils.Date, FYear, FMonth, FDay); tmiem;
{4} proċed­ura TDate3.SetDay (Newday: Word); {Tin­voka avveni­ment â € ““jum tin­bidel}
Tin­be­da FDay: = Newday; {Dan huwa l-avveni­ment li jiġu noti­fikati}
{4} DoChange; {Dan il niri­en f’każ bil­li jin­voka proċed­ura assoċ­jat miegħu

FOn­Change (awto) li huwa attwal­ment sejħa biex l assen­jat avveni­ment hand­ler} għan;
{3a} proċed­ura TDate3.DoChange; Tib­da jekk Assen­jat (FOn­Change) imbagħad FOn­Change (awto); {Tin­voka assoċ­jat hand­ler avveni­ment fil­waqt li tgħad­di hi toġġezz­jona li qaj­met l-avveni­ment} aħħar; tmiem.

“ —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

Onder­steun­ing ver­tal­ing: http://amzn.to/1Z7d5oc
 — —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

T22-23 kom­pon­en­te Fir­ing Event
een­heid Unit1;
kop­pel­vlak
gebruike
Win­dows, bood­skappe, SysUtils, Vari­ante, klasse, Graph­ics, Beheer, Vorms, ven­sters,
StdCtrls, Date3;

tik TForm1 = klas (tform) But­ton1: TBut­ton;
MyDate: TDate3;
BUTTON2: TBut­ton;
prosed­ure But­ton1Click (Sender: TOb­ject);

prosed­ure MyDat­e­Change (Sender: TOb­ject); {Gebruiker verk­laar hanteer­der (enige naam). Die hanteer­der is bek­end as wan­neer â € œOn­Changeâ € geval is aangevuur deur die MyDate (TDate3) kom­pon­ent}
prosed­ure But­ton2Click (Sender: TOb­ject);
privaat
{Private verklar­ings}
open­bare
{Open­bare verklar­ings}
einde;

var
Form1: TForm1;

imple­men­ter­ing
{$ R * .dfm}
prosed­ure TForm1.Button1Click (Sender: TOb­ject);
begin
MyDate: = TDate3.Create (self); // Bou TDate3 voor­werp MyDate.OnChange: = MyDat­e­Change; {Mede hanteer­der met die standaard â € œOn­Changeâ € geval}
ShowMes­sage (Int­To­Str (today.Day)):
ShowMes­sage (Int­To­Str (today.Month)):
ShowMes­sage (Int­To­Str (today.Year)):

einde;
prosed­ure TForm1.myDateChange (Sender: TOb­ject); {Werklike event hand­ler} begin ShowMes­sage (â € ~The dag het changedâ € ™); einde;
prosed­ure TForm1.Button2Click (Sender: TOb­ject); begin MyDate.Day:=29; {Skryf aan Dag eiendom, die gebruik van Set­Date () wat van bin­ne roep DoChange () die afvuur van die geval} end;
einde.
een­heid Date3;
kop­pel­vlak gebruik SysUtils, Klasse;
TIPE TDate3 = klas (TCom­pon­ent) private FDay, FMonth, FYear: Word; Dummy­Word: woord; {- Gebeur­t­en­is eiendom —}
{1} FOn­Change: TNo­ti­fyEvent; {Stelsel tipe gebeur­t­en­is verk­laar as: prosed­ure (Sender: TOb­ject) van voor­werp;}
beskerm prosed­ure Set­Day (newDay: Word);
{3} prosed­ure DoChange; din­am­ies; {Toe opger­oep brande die geval}
open­bare kon­struk­t­or Skep (AOwn­er: TCom­pon­ent);
gepub­liseer eiendom Dag: woord gelees FDay skryf Set­Day; eiendom Maand: woord gelees FMonth skryf Dummy­Word; eiendom Jaar: Woord lees FYear skryf Dummy­Word;
{2} eiendom OnChange: TNo­ti­fyEvent lees FOn­Change skryf FOn­Change; einde;
prosed­ure Register;
imple­men­ter­ing
prosed­ure Register; begin Register­Com­pon­ents (â € ~Samplesâ € ™, [TDate3]); einde;
kon­struk­t­or TDate3.Create (AOwn­er: TCom­pon­ent); Begin geërf Skep (AOwn­er);
DecodeD­ate (SysUtils.Date, FYear, FMonth, FDay); einde;
{4} prosed­ure TDate3.SetDay (newDay: Word); {Roep geval â € ““dag ver­ander}
Begin FDay: = newDay; {Dit is die geval in ken­nis gestel word}
{4} DoChange; {Hierdie brande die geleen­theid deur sy ver­wante proses ber­oep

FOn­Change (self) wat eint­lik bel om die opgedra event hand­ler} end;
{3a} prosed­ure TDate3.DoChange; Begin as Opgedra (FOn­Change) dan FOn­Change (self); {Ber­oep geas­sosieer event hand­ler ter­wyl jy dit beswaar wat die geval opgewek} end; einde.

“ —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

përk­thim Sup­port: http://amzn.to/1Z7d5oc
 — —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  —  — —

T22-23 Com­pon­ents Qitjes Event
Njësia Unit1;
ndër­faqe
për­dor
Win­dows, Mes­sages, SysUtils, Vari­antet, Klasat, Graph­ics, Kon­trol­let, Forms, Dia­lo­gët,
StdCtrls, Date3;