Autor Beitrag
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 30.03.11 20:28 
Hallo,

unter Windows XP hatte ich ein Programm geschrieben, das sehr viel mit Extended-Zahlen rechnet. Diese Zahlen wurden mit FloatToStr() richtig dargestellt, also z.B. in der Form "1.234,56"
Auch nach einem Umstieg auf Windows 7 32 bit funktionierte alles richtig. Das identische Programm aber auf Windows 7 64 bit gestartet stellt die Zahlen, obwohl in der Systemsteuerung alles korrekt eingestellt ist, in der amerikanischen Form dar, also "1,234.56"
Wie kann ich mittels Delphi die Darstellung der Dezimalzahlen wieder für die Funktion FloatToStr auf das deutsche Format umstellen?
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mi 30.03.11 20:35 
Hallo,

die Funktion FloatToStr akzeptiert noch einen zweiten Parameter vom Typ TFormatSettings.

Hier ein Beispiel, wie du die vom Benutzer eingestellten Werte abrufst:
Delphi-Referenz auf About.com:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var 
  s: string;
  fs : TFormatSettings; 

GetLocaleFormatSettings(0, fs);
fs.DecimalSeparator := 'D';
fs.ThousandSeparator := 'T';

s := FloatToStr(100 000 * PI, fs);

//s == '3T141T592D65'

Den Teil, in dem das TFormatSettings-Objekt angepasst wird, kannst du ja weglassen.

Es kann aber natürlich auch sein, dass die FloatToStr-Methode intern genau so etwas macht, wenn der zweite Parameter weggelassen wird. Dann hilft dieser Code wohl auch nichts mehr.

Grüße,
Yogu

Moderiert von user profile iconNarses: Delphi-Tag repariert.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 30.03.11 20:44 
Moin!

user profile iconfeivel3333 hat folgendes geschrieben Zum zitierten Posting springen:
Das identische Programm aber auf Windows 7 64 bit gestartet stellt die Zahlen, obwohl in der Systemsteuerung alles korrekt eingestellt ist, in der amerikanischen Form dar,
Das hört sich doch glatt so an, als ob das auch auf diesen Bug in Windows zurückzuführen wäre. :idea: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
feivel3333 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Do 31.03.11 22:32 
Narses, du bist Klasse!
Wir haben es ausprobiert, und siehe da: Das Problem ist jetzt aus der Welt! Tausend Dank, nein, noch mehr.
Ohne diese Info würde ich vermutlich noch immer suchen und suchen und suchen...

Gruß, Schabi