delphi - TActionManager in MDI application. Losing actions -
i have mdi application , i'm using tactionmanager manage actions within application means contains actions mdichild forms.
here's simple exemple recreate problem:
create new vcl forms applications 2 forms. form1 & form2 drop tbutton , tactionmanager on form1. create 2 tactions using tactionmanager's popup editor. set formstyle := fsmdiform form1. set formstyle := fsmdichild form2.
add code correspondant events:
// form1 procedure tform1.action1execute(sender: tobject); begin showmessage('action1'); end; procedure tform1.action2execute(sender: tobject); begin showmessage('action2'); end; procedure tform1.button1click(sender: tobject); var oform2: tform2; begin oform2 := tform2.create(application); end; // form 2 procedure tform2.formclose(sender: tobject; var action: tcloseaction); begin action := cafree; end; drop tactiontoolbar on form2. drop action1 , action2 on tactiontoolbar using tactionmanager popup editor. save & run. click on button on form1 show form2. works expected. close form2 , open back. actions missing...
is there way avoid losing actions knowing need use tactionmanager?
i going attempt explain best understand issue.
first of all, actions disconnected not "gone", still exist. in other words, actionmanager1.actioncount still return 2.
with said, doing @ design time connecting 1 action list on 1 form variable tool bar on form variable. in other words. form1.actionlist being attached form2.toolbar. that's why works first time run, next time create instance of tform2, no longer default created form2 , therefore not connected variable form1. has been best guess on years, , have experienced similar issues datamodules.
my answer is, put action list on child form. if need actions shared across of child forms, action list , tool bar belong on mdi parent. standard mdi apps.
Comments
Post a Comment