TTimer/fi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TTimer/fi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **TTimer**  on komponentti, joka Se löytyy [[Component Palette/fi|komponenttipaletin]] [[Standard tab/fi|Standard-välilehdeltä]]. Se tuo ajastimen, jonka tarkkuus voidaan esittää millisekuntteina. Se perii suurimman osan ominaisuuksistaan [[doc:lcl/customtimer/tcustomtimer.html|TCustomTimer]]:ltä. | |
| 2 | + | ||
| 3 | + | ## Lähtölaskentaesimerkki. | |
| 4 | + | ||
| 5 | + | - Pudota [[TLabel/fi|label]], [[TShape/fi|shape]] ja timer komponentit [[TForm/fi|päälomakkeelle (TForm)]] | |
| 6 | + | - Kaksoisklikkaa tätä Timer1-komponenttia lomakkeella (oletuskäsittelijä: OnTimer luodaan Timer1:lle, lähdekoodieditori avautuu). | |
| 7 | + | - Lisää seuraava [[Source code/fi|lähdekoodi]] tapahtumakäsittelijään: | |
| 8 | + | ||
| 9 | + | ``` pascal | |
| 10 | + | procedure TForm1.Timer1Timer(Sender: TObject); | |
| 11 | + | begin | |
| 12 | + | Label1.Caption := Format('%d sec',[start]); | |
| 13 | + | Dec(start); | |
| 14 | + | if (start < 5) then Shape1.Brush.Color:=clYellow; | |
| 15 | + | if (start < 0) then begin | |
| 16 | + | Timer1.Enabled := False; | |
| 17 | + | Shape1.Brush.Color:=clGreen; | |
| 18 | + | Label1.Caption := 'Finished!'; | |
| 19 | + | end; | |
| 20 | + | end; | |
| 21 | + | ``` | |
| 22 | + | ||
| 23 | + | - Luo lomakkeen Form1 OnCreate-tapahtumakäsittelijä (siirry komponenttimuokkaimen tapahtuman OnCreate-kohtaan ja klikkaa painiketta \[...\]). | |
| 24 | + | - Täydennä lähdekoodi seuraavasti:: | |
| 25 | + | ||
| 26 | + | ``` pascal | |
| 27 | + | ||
| 28 | + | procedure TForm1.FormCreate(Sender: TObject); | |
| 29 | + | begin | |
| 30 | + | Caption := 'Countdown calculation'; | |
| 31 | + | Timer1.Interval := 1000; | |
| 32 | + | Timer1.Enabled := True; | |
| 33 | + | Label1.Caption := ''; | |
| 34 | + | Shape1.Shape := stCircle; | |
| 35 | + | Shape1.Brush.Color:=clRed; | |
| 36 | + | start := 20; | |
| 37 | + | end; | |
| 38 | + | ``` | |
| 39 | + | ||
| 40 | + | - Siirry lähdekoodieditorissa [[Class/fi|luokan (Class)]] *TForm1* [[Private/fi|private]] osioon. | |
| 41 | + | - Lisää sinne koodi: **`start: integer;`** | |
| 42 | + | - Käynnistä [[Program/fi|program]] (painamalla näppäintä `F9`) | |
| 43 | + | ||
| 44 | + | ## Katso myös | |
| 45 | + | ||
| 46 | + | - [[doc:lcl/extctrls/ttimer.html|TTimer doc]] | |
| 47 | + | - [[TIdleTimer/fi|TIdleTimer]] | |
| 48 | + | ||
| 49 | + | --- | |
| 50 | + | *From the Free Pascal wiki, page "TTimer/fi", as it stood on 2019-11-09 after a change by Djzepi, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
