![]() |
Problem mit ActionMainMenuBar und Bildchen
Ich habe auf einer From eine Controlbar mit einer ActionMainMenuBar drauf.
In der MenuBar hab ich mit Hilfe des ActionManagers auch einige Actionen drin. Nun möchte ich aber einen Eintrag im Menü dynamisch erzeugen. Dazu erzeuge ich eine Action mit einem eindeutigen Namen und weise diese dann dem Menü zu.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var myAction:Taction; myActionItem:TActionClientItem; begin myAction:=TAction.Create(Form1); myAction.Caption:='caption'; myAction.Name:='action_123'; myAction.OnExecute:=MyActionExecute; myAction.ImageIndex:=1; // <<< hier steckt irgendwie das Problem myActionItem:=ActionManager1.ActionBars[0].Items[1].Items.Add; myActionItem.Action:=myAction; end; Dies klappt auch ganz gut, solange ich der Action kein Bild (aus einer Imagelist) zuweise. Wird jedoch ein ImageIndex (>-1) mit angegeben schmeißt mich der Debugger mit einer Zugriffsverletzung heraus (Lesen von Adresse 00000038) und springt zur procedure TCustomActionControl.DrawGlyph in der Unit ActnMan.pas. Den Actionband-Patch hab ich bereits installiert. Weiß jemand Rat? :?: |
Re: Problem mit ActionMainMenuBar und Bildchen
Hallo,
vor dem zuweisen des Image-index musst du der aktion auch sagen, zu welcher actionlist sie gehört. Schließlich bezieht sich der Imageindex auf die Images in der Liste, die der Actionlist zugeordnet ist. Gruß Ken |
Re: Problem mit ActionMainMenuBar und Bildchen
hi
Danke für den tip. Jetzt funktionierts :-D Ich hab noch folgende Zeile eingefügt:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var myAction:Taction; myActionItem:TActionClientItem; begin myAction:=TAction.Create(Form1); myAction.Caption:='caption'; myAction.Name:='action_123'; myAction.OnExecute:=MyActionExecute; myAction.ActionList:=ActionManager1; // <<< diese Zeile ist neu!!! myAction.ImageIndex:=1; // <<< hier steckt irgendwie das Problem myActionItem:=ActionManager1.ActionBars[0].Items[1].Items.Add; myActionItem.Action:=myAction; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:18 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz