Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 09/06/21 in all areas

  1. There is another way to prevent instance creation - or at least misuse - having public constructor that raises exception. TSingleton = class private class var FInstance: TSingleton; constructor CreateSingleton; class destructor ClassDestroy; public constructor Create; class function Instance: TSingleton; static; end; class destructor TSingleton.ClassDestroy; begin FInstance.Free; end; constructor TSingleton.Create; begin raise Exception.Create('Singleton instance cannot be directly constructed'); end; constructor TSingleton.CreateSingleton; begin // actual constructor end; class function TSingleton.Instance: TSingleton; begin if not Assigned(FInstance) then FInstance := TSingleton.CreateSingleton; Result := FInstance; end;
  2. Lars Fosdal

    TPopupMenu with group headers

    Nice idea, @chkaufmann and nglthach. I had to change it around a little to get it to work, as I instantiate the menu items at runtime. Since I don't assign an OnClick handler, I don't need to disable the entry. I mucked around with colors for a while. Currently using Bold White on DarkGrey which works "ok" for both light and dark themes. type TMenuItemGroup = class(TMenuItem) protected procedure DoAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState); public constructor Create(AOwner: TComponent); override; end; constructor TMenuItemGroup.Create(AOwner: TComponent); begin Inherited; OnAdvancedDrawItem := DoAdvancedDrawItem; end; procedure TMenuItemGroup.DoAdvancedDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState); begin ACanvas.Brush.Color := TColors.Darkgrey; // TColors.SysHighlight; // TColors.Darkblue; ACanvas.FillRect(ARect); ACanvas.Font.Color := TColors.White; // TColors.SysHighlightText; // TColors.White; ACanvas.Font.Style := [fsBold]; ACanvas.TextRect(ARect, ARect.Left + 3, ARect.Top + 3, StripHotkey(Caption)); end;
  3. 0x8000FFFF

    TPopupMenu with group headers

    Maybe you should disable the item anyway to prevent navigating to it using arrow keys.
  4. If you don't want instances, then don't make it a class - this ain't Java.
  5. dummzeuch

    Anybody changing FileVersion directly in dproj file?

    I think you overestimate the complexity of an automated build: Have a release configuration in the IDE Build from command line. That's it. You can always add more to the automation but the command line build is a good starting gpoint.
  6. https://firebase.google.com/docs/reference/rest/database
  7. David Heffernan

    Anybody changing FileVersion directly in dproj file?

    Why wouldn't you automate the build?
  8. nglthach

    TPopupMenu with group headers

    @chkaufmann Something like this?
×