DelphiBasics
TFormatSettings
Type
A record for holding locale values for thread-safe functions SysUtils unit
  type TFormatSettings = record
             CurrencyFormat : Byte;
              NegCurrFormat : Byte;
          ThousandSeparator : Char;
           DecimalSeparator : Char;
           CurrencyDecimals : Byte;
              DateSeparator : Char;
              TimeSeparator : Char;
              ListSeparator : Char;
             CurrencyString : string;
            ShortDateFormat : string;
             LongDateFormat : string;
               TimeAMString : string;
               TimePMString : string;
            ShortTimeFormat : string;
             LongTimeFormat : string;
            ShortMonthNames : array[1..12] of string;
             LongMonthNames : array[1..12] of string;
               ShortDayNames : array[1..7] of string;
               LongDayNames : array[1..7] of string;
  TwoDigitYearCenturyWindow : Word;
  end;
Description
The TFormatSettings record is used to hold Windows locale global variable for use by thread-safe versions of a number of data conversion functions.
 
It must be furnished before invoking a function that uses it.
Related commands
DateTimeToStr Converts TDateTime date and time values to a string
Format Rich formatting of numbers and text into a string
StrToDateTime Converts a date+time string into a TDateTime value
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Use of the format settings record
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  SysUtils,   // Unit containing the TFormatSettings command
  Windows,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  formatSettings : TFormatSettings;

begin
  // Furnish the locale format settings record
  GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, formatSettings);

  // And use it in the thread safe form of CurrToStrF
  ShowMessage('1234.56 formats as = '+
              CurrToStrF(1234.56, ffCurrency, 4, formatSettings));
end;
 
end.
Hide full unit code
   1234.56 formats as ?1,234.5600
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page