Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Boolean Indikator (https://www.delphipraxis.net/168693-boolean-indikator.html)

Popov 4. Jun 2012 18:45

AW: Boolean Indikator
 
Zitat:

Zitat von shmia (Beitrag 1169490)
Sonstige Ideen?

Jep, mit Trick 17.

Delphi-Quellcode:
procedure TForm1.CheckListBox1ClickCheck(Sender: TObject);
begin
  CheckListBox1.Checked[CheckListBox1.ItemIndex] :=
    not CheckListBox1.Checked[CheckListBox1.ItemIndex]; // Trick 17
end;

procedure TForm1.Button1Click(Sender: TObject); // Beispiel
var
  i: Integer;
begin           // Beispiel Checks setzten
  for i := 0 to CheckListBox1.Count - 1 do
    CheckListBox1.Checked[i] := Random(2) = 0;
end;
Wenn das Item ausgecheckt wird, dann checken wir es doch wieder ;)

//Edit:

Eine kleine Erweiterung, sie ersetzt das Check-Zeichen durch einen Smiley

Delphi-Quellcode:
procedure TForm1.CheckListBox1DrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
  R: TRect;
  CLB: TCheckListBox;
  CW: Integer;
  FN: String;
  Ch: Char;
  TopDifTxt: Integer; // Gleicht die Höhendifferenz aus
begin
  CLB := (Control as TCheckListBox);
  R := Rect;
  CW := CLB.ClientWidth - (R.Right - R.Left);
  R.Left := R.Left - CW;
  R.Right := R.Left + CW;

  TopDifTxt := (CLB.ItemHeight div 2) - (CLB.Canvas.TextHeight(CLB.Items[Index]) div 2);

  //Ausgabe normaler Text
  CLB.Canvas.TextRect(Rect, Rect.Left, Rect.Top + TopDifTxt, CLB.Items[Index]);

  //Checkersatz
  CLB.Canvas.Font.Name := 'Wingdings';
  if CLB.Checked[Index] then Ch := 'J' else Ch := #32;
  CLB.Canvas.TextRect(R, R.Left + 2, Rect.Top + TopDifTxt, Ch);
end;

Furtbichler 5. Jun 2012 06:31

AW: Boolean Indikator
 
Mit Bordmitteln, keine Checkbox:
Font: Windings
Zeichen #251, #252 oder #253, #254
Fontcolor: Rot (251,253) bzw. grün (252,254)

Fertig.


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:55 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz