Jump to content

Lars Fosdal

Administrators
  • Content Count

    3504
  • Joined

  • Last visited

  • Days Won

    115

Everything posted by Lars Fosdal

  1. Lars Fosdal

    AllocHwnd + TTimer = lag?

    That is waaay to familiar. As a developer, you never run out of chances to own yourself.
  2. Lars Fosdal

    AllocHwnd + TTimer = lag?

    I've had issues with having multiple allocated hWnds and messaging. Ended up with a single allocated hWnd and a custom message broker/router for my user messages.
  3. Lars Fosdal

    Delphi 11 Announced

    https://blogs.embarcadero.com/rad-studio-11-is-coming-new-version-announcement-and-beta-invite-for-update-subscription-customers/
  4. Lars Fosdal

    Delphi 64 bit Registration Tools for Windows Apps

    A company that offers registration tools i.e. licensing tools for developers?
  5. Lars Fosdal

    Drawing bug with VCL Styles

    Still unable to reproduce (10.4.2).
  6. Lars Fosdal

    Alfabetical order of a letter

    A-Z. AA-ZZ, AAA-ZZZ
  7. Assuming the Tag value of each checkbox can be set to the ordinal of it's enum, you could walk the enums and check if you find a checkbox under Filters for each of them. If you don't find it - you change the caption of "Filters: to "Filters is INCOMPLETE" or log it or whatever. But - it would be runtime, preferably in the debug code. Likewise, you could easily take a set of enum values to get or set the states of the check boxes. It is a little inconvenient to do this in Generics, since we don't have a constraint for enumerated types - which means we can't really use Low, High or Ord, but it is possible.
  8. Lars Fosdal

    Create hyperlink inside code

    Very thin description. Are we talking design time in source code?
  9. Link rot - the scourge of the internet 😛
  10. Originally a comment to I find Attributes to be an excellent feature of Delphi. Saves me a lot of variations of init code which instead is done with attributes.
  11. Lars Fosdal

    Using Attributes in class declarations

    I see that I've cut off the source I pasted. If you had the full source, you would have seen that the numbers are the default widths in pixels. This is the initial default value. I.e. those you need before you have a config to load. The same default as you would define in a constructor or design in the form editor. Likewise, with the type of the field, there is a default alignment which can be overridden with the attribute. These are indeed presentation properties and they are defaults explicitly bound to each instance of a field. The idea is to keep the default properties together with the field declarations instead of having them spread out through the code or defined in the .dfm. Unfortunately, I cannot use record constants to initialize the titles or specify the secondary sorting columns due to limitations in the language.
  12. Lars Fosdal

    Using Attributes in class declarations

    The grid sets are multipurpose. I can create gridsets dynamically from an SQL query, or dynamically from records or objects, or I can specify the design as in the example. All the actual grids have the same features, look and feel and the same behaviour. Visual inheritance is a nightmare. Just the same way as values in a constructor or in a designtime form are hardcoded. Except - the values are in code, right next to the declaration. Please elaborate? Where and how? As for torture of fingers. It is not like you need a huge amount of square brackets and using them is no different from when using them for arrays. [InitField(50, hcLeftJustify), UniqueField, DefaultSortField, ReadOnlyField] GlobalLocId: TFieldInteger; Anyways... Don't be blinded by one man's implementation in a specific context tailored for his needs. Attributes can be very useful and applied for a wide range of purposes.
  13. Lars Fosdal

    Delphi compatibility with Windows 11?

    AWS and Azure already have virtual TPMs for VMs.
  14. Lars Fosdal

    Delphi compatibility with Windows 11?

    Well, every other piece of hardware is virtual in a VM, so why not the TPM?
  15. Lars Fosdal

    Delphi compatibility with Windows 11?

    Both AWS and Windows Server Hyper-V VMs can have virtualized TPMs. I would expect VMWare and others to go the same way. I am curious towards what you would need to do to move a VM from one workstation to another if it relies on a physical TPM. Perhaps an export/import thing? BTW: Currently, Generation 8 of Intel is the CPU cutoff point. For anything older than that, Windows 10 21H2 will be available and patched until 2025. https://www.theverge.com/2021/6/25/22550376/microsoft-windows-11-tpm-chips-requirement-security
  16. Lars Fosdal

    Using Attributes in class declarations

    I am pretty sure that the syntax of attributes won't change, so that discussion is not really interesting. Your suggested helper separates the attributes from the field/property declarations, which is not a good thing, IMO. As for cross platform - there would be two means of managing that. Defines around the attributes, or ensuring that values are appropriately scaled in the TGridView class (See last paragraphs). The attributes are just the means to change a default. I can (and do) change attributes of the fields in a Create method as well. I would have loved to be able to set all these from attributes as well, but the compiler won't allow it. If we had lambda expressions and the compiler would accept complex constants as arguments, I'd move of this to attributes. constructor TSiteGridSet.Create; begin inherited; LocationNo.Title := titles.LocationNo; GlobalLocId.Title := titles.GlobalLocId; Name.Title := titles.Name; Environment.Title := titles.Environment; Role.Title := titles.Role; AppServer.Title := titles.AppServer; LocationType.Title := titles.LocationType; DBInfo.Title := titles.DBInfo; BuildName.Title := titles.LocationType; LocationBuildTrack.Title := xlt.Create('Build'); LocationBuildTrack.Formatter := function (const aValue: TPSDLocationBuildTrack): string begin case aValue of lbtDefault, lbtLive : Result := 'Live'; lbtPilot : Result := 'Pilot'; lbtTrunk : Result := 'Trunk'; else Result := ''; end; end; RowStyler := HighlightOffline; Environment.SecondaryKeys := [LocationType, Role, Name]; Environment.Formatter := function(const aValue: TPSDEnviroment):String begin Result := aValue.ToString end; Name.ColumnStyler := Self.ServerNameColor; Role.SecondaryKeys := [LocationType, Environment, Name]; Role.Formatter := function(const aValue: TPSDServerRole):String begin Result := aValue.ToString; end; Role.CellStyler := ServerRoleColor; LocationType.SecondaryKeys := [Environment, Role, Name]; LocationType.Formatter := function(const aValue: TPSDLocationType):String begin Result := aValue.ToString; end; Param.OwnsReference := True; FComboLayout := Layout.AddLayout(xlt.Create('Combo'), [LocationNo, Name, Environment, LocationBuildTrack, Role, GlobalLocId]); end; FYI - the TGridSet is non-visual. There is a TGridView proxy class that takes a TGridSet and applies the visual stuff to the actual grid. TSiteQueryGrid = class(TGridViewPSD<TPSDLocation, TSiteGridSet>); Currently, the TGridView was written to only support TMS TAdvStringGrid, but could be refactored into a multiplatform/multigrid adapter.
  17. Lars Fosdal

    [Android][Rio] How catch timeout REST error?

    I split the Attribute discussion into a separat thread
  18. Lars Fosdal

    Using Attributes in class declarations

    They are far from perfect. They don't support generics, nor can you send a structured constant as an argument, even with if they were declared as {$WRITEABLECONST OFF}. For my grids wrappers, I have a load of them... type TGridSetAttribute = class abstract(TCustomAttribute); /// <summary> Disable automatic field creating for GridSet </summary> GridManuallyCreateFieldsAttribute = class(TGridSetAttribute); /// <summary> Allow MultiSelect in Grid</summary> GridMultiSelectAttribute = class(TGridSetAttribute) MultiSelect: Boolean; constructor Create; overload; constructor Create(DoMultiSelect:Boolean); overload; end; GridMultiLineCellsAttribute = class(TGridSetAttribute) MultiLineCells: Boolean; constructor Create; overload; constructor Create(DoMultiLineCells:Boolean); overload; end; /// <summary> Autosize entire grid </summary> GridAutoSizeAttribute = class(TGridSetAttribute) AutoSizeEnabled: Boolean; constructor Create; overload; constructor Create(DoAutoSize:Boolean); overload; end; /// <summary> Turn on filters for grid </summary> GridShowFiltersAttribute = class(TGridSetAttribute) ShowFilters: Boolean; constructor Create; overload; constructor Create(DoShowFilters:Boolean); overload; end; GridEditModeAttribute = class(TGridSetAttribute) EditMode: Boolean; constructor Create; overload; constructor Create(DoEditMode:Boolean); overload; end; /// ----------------- Field attributes ----------------- TQueryFieldAttribute = class(TCustomAttribute) constructor Create; virtual; end; /// <summary> Allow MultiSelect in Grid</summary> CheckBoxAttribute = class(TQueryFieldAttribute); /// <summary> Text to show as hint for column header </summary> HeaderHintAttribute = class(TQueryFieldAttribute) Hint: xlt; constructor Create; overload; override; constructor Create(const aHint: string); reintroduce; overload; constructor Create(const aHint: xlt); reintroduce; overload; end; /// <summary> Mark field as UniqueField </summary> UniqueFieldAttribute = class(TQueryFieldAttribute); /// <summary> Read-Only field attribute </summary> ReadOnlyFieldAttribute = class(TQueryFieldAttribute) ReadOnly: Boolean; constructor Create; overload; override; constructor Create(const IsReadOnly: Boolean); reintroduce; overload; end; /// <summary> Mark field as hidden </summary> HiddenFieldAttribute = class(TQueryFieldAttribute) WhenBlank: boolean; //Hides columns if all the data is empty string og 0 constructor Create; overload; override; constructor Create(const aWhenBlank: Boolean); reintroduce; overload; end; InternalFieldAttribute = class(TQueryFieldAttribute); /// <summary> Enable filtering for column </summary> DontFilterFieldAttribute = class(TQueryFieldAttribute) constructor Create; override; end; /// <summary> Custom Field - populate in DoAfterConvert </summary> CustomFieldAttribute = class(TQueryFieldAttribute); /// <summary> Toggle visibility of hidden field</summary> ToggleFieldAttribute = class(TQueryFieldAttribute); /// <summary> Grouping column </summary> GroupingAttribute = class(TQueryFieldAttribute) Priority: Integer; constructor Create; overload; override; constructor Create(const aPriority: Integer); reintroduce; overload; end; UseFieldAsCategoryAttribute = class(TQueryFieldAttribute); /// <summary> Category Name for GridEdit </summary> CategoryAttribute = class(TQueryFieldAttribute) Name: string; Priority: Integer; constructor Create; overload; override; constructor Create(const aName: string; const aPriority: Integer = MaxInt); reintroduce; overload; end; /// <summary> Autosize field </summary> AutoSizeAttribute = class(TQueryFieldAttribute) AutoSizeEnabled: Boolean; MinSize: Integer; MaxSize: Integer; constructor Create; overload; override; constructor Create(DoAutoSize:Boolean); reintroduce; overload; constructor Create(aMinSize, aMaxSize: Integer); reintroduce; overload; end; /// <summary> Set OwnsReference to true for field:TFieldReference<T> instance </summary> OwnsReferenceAttribute = class(TQueryFieldAttribute); /// <summary> Mark field as using WordWrap </summary> WordWrapAttribute = class(TQueryFieldAttribute) public WordWrap: TFieldWordWrap; constructor Create; overload; override; constructor Create(const aWordWrap: TFieldWordWrap); reintroduce; overload; end; /// <summary> Mark field as using WordWrap </summary> NoWordWrapAttribute = class(WordWrapAttribute) public constructor Create; override; end; /// <summary> Mark field as default sort-by column </summary> DefaultSortFieldAttribute = class(TQueryFieldAttribute) public SortDescending: Boolean; constructor Create; overload; override; constructor Create(const aSortDescending: Boolean); reintroduce; overload; end; /// <summary> [InitField(64 {, alignment})] <br/> /// [InitField('Title', 64 {, alignment})] <br/> /// [InitField('Title', 'Name Override for SQL', 64 {, alignment})]</summary> InitFieldAttribute = class(TQueryFieldAttribute) Here is an example of how I use them for what I call a GridSet. I have a large number of grids that uses gridsets instead of having visual form designed grids. type TSiteGridSet = class(TGridSet<TPSDLocation>) public [GridShowFilters, GridAutoSize] [CustomField] Ticked: TFieldCheckBox; [InitField(40), UniqueField] GlobalLocId: TFieldInteger; [InitField(50, hcRightJustify )] LocationNo: TFieldString; [InitField(110)] Name: TFieldString; [InitField(70), DefaultSortField] Environment: TFieldEnum<TPSDEnviroment>; [InitField(70)] Role: TFieldEnum<TPSDServerRole>; [InitField(70)] LocationBuildTrack: TFieldEnum<TPSDLocationBuildTrack>; [InitField(70), HiddenField] BuildName: TFieldString; [InitField(70)] AppServer: TFieldString; [InitField(70)] LocationType: TFieldEnum<TPSDLocationType>; [InitField(300)] DBInfo: TFieldString; [InitField(300)] DBHostName: TFieldString; [HiddenField] Param: TFieldReference<TPSDCreateParameters>;
  19. Lars Fosdal

    Delphi compatibility with Windows 11?

    aka.ms is about a decade old, I think 🙂 That is an interesting conundrum with the Parallels VM and the TPM. The whole point of a VM is that is is portable.
  20. Lars Fosdal

    How do I check for empty rows in a string grid?

    I use wrappers that fill my grids, and I clear the grid and set up the grid size before I start loading data.
  21. Lars Fosdal

    Windows 11 and Server 2022 versions

    Who knows... Oddly, Windows Product Name still says Windows 10 Pro
  22. Lars Fosdal

    Windows 11 and Server 2022 versions

    The current Windows 11 build shows (among lots of other values) PS C:\Windows\System32> get-computerinfo | format-list WindowsBuildLabEx : 22000.1.amd64fre.co_release.210604-1628 WindowsCurrentVersion : 6.3 WindowsEditionId : Professional WindowsInstallationType : Client WindowsProductName : Windows 10 Pro WindowsVersion : 2009 WindowsUBR : 51 OsName : Microsoft Windows 11 Pro OsType : WINNT OsOperatingSystemSKU : 48 OsVersion : 10.0.22000 OsCSDVersion : OsBuildNumber : 22000 OsHotFixes : {KB5004034, KB5004567, KB5004564, KB5004570} PS C:\Windows\System32>
  23. Lars Fosdal

    Drawing bug with VCL Styles

    Ok, I tried with the vertical offsets as well. No change. Maximized perfectly - even when spanning both displays. I suspect driver antics? What are the resolutions and scaling of monitor 1 and 2 ?
  24. Lars Fosdal

    Drawing bug with VCL Styles

    I didn't try that offset config. I always aligned the top or the bottom edges?
×