0
votes

At Delphi -> Help -> Table Of Content -> Code Example -> Delphi -> ActnMgrBar, There is tutorial regd Action Manager Component. Anyone can retrieve this tutorial at Help and check out.

Description : This application requires a TPopupActionBar component already on the form. The application creates an action manager component and assigns an image list to some of its properties. Then, the popup action bar is customized and assigned to the form's PopupMenu property. Right click the form to show the popup menu.

procedure TForm1.FormCreate(Sender: TObject);
var
  Images: TImageList;
  Image: TBitmap;
  ActionManager: TActionManager;  
  Option1, Option2: TMenuItem;
begin
  // display an information message
  ShowMessage('Right click the form to display the customized popup menu');
  // create an image list
  Images := TImageList.Create(self);
  Images.Height := 32;
  Images.Width := 32;
  try
    Image := TBitmap.Create;
    Image.Height := 32;
    Image.Width := 32;
    Image.Canvas.Font.Name := 'Times New Roman';
    Image.Canvas.Font.Size := 22;
    Image.Canvas.TextOut((Image.Width - Image.Canvas.TextWidth('1')) div 2, 0, '1');
    Images.Add(Image, nil);
  finally
    Image.Free;
  end;
  // create an action manager and assign the image list to some of its properties
  ActionManager := TActionManager.Create(self);  
  ActionManager.DisabledImages := Images;  
  ActionManager.LargeDisabledImages  := Images;  
  ActionManager.LargeImages := Images;
  // add some items to the popup menu associated with the popup action bar
  Option1:= TMenuItem.Create(self);
  Option1.Caption := 'New';
  PopupActionBar1.Items.Add(Option1);
  Option2:= TMenuItem.Create(self);
  Option2.Caption := 'Save';
  PopupActionBar1.Items.Add(Option2);
  // let the popup action bar be the form's popup menu
  Form1.PopupMenu := PopupActionBar1;
end;

I am getting the following error:

Undeclared Identifier : TActionManager

This type of Undeclared Identifier error I get quiet often at my Delphi (Earlier I got same type of error with TAniIndicator) where component is declared at source. In above case, if I manually put TActionManager on form then code works. Someone told me there must be error with installation or configuration of Delphi on my HP PC.

1
Add ActnMan to the uses clause.TLama
I am using Embarcadero® Delphi® XE4 version....Vishal Desai
What's bogus is the formatting. This is unreadable. Please fix it.David Heffernan
So then you have Vcl.ActnMan with a full namespace.TLama
Not a "bogus" error at all. If you don't have the proper unit in the uses clause that defines a TActionManager, the TActionManager type doesn't exist, making it an "undeclared identifier".Ken White

1 Answers

6
votes

When you drop a TActionManager onto a Form at design-time, the IDE automatically inserts the necessary ActnMan unit reference into the Form unit's uses clause. The example obviously does not have that reference, hense the error. So simply add the ActnMan unit to your uses clause manually.