A very interesting thread at [WayBack] Do i need to create one TFormatSettings instance for each thread that needs it? If i want the same settings (for all threads), th… – Dany Marmur – Google+
It’s about:
- The global [Archive.is] FormatSettings variable.
- [WayBack] TFormatSettings record
- RTL methods with and without TFormatSettings parameters, for instance [WayBack] SysUtils.StrToFloat Function
- The [WayBack] TApplication.UpdateFormatSettings Property named like a method that can inhibit [WayBack] WM_WININICHANGE message handling: set the property to false and the handling is disabled.
- This property has been present since Delphi 3 and documented since at least Delphi 2007.
- Sometimes Ctrl-Shift-Enter on TFormatSettings in the code editor gives you the list of usages. Often that list is incomplete.
- Much more.
Recommended reading!
It made me go back to these style guides (from oldest to newest):
- [WayBack] Object Pascal Style Guide
- [WayBack] Object Pascal Style Guide original by Charles Calvert
- [WayBack] Delphi Developer’s Guide (live version disappeared after 20050306)
- [WayBack] Econos – Coding Standard Document (live version disappeared after 20140227)
- [WayBack] Delphi Language Coding Standards Document
And Stefan Glienke reminded me naming is always hard, so I found back these from a distant past:
- There are only two hard things in Computer Science: cache invalidation and naming things — Phil Karlton (bonus variations on the page)Source:[WayBack] TwoHardThings
- [WayBack] Leon Bambrick @secretGeek: There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors.
- [WayBack] Mathias Verraes @mathiasverraes: There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery
Note most of the above Links point to (archives of) Delphi 2007 documentation as the behaviour is that old and that the below identifiers were not mentioned in the thread.
The FormatSettings
variable was introduced in Delphi XE but only documented in XE2 and up.
Until that, other global variables like the [WayBack] SysUtils.DecimalSeparator Variable were used.
- [WayBack] SysUtils.GetLocaleFormatSettings Function that updates the global FormatSettings variable from a Locale ID
- [WayBack] SysUtils.GetFormatSettings Function that is called when WM_WININICHANGE message handling is enabled
- Lists of LCID values can be found here:
- old now defunct Locale ID Chart and replaced by the new:
- Microsoft Locale ID Values,
- Language Identifier Constants and Strings table or
- list of Locale IDs Assigned by Microsoft
- [WayBack] WM_WININICHANGE message (Windows)
- [WayBack] WM_SETTINGCHANGE message (Windows)
–jeroen