T22-23 Components Firing Event

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

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

Support translation: http://amzn.to/1Z7d5oc
——————————————————————————————————————————————————

T22-23 Components Firing Event
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Date3;

type TForm1 = class(TForm) Button1: TButton;
MyDate: TDate3;
Button2: TButton;
procedure Button1Click(Sender: TObject);

procedure MyDateChange(Sender: TObject); {user declared handler (any name). The Handler is called when “OnChange” event is fired by the MyDate (TDate3) component}
procedure Button2Click(Sender: TObject);
private
{Private declarations}
public
{Public declarations}
end;

var
Form1: TForm1;

implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
MyDate:= TDate3.Create(self); // construct TDate3 object MyDate.OnChange := MyDateChange; {associate handler with the standard “OnChange” event }
ShowMessage (IntToStr(today.Day)):
ShowMessage (IntToStr(today.Month)):
ShowMessage (IntToStr(today.Year)):

end;
procedure TForm1.myDateChange(Sender: TObject); {actual event handler} begin ShowMessage(‘The day has changed’); end;
procedure TForm1.Button2Click(Sender: TObject); begin MyDate.Day:=29; {writes to Day property, using SetDate() which from inside invokes DoChange() firing the event} end;
end.
unit Date3;
interface uses SysUtils, Classes;
TYPE TDate3 = class(TComponent) private FDay, FMonth, FYear : Word; DummyWord : word; { — event property —}
{1} FOnChange : TNotifyEvent; {system event type declared as: procedure (Sender:TObject) of object;}
protected procedure SetDay(newDay: Word);
{3} procedure DoChange; dynamic; {when invoked fires the event}
public constructor Create(AOwner: TComponent);
published property Day:word read FDay write SetDay; property Month:word read FMonth write DummyWord; property Year:word read FYear write DummyWord;
{2} property OnChange: TNotifyEvent read FOnChange write FOnChange; end;
procedure Register;
implementation
procedure Register; begin RegisterComponents(‘Samples’,[TDate3]); end;
constructor TDate3.Create(AOwner: TComponent); Begin inherited Create(AOwner);
DecodeDate(SysUtils.Date, FYear, FMonth, FDay); end;
{4} procedure TDate3.SetDay(newDay: Word); {invokes event – day is changed}
Begin FDay := newDay; {this is the event to be notified}
{4} DoChange; {this fires the event by invoking its associated procedure

FOnChange(self) which is actually call to the assigned event handler} end;
{3a} procedure TDate3.DoChange; Begin if Assigned (FOnChange) then FOnChange(self); {invokes associated event handler while passing it object which raised the event} end; end.

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

Appoġġ traduzzjoni: http://amzn.to/1Z7d5oc
——————————————————————————————————————————————————

T22-23 Komponenti Firing Avveniment
unità Unit1;
interface
użi
Twieqi, Messaġġi, SysUtils, Varjanti, Klassijiet, Grafika, Kontrolli, Formoli, Dialogs,
StdCtrls, Date3;

tip TForm1 = klassi (tform) Button1: TButton;
MyDate: TDate3;
Button2: TButton;
Proċedura Button1Click (Sender: TObject);

Proċedura MyDateChange (Sender: TObject); {Handler (kwalunkwe isem) utent iddikjarat. Il Handler huwa msejjaħ meta avveniment € € œOnChangeâ jiġi sparat tir mill-MyDate (TDate3) komponent}
Proċedura Button2Click (Sender: TObject);
privata
{dikjarazzjonijiet privati}
pubbliku
{dikjarazzjonijiet pubbliċi}
tmiem;

var
Form1: TForm1;

implimentazzjoni
{$ R * .dfm}
Proċedura TForm1.Button1Click (Sender: TObject);
tibda
MyDate: = TDate3.Create (awto); // Jinbena TDate3 oġġett MyDate.OnChange: = MyDateChange; {Handler jassoċjaw mal-istandard avveniment € € œOnChangeâ}
ShowMessage (IntToStr (today.Day)):
ShowMessage (IntToStr (today.Month)):
ShowMessage (IntToStr (today.Year)):

