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/)
-   -   Suche Komponente ähnlich ProgressBar (https://www.delphipraxis.net/178770-suche-komponente-aehnlich-progressbar.html)

himitsu 26. Jan 2014 23:44

AW: Suche Komponente ähnlich ProgressBar
 
Code:
object Gauge1: TGauge
  Left = 32
  Top = 24
  Width = 103
  Height = 25
  BackColor = clRed
  ForeColor = clWhite
  MinValue = -100
  MaxValue = 0
  Progress = -50
  ShowText = False
end
object Gauge2: TGauge
  Left = 134
  Top = 24
  Width = 103
  Height = 25
  ForeColor = clLime
  Progress = 50
  ShowText = False
end
object Timer1: TTimer
  Interval = 10
  OnTimer = Timer1Timer
  Left = 144
  Top = 56
end
object Label1: TLabel
  Left = 248
  Top = 29
  Width = 31
  Height = 13
  Caption = 'Label1'
end
"Markieren"anklicken, Strg+C drücken und dann Strg+V auf der Form.

Und nach einem Doppelklick auf den Timer das Folgende da rein.

Delphi-Quellcode:
  Inc(Position);
  if Position > 100 then
    Position := -100;

  //Gauge1.Progress := Min(Position, 0); // TGauge meckert nicht, wenn Progress außerhalb des Wertebereichs liegt.
  //Gauge2.Progress := Max(Position, 0); // Also nicht wie TProgressBar, welches mit einer Exception reagiert.
  Gauge1.Progress := Position;
  Gauge2.Progress := Position;
  Label1.Caption := IntToStr(Position) + '%';
Man kann auch gerne noch das Nächste in dem Timer mit aufnehmen.

Delphi-Quellcode:
  Gauge1.ShowText := Position < 0;
  Gauge2.ShowText := Position > 0;

[edit]
Nee, Letzteres geht nicht, denn da ist ein Bug in der Komponente, aber Dieser wird ja niemals repariert.

Namenloser 26. Jan 2014 23:48

AW: Suche Komponente ähnlich ProgressBar
 
Also ehrlich gesagt, wenn ich schon keine richtige Komponente schreibe, dann würde ich immer noch eher eine einzige Paintbox verwenden statt mit zwei Gauges rumzuhantieren, um einen Wert darzustellen. Das finde ich irgendwie arg frickelig...

himitsu 27. Jan 2014 00:06

AW: Suche Komponente ähnlich ProgressBar
 
Du packst eine TPaintBox auf deine Form,
schreibst den nötigen Code als Methoden in deine Form, bzw. hängst sie als Events an deine PaintBox (z.B. OnPaint)
und wenn du fertig bist, dann refactorierst du deinen Code und verschiebst alles ein eine Komponente. (OK, wenn diese komponente eh nie wieder braucht, dann erspart man sich das halt)


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

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