1

I still use Delphi XE4 (newest compiler I use of multiple Delphi compilers) and need a specific workaround for the fact they completely hid FClients in TBasicAction in this version. I connect/disconnect clients runtime while setting enabled/disabled (to avoid flicker with ~100+ actions and ui elements) thus this workaround for XE4:

Here's my naive attempt and simply returning the field.

  TmscBasicActionCrack = class(TBasicAction)
  end;
{$IFDEF mymsDELPHIXE4}
  TmscBasicActionHelper = class helper for TBasicAction
  public
    function Helper_Get_Private_FClients: TList<System.Classes.TBasicActionLink>;
  end;
{$ENDIF}

{$IFDEF mymsDELPHIXE4}
//------------------------------------------------------------------------------
function TmscBasicActionHelper.Helper_Get_Private_FClients: TList<System.Classes.TBasicActionLink>;
begin
  Result := Self.FClients;
end;
{$ENDIF}

However, I get error

E2003 Undeclared identifier: TList<>

I must admit I never go around to using generics with Delphi since I initially heard of stability problems + I need to maintain compability with Lazarus/FreePascal.

I am aware the most recent versions Delphi has altered class helpers again, but I am for now mostly interested in getting this to work with Delphi XE4

6
  • Please make as answer... And I will accept. Thanks :) Commented Apr 10, 2017 at 12:01
  • If you ever upgrade to Berlin or higher, your class helper will no longer work as-is, you would have to re-write it (see How to access a private field from a class helper in Delphi 10.1 Berlin?). You should find a different solution to your problem. Why do you need direct access to the FClients list at all? It is private for a reason. Commented Apr 10, 2017 at 20:01
  • I have a rather convoluted setup where 100+ actions are set enabled/disabled in onidle ... now unfortunately the rules are a bit complex (also partly riddled with defines since I have 6 different tools compiling/using exact same project and code) and some actions can be set twice (yes, I could create boolean values for all actions, work on them and then set actions) - that causes flicker in toolbars. My solution long ago was to disattach actions from their UI elements while updating the action states. Commented Apr 10, 2017 at 20:19
  • 2
    You should be updating the action states in the OnUpdate event of the individual actions, or in the OnUpdate event of the TActionManager, but not in the Application.OnIdle event itself. Also look at the TApplication.ActionUpdateDelay property (which is 0 by default). Commented Apr 10, 2017 at 20:25
  • Thanks - I will try see if those are available in Lazarus as well ror maybe use those you list for Delphi in defines - I use the same codebase + forms for Delphi and Lazarus (Using Lazarus for targeting Mac) Commented Apr 10, 2017 at 21:10

1 Answer 1

9

The error is indicating that the TList<T> type is unknown to the compiler. To use it you must include System.Generics.Collections in your uses clause.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.