2013-07-25 42 views
0

Delphi -> Help -> Table Of Content -> Code Example -> Delphi -> ActnMgrBar,有教程regd動作管理器組件。任何人都可以在「幫助」中檢索此教程並查看。德爾福未聲明標識符(僞造)錯誤

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; 

我收到以下錯誤:

Undeclared Identifier : TActionManager 

這種類型的未聲明的標識符錯誤,我安靜下來常常在我的德爾福(早些時候我得到了相同類型的錯誤與TAniIndicator),其中成分在源頭聲明。在上述情況下,如果我手動將TActionManager置於窗體上,則代碼有效。有人告訴我,在我的HP PC上安裝或配置Delphi時一定有錯誤。

+3

將'ActnMan'加入['the uses clause'](http://i.imgur.com/0DZTDK0.png)。 – TLama

+0

我正在使用Embarcadero®Delphi®XE4版本.... –

+0

什麼是假的格式。這是不可讀的。請修復它。 –

回答

6

當您在設計時將TActionManager拖放到窗體上時,IDE會自動將必要的ActnMan單元參考插入到窗體單元的uses子句中。這個例子顯然沒有那個參考,這個錯誤。因此只需手動將ActnMan單元添加到uses子句中。

+0

只要完全清楚,誰告訴你「在我的HP PC上安裝或配置Delphi時必須有錯誤」是完全錯誤的**。只需手動使用組件(而不是讓IDE管理它們),就需要執行IDE執行的所有步驟。 –