tmiem;
Proċedura TForm1.myDateChange (Sender: TObject); {Handler avveniment attwali} jibda ShowMessage (kuljum € ~ Il ikun changedâ € ™); tmiem;
Proċedura TForm1.Button2Click (Sender: TObject); jibdew MyDate.Day:=29; {Jikteb lill-proprjetà Jum, bl-użu SetDate () li minn ġewwa tinvoka DoChange () isparar F’każ} aħħar;
tmiem.
unità Date3;
interface użi SysUtils, Klassijiet;
TIP TDate3 = klassi (TComponent) privat FDay, FMonth, FYear: Kelma; DummyWord: kelma; {- Proprjetà avveniment —}
{1} FOnChange: TNotifyEvent; {Sistema tip avveniment ikun iddikjarat li: Proċedura (Sender: TObject) tal-oġġett;}
Proċedura protetti SetDay (Newday: Word);
{3} DoChange proċedura; dinamiku; {Meta invokat nirien l-avveniment}
kostruttur pubbliku Oħloq (AOwner: TComponent);
Jum proprjetà ppubblikati: kelma aqra FDay write SetDay; proprjetà Xahar: kelma jaqraw FMonth jiktbu DummyWord; Sena proprjetà: kelma taqra FYear ikteb DummyWord;
{2} proprjetà OnChange: TNotifyEvent jaqraw FOnChange jiktbu FOnChange; tmiem;
Reġistru proċedura;
implimentazzjoni
Reġistru proċedura; tibda RegisterComponents (â € ~Samplesâ € ™, [TDate3]); tmiem;
TDate3.Create kostruttur (AOwner: TComponent); Tibda wiret Oħloq (AOwner);
DecodeDate (SysUtils.Date, FYear, FMonth, FDay); tmiem;
{4} proċedura TDate3.SetDay (Newday: Word); {Tinvoka avveniment â € “”jum tinbidel}
Tinbeda FDay: = Newday; {Dan huwa l-avveniment li jiġu notifikati}
{4} DoChange; {Dan il nirien f’każ billi jinvoka proċedura assoċjat miegħu

FOnChange (awto) li huwa attwalment sejħa biex l assenjat avveniment handler} għan;
{3a} proċedura TDate3.DoChange; Tibda jekk Assenjat (FOnChange) imbagħad FOnChange (awto); {Tinvoka assoċjat handler avveniment filwaqt li tgħaddi hi toġġezzjona li qajmet l-avveniment} aħħar; tmiem.

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

Ondersteuning vertaling: http://amzn.to/1Z7d5oc
——————————————————————————————————————————————————

T22-23 komponente Firing Event
eenheid Unit1;
koppelvlak
gebruike
Windows, boodskappe, SysUtils, Variante, klasse, Graphics, Beheer, Vorms, vensters,
StdCtrls, Date3;

tik TForm1 = klas (tform) Button1: TButton;
MyDate: TDate3;
BUTTON2: TButton;
prosedure Button1Click (Sender: TObject);

prosedure MyDateChange (Sender: TObject); {Gebruiker verklaar hanteerder (enige naam). Die hanteerder is bekend as wanneer â € œOnChangeâ € geval is aangevuur deur die MyDate (TDate3) komponent}
prosedure Button2Click (Sender: TObject);
privaat
{Private verklarings}
openbare
{Openbare verklarings}
einde;

var
Form1: TForm1;

implementering
{$ R * .dfm}
prosedure TForm1.Button1Click (Sender: TObject);
begin
MyDate: = TDate3.Create (self); // Bou TDate3 voorwerp MyDate.OnChange: = MyDateChange; {Mede hanteerder met die standaard â € œOnChangeâ € geval}
ShowMessage (IntToStr (today.Day)):
ShowMessage (IntToStr (today.Month)):
ShowMessage (IntToStr (today.Year)):

einde;
prosedure TForm1.myDateChange (Sender: TObject); {Werklike event handler} begin ShowMessage (â € ~The dag het changedâ € ™); einde;
prosedure TForm1.Button2Click (Sender: TObject); begin MyDate.Day:=29; {Skryf aan Dag eiendom, die gebruik van SetDate () wat van binne roep DoChange () die afvuur van die geval} end;
einde.
eenheid Date3;
koppelvlak gebruik SysUtils, Klasse;
TIPE TDate3 = klas (TComponent) private FDay, FMonth, FYear: Word; DummyWord: woord; {- Gebeurtenis eiendom —}
{1} FOnChange: TNotifyEvent; {Stelsel tipe gebeurtenis verklaar as: prosedure (Sender: TObject) van voorwerp;}
beskerm prosedure SetDay (newDay: Word);
{3} prosedure DoChange; dinamies; {Toe opgeroep brande die geval}
openbare konstruktor Skep (AOwner: TComponent);
gepubliseer eiendom Dag: woord gelees FDay skryf SetDay; eiendom Maand: woord gelees FMonth skryf DummyWord; eiendom Jaar: Woord lees FYear skryf DummyWord;
{2} eiendom OnChange: TNotifyEvent lees FOnChange skryf FOnChange; einde;
prosedure Register;
implementering
prosedure Register; begin RegisterComponents (â € ~Samplesâ € ™, [TDate3]); einde;
konstruktor TDate3.Create (AOwner: TComponent); Begin geërf Skep (AOwner);
DecodeDate (SysUtils.Date, FYear, FMonth, FDay); einde;
{4} prosedure TDate3.SetDay (newDay: Word); {Roep geval â € “”dag verander}
Begin FDay: = newDay; {Dit is die geval in kennis gestel word}
{4} DoChange; {Hierdie brande die geleentheid deur sy verwante proses beroep

FOnChange (self) wat eintlik bel om die opgedra event handler} end;
{3a} prosedure TDate3.DoChange; Begin as Opgedra (FOnChange) dan FOnChange (self); {Beroep geassosieer event handler terwyl jy dit beswaar wat die geval opgewek} end; einde.

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

përkthim Support: http://amzn.to/1Z7d5oc
——————————————————————————————————————————————————

T22-23 Components Qitjes Event
Njësia Unit1;
ndërfaqe
përdor
Windows, Messages, SysUtils, Variantet, Klasat, Graphics, Kontrollet, Forms, Dialogët,
StdCtrls, Date3;

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather