Delphi-PRAXiS

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 TUpDown hat eine Macke ? (https://www.delphipraxis.net/97843-tupdown-hat-eine-macke.html)

turboPASCAL 17. Aug 2007 08:37


TUpDown hat eine Macke ?
 
Testcode:

Delphi-Quellcode:
// ...

implementation

{$R *.dfm}

var n: SmallInt = 0;

procedure TForm1.UpDown1Changing(Sender: TObject;
  var AllowChange: Boolean);
begin
   StaticText1.Caption := inttostr( UpDown1.Position ); // <--<<
end;

procedure TForm1.UpDown1ChangingEx(Sender: TObject;
  var AllowChange: Boolean; NewValue: Smallint;
  Direction: TUpDownDirection);

begin
  case Direction of
    updUp  : if n+UpDown1.Increment <= UpDown1.Max then inc(n, UpDown1.Increment);
    updDown : if n-UpDown1.Increment >= UpDown1.Min then dec(n, UpDown1.Increment);
  end;

  label1.Caption := inttostr( n );
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  n := UpDown1.Position;
end;

end.
Also UpDown in Normalhandling hinkt immer einen Positionswert gegenüber den Selbstbau
im UpDownChangingEx hinterher. Der Fehler, wenn es denn einer ist, fiel mir bei Delphi 6
und Delphi 2005 PE auf.

Ist das jmd aufgefallen, mach ich was falsch oder stecht da ein Denkfehler drin ?

( Sorry drei Fragen auf einmal ? ;) )

jim_raynor 17. Aug 2007 08:52

Re: TUpDown hat eine Macke ?
 
OnChanging deutet auch darauf hin, dass der Wert geändert werden soll. Und der AllowChange-Parameter schreit gerade dazu danach, dass die Änderung noch nicht statt gefunden hat ;). Naja kenne die Komponente nicht, aber es gibt bestimmt noch ein OnChange Ereigniss oder so, dass dann tatsächlich nach der Änderung ausgelöst wird.

turboPASCAL 17. Aug 2007 09:41

Re: TUpDown hat eine Macke ?
 
Liste der Anhänge anzeigen (Anzahl: 1)
Guck dir mal das Beispiel an, man sollte doch meinen das man den richtigen Wert bekommt.

Hawkeye219 17. Aug 2007 10:11

Re: TUpDown hat eine Macke ?
 
Hallo,

Zitat:

Zitat von jim_raynor
[...]aber es gibt bestimmt noch ein OnChange Ereigniss oder so, dass dann tatsächlich nach der Änderung ausgelöst wird.

Das Ereignis heißt in diesem Fall OnClick.

Gruß Hawkeye

turboPASCAL 17. Aug 2007 11:48

Re: TUpDown hat eine Macke ?
 
Achso, danke. Manchmal isses schon soweit... :wall:


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:14 Uhr.

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 by Thomas Breitkreuz