-5

I am pretty new in Delphi XE7, got a project and tried to build it, but it gives error like

undeclared identifier 'Images'

in the line..

(TContainedAction(Action).ActionList.Images.Draw(ACanvas, GlyphRect.Left, GlyphRect.Top)

and

TContainedAction does not contain a member named 'image'.

Please help me to resolve issues.

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
  • This isn't your actual code, because a) it doesn't contain anything that would generate the `TContainedAction does not contain` error, and b) it wouldn't get that far anyway because it has mismatched parentheses. If you want help with your code, **post your real code** with enough surrounding content so we have some context and variable/type declarations. – Ken White Dec 16 '14 at 13:20

1 Answers1

1

The error is simple enough to understand. No variable or member is defined in the scope which your code is searching.

undeclared identifier 'Images'

TContainedAction.ActionList is of type TContainedActionList. And TContainedActionList has no member named Images. Hence the error.

You will need to up-cast the TContainedActionList reference to be of a type that has the member you are looking for. I don't know what that type is because I can't see any of your code other than that in the question. Perhaps a cast to TActionList will suffice.

You are playing with fire by using unchecked casts. Use runtime checked casts instead so that you find out if you got it wrong.

uses
  System.Actions, Vcl.ActnList;
....
var
  ActionList: TActionList;
....
ActionList := (Action as TContainedAction).ActionList as TActionList;
// now you can refer to ActionList.Images;

One thing that is unclear is why you need to cast Action. Since we do not know what Action is we cannot advise, beyond commenting that all this casting feels odd.

TContainedAction does not contain a member named 'image'

This error message does not match any code in the question.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490