Delphi中未声明的标识符(Bogus)错误

时间:2013-07-25 19:07:06

标签: delphi

Delphi -> Help -> Table Of Content -> Code Example -> Delphi -> ActnMgrBar处,有教程regd Action Manager组件。任何人都可以在帮助中检索本教程并查看。

  

描述:此应用程序需要表单上已有TPopupActionBar组件。该应用程序创建一个动作管理器组件,并为其某些属性分配一个图像列表。然后,弹出操作栏被自定义并分配给表单的PopupMenu属性。右键单击表单以显示弹出菜单。

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;

我收到以下错误:

Undeclared Identifier : TActionManager

这种类型的Undeclared Identifier错误我经常在我的Delphi中安静(早先我得到TAniIndicator的相同类型的错误)其中组件在源处声明。在上面的例子中,如果我手动将TActionManager放在表单上,​​那么代码就可以了。有人告诉我在HP PC上安装或配置Delphi时一定有错误。

1 个答案:

答案 0 :(得分:6)

在设计时将TActionManager放到窗体上时,IDE会自动将必要的ActnMan单元引用插入到窗体单元的uses子句中。这个例子显然没有那个参考,只有错误。因此,只需手动将ActnMan单位添加到uses子句中。