Client formatting changes when printing in Firemonkey

I have a datasnap server and client. The server system has a decimal separator ".". I do not know what my clients will have, so I change it in my program.

FormatSettings.DecimalSeparator:='.';
FormatSettings.ThousandSeparator:=' ';

Now, when I print from my client, FormatSettings are restored to default.

  Printer.ActivePrinter.SelectDPI(600,600);
  //formatsettings.Decimalseperator is now ","

What is this behavior? This is mistake?

Bonus Q: How do you maintain the same settings for the client and server?

+4
source share
1 answer

FormatSettingsis a global variable. It can be changed anywhere, and all code that uses it will be affected.

TFormatSettings , FormatSettings . , , - , , .

, , , , .

var
  MyFormat: TFormatSettings;

MyFormat := TFormatSettings.Create;
MyFormat.DecimalSeparator:='.';
MyFormat.ThousandSeparator:=' ';

.

, FormatSettings, , , - FormatSettings , .

StrToFloat , .

function StrToFloat(const S: string; const AFormatSettings: TFormatSettings): Extended;
+5

Source: https://habr.com/ru/post/1569401/


All Articles