Jump to content

Lars Fosdal

Administrators
  • Content Count

    3524
  • Joined

  • Last visited

  • Days Won

    116

Everything posted by Lars Fosdal

  1. Lars Fosdal

    Enums and generics

    Not really. Usually I just create a keyboard macro on the fly to make the template, and then I fill in the texts afterwards.
  2. Lars Fosdal

    Enums and generics

    Normally we use Sisulizer, but it is hard to keep track of context in Sisulizer, so for enums we have this "dirty" workaround which also prevents missing translations.
  3. Lars Fosdal

    Enums and generics

    It probably is no consolation that I also have hundreds of these helpers... TAllowState = (asAllow,asWarn,asDeny); TAllowStateHelper = record helper for TAllowState const Translate: array[TAllowState] of xlt = ( { asAllow } (no:'Tillatt'; se:'Tillåten'; en:'Allow'), { asWarn } (no:'Vis advarsel'; se:'Visa varning'; en:'Show warning'), { asDeny } (no:'Sperret'; se:'Sperrad'; en:'Denied') ); public function ToString(const Language: TLanguage = langDefault): String; inline; class function FromString(str: string; const Language: TLanguage = langDefault): TAllowState; static; end; { TAllowStateHelper } class function TAllowStateHelper.FromString(str: string; const Language: TLanguage): TAllowState; begin Result:=asWarn; //Default var Lang := Language.GetLanguage; for var state :=Low(TAllowState) to High(TAllowState) do if CompareText(str, state.ToString(Lang)) = 0 then Exit(state); end; function TAllowStateHelper.ToString(const Language: TLanguage): String; begin Result := Translate[Self].Text(Language); end;
  4. Lars Fosdal

    Enums and generics

    It is tricky to do a generic helper class for Enumerations, since there is no constraint that will allow you to use enum operators. There are workarounds, but not pretty ones. As for having to use a constant table - why not use the actual type name? There is System.TypInfo function to convert an enum to a string which reflects the actual type name. http://docwiki.embarcadero.com/Libraries/Sydney/en/System.TypInfo.GetEnumName Result := GetEnumName(TypeInfo(TProjectType), Ord(Self)); There also is the reverse http://docwiki.embarcadero.com/Libraries/Sydney/en/System.TypInfo.GetEnumValue
  5. Lars Fosdal

    best component for web media player

    @RDP1974 - I moved the post and delete the three "reposts". If you happened to post in the wrong category, ask a moderator to move it. Please don't do reposts/cross-posts.
  6. Wrong floating point precision when choosing overloads https://quality.embarcadero.com/browse/RSP-27488 Reduction of precision from integer to single rather than double https://quality.embarcadero.com/browse/RSP-27499 Another case of silent reduction of precision https://quality.embarcadero.com/browse/RSP-27500
  7. Can it be that some of the known FP expression precision issues come into play here?
  8. It was based on this: https://stackoverflow.com/questions/12788870/conditionally-compile-units-for-fmx-or-vcl I never mix VCL and FMX form code in projects myself, but I guess the problem here is that the "defined" depends on FMX.Types already being in scope. My approach would probably be to use an interface or a proxy class to hide the actual VCL/FMX accesses.
  9. Lars Fosdal

    Grid Sort indicator

    No worries. The only benefit of custom draw is if the column title is wider than the actual column.
  10. Lars Fosdal

    System.GetMemory returning NIL

    @Kas Ob. - The 32-bit IDE is running on WoW. My IDE crashes too. Out of memory or it simply hangs in an internal deadlock. Several times per day. But - it has never crashed or trashed my Windows 10 Enterprise 1909 system. My uptime is typically about a month, i.e. until the next security patches. RAD Studio, Visual Studio, VS Code, PowerShell 7, MS SQL Server Manager, MS SQL Server, a large number of remote desktops, Excel, Outlook, OneNote, Teams, Discord, Chrome with too many tabs, Apex SQL Diff, Beyond Compare, VirtualBox, and the invaluable Process Hacker. I was thinking of the software you write - if it has page file issues - you either have HW spec issues, or you have allocation strategy issues.
  11. Lars Fosdal

    System.GetMemory returning NIL

    "suffered from potential degradation" ? Either you suffer, or it is entirely potential. "The guys" ?
  12. Lars Fosdal

    System.GetMemory returning NIL

    If your software has issues with page file involvement - your machines are not up to spec.
  13. If you need VCL/FMX conditions in your own code, this works: {$DEFINE HAS_VCL} {$IF DECLARED(FireMonkeyVersion) and (FireMonkeyVersion >= 16.0)} {$UNDEF HAS_VCL} {$DEFINE HAS_FMX} {$IFEND}
  14. Lars Fosdal

    System.GetMemory returning NIL

    @Kas Ob. My last three laptops have had 32Gbs of RAM. Page file involvement is pretty rare.
  15. Lars Fosdal

    August 2020 GM Blog post

    A forum is a place for reasoning and discussion. SO, not so much. What do you prefer? I guess most people go to SO to get an answer, provided one exists, and if not - use a forum. Edit: I gave up on SO for asking questions a long time ago.
  16. Lars Fosdal

    Grid Sort indicator

    Surely there are better characters in Unicode that you can use? ↑ / ↓ #$2191 / #$2193 ˄ / ˅ #$02C4 / #$02C5 ▲ ▼ #$25B2 / #$25BC Optimal solution could be a custom draw, but... is it worth the effort?
  17. Lars Fosdal

    August 2020 GM Blog post

    But SO is not a forum. Questions that are ... unprecise ... get eradicated fast and hard.
  18. Lars Fosdal

    August 2020 GM Blog post

    Looks like YAME. Yet Another Marketing Event.
  19. Lars Fosdal

    August 2020 GM Blog post

    https://community.idera.com/developer-tools/p/forums has some traffic, but I wonder how they will address the need for sub-forums that are not strictly Delphi...
  20. Lars Fosdal

    August 2020 GM Blog post

    We're gonna need more moderators And... perhaps some anger management classes
  21. Added this suggestion today. https://quality.embarcadero.com/browse/RSP-30444
  22. Lars Fosdal

    Is interposer class really best to customize TPanel.Paint?

    I use the same approach as @FPiette
  23. Oh Emm Gee - that was scary 😄
  24. Lars Fosdal

    Debug Expert

    The socket error is caused by something already using the port that you try to bind. F.x. if you run a http server, it defaults to port 80, but there may already be something else on your machine using port 80.
  25. I prefer using method parameters instead of fields as parameters for reentrancy and thread safety. This allows for a parallel model or recursive model Result := SharedObject.Search('Value'); vs this, which does not allow parallel calls or recursive calls SharedObject.SearchField := 'Value'; Result := SharedObject.Search;
×