在Delphi -> Help -> Table Of Content -> Code Example -> Delphi -> ActnMgrBar,有教程规则操作管理器组件。任何人都可以在“帮助”中检索本教程并结帐。
描述:此应用程序需要表单上已有的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这种类型的未声明的标识符错误--我经常在Delphi (早些时候,我在TAniIndicator中得到了相同类型的错误)--在源代码中声明组件。在上述情况下,如果我手动将TActionManager放在表单上,那么代码就能工作。有人告诉我,在我的HP PC上安装或配置Delphi一定有错误。
发布于 2013-07-25 19:23:27
当您在设计时将TActionManager放到表单上时,IDE会自动将必要的ActnMan单元引用插入表单单元的uses子句中。该示例显然没有该引用,因此会出现错误。因此,只需手动将ActnMan单元添加到uses子句中即可。
https://stackoverflow.com/questions/17866677
复制相似问题