Einzelnen Beitrag anzeigen

Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#24

AW: FormatSettings for Dummies

  Alt 13. Apr 2016, 11:54
Dein Problem liegt darin, dass du annimmst,
TFormatSettings.ShortTimeFormat und LongTimeFormat hätten etwas mit dem ab Windows 7 einstellbaren "Short time" und "Long time" zu tun, was aber nicht der Fall ist.
Öhm ... diese Relation würde ich aber auch implizieren ... nein besser: erwarten!

So bekommt man das Gewünschte:
Delphi-Quellcode:
procedure TForm1.PresentData;
var
  lShortTimeFmt: string;
  lLongTimeFmt : string;
begin
  Label1.Caption := FormatDateTime( FormatSettings.ShortDateFormat, Now ) + ' (' + FormatSettings.ShortDateFormat + ')';

  lShortTimeFmt := GetLocaleStr( GetThreadLocale, LOCALE_SSHORTTIME, FormatSettings.ShortDateFormat );
  Label2.Caption := FormatDateTime( lShortTimeFmt, Now );

  // Geht erst ab Windows 7!
  lLongTimeFmt := GetLocaleStr( GetThreadLocale, LOCALE_STIMEFORMAT, FormatSettings.LongTimeFormat );
  Label3.Caption := FormatDateTime( lLongTimeFmt, Now );
end;
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat