首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Delphi中的未声明标识符(伪造)错误

Delphi中的未声明标识符(伪造)错误
EN

Stack Overflow用户
提问于 2013-07-25 19:07:05
回答 1查看 2.2K关注 0票数 0

Delphi -> Help -> Table Of Content -> Code Example -> Delphi -> ActnMgrBar,有教程规则操作管理器组件。任何人都可以在“帮助”中检索本教程并结帐。

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

代码语言:javascript
复制
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;

我得到了以下错误:

代码语言:javascript
复制
Undeclared Identifier : TActionManager

这种类型的未声明的标识符错误--我经常在Delphi (早些时候,我在TAniIndicator中得到了相同类型的错误)--在源代码中声明组件。在上述情况下,如果我手动将TActionManager放在表单上,那么代码就能工作。有人告诉我,在我的HP PC上安装或配置Delphi一定有错误。

EN

回答 1

Stack Overflow用户

发布于 2013-07-25 19:23:27

当您在设计时将TActionManager放到表单上时,IDE会自动将必要的ActnMan单元引用插入表单单元的uses子句中。该示例显然没有该引用,因此会出现错误。因此,只需手动将ActnMan单元添加到uses子句中即可。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17866677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档