Prosty programik z TGauge
Cel

Chcemy uzyskać efekt, aby po kliknięciu na przycisk powiększyć o " 10 " wartość Progress komponentu TGauge. Końcowy efekt :



Potrzebne komponenty :

Nazwa

Klasa

Gauge

TGauge

Button1

TButton



Metoda

1) Wstawiamy komponenty, wypisane w powyższej tabeli i zmieniamy im właściwość name na taką jaka jest w kolumnie "Nazwa"

2) Do obsługi funkcji OnClick przycisku dodajemy poniższy kod:

procedure TForm1.Button1Click(Sender: TObject); var X : Integer; begin X := Gauge.Progress; X := X + 10; Gauge.Progress := X ; end;


3) Uruchamiamy program.

Kod źródłowy

unit Unit1;   interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Gauges, StdCtrls;   type TForm1 = class(TForm) Button1: TButton; Gauge1: TGauge; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;   var Form1: TForm1;   implementation   {$R *.DFM}   procedure TForm1.Button1Click(Sender: TObject); var X : Integer; begin X := Gauge.Progress; X := X + 10; Gauge.Progress := X ; end;   end.


Autorem tekstu jest: Michał Siudziński
http://cpw.net.pl
Materiał dodany przez użytkownika: alphan