Sign in Join
Wiki copytemporary

TToggleBox/fi

Deutsch · English · Français · Suomi · Русский · 日本語

TToggleBox on kaksitilainen tekstillä varustettu painike, joka otetaan käyttöön tai poistetaan käytöstä yhdellä klikkauksella. Se löytyy komponenttipaletin Standard-välilehdeltä.

Missä tahansa lähdekoodissa voidaan tarkistaa sen tila onko se aktiivinen tai passiivinen kyselyllä Status := <ToggleBox>.Checked;. Tämä voidaan tarkistaa Checked ominaisuudesta joka on Boolean arvo. Lisäksi myös arvon liittäminen <ToggleBox>.Checked := True;, on mahdollista.

Yksinkertainen esimerkki

pascal
procedure TForm1.btnPaintClick(Sender: TObject);
var
  aColor: TColor;
begin
  aColor:=0;        //Background color of Form1 is set according to the Toggleboxes
  if tbRed.Checked   then aColor:=aColor + $0000FF;
  if tbGreen.Checked then aColor:=aColor + $00FF00;
  if tbBlue.Checked  then aColor:=aColor + $FF0000;
  Color := aColor;  //the change of the property <Formular>.Color causes a redrawing of the form
end;

->

Käytä tapahtumaa

Ero edelliseen esimerkkiin nähden on, että lomaketta ei maalattaisi uudelleen painikkeen klikkauksella, vaan klikkaamalla yhtä togglebox:a.

Edellistä esimerkkiä voidaan muokata poistamalla painike ja sen OnClick-tapahtumakäsittelijä lähdekoodista. Mutta on myös helppoa, luoda uusi esimerkki:

pascal
procedure TForm1.tbRedChange(Sender: TObject); 
var
  aColor: TColor; 
begin
  aColor:=0;        //Background color of Form1 is set according to the Toggleboxes
  if ToggleBox1.Checked then aColor:=aColor + $0000FF;
  if ToggleBox2.Checked then aColor:=aColor + $00FF00;
  if ToggleBox3.Checked then aColor:=aColor + $FF0000;
  Color := aColor;  //the change of the property <Formular>.Color causes a redrawing of the form
end;

Katso myös


From the Free Pascal wiki, page "TToggleBox/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.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.