[Solved] Separate the TActionList/TAction from the Form. lazarus / 21-General ---------------------------------------------------------------------- pebe · 2022-04-01 18:18 I am in the process of refactoring my application as it has become a "little mess" I am wondering how to approach the topic of separating TActionList and TAction actions from the TForm form. Currently I have a lot of forms in which actions are defined. Basically, everything works fine, but at the moment, it makes it a bit difficult for me to make some changes, such as combining the functionality of two forms into one form. I don't know how practical this approach is, but it seems to me that it will be a bit cleaner in the code - at least from the backbone of the application, e.g. form control (unit form1) vs form function (unit form1Action) I do not want to reinvent the wheel, so I ask you. How to bite it? Is my approach correct? ---------------------------------------------------------------------- howardpc · 2022-04-01 20:10 One common approach is to place actionlist(s) on datamodule(s), rather than bundling everything together on forms. ---------------------------------------------------------------------- pebe · 2022-04-03 16:42 Thanks for the hint. Somehow I didn't associate DataModule with this functionality. I think the topic can be closed, unless someone has other suggestions? ---------------------------------------------------------------------- wp · 2022-04-03 17:08 Quote from: pebe on April 03, 2022, 06:42:58 pmSomehow I didn't associate DataModule with this functionality. I think it is badly named, and the usual tutorials mention it only in combinations with database applications. A datamodule is good for any non-visual controls. For example, when you need the same images in several forms, put the imagelist into a datamodule! The only complication is that the datamodule must be created before the form using it, i.e., in the "Project Options" > "Forms" > "Autocreate forms" it must be at the top. (But this in turn causes problems, when you have code in the datamodule which refers to one of the now not yet created forms... - this is an indication that you should rethink the dependencies in your project). ---------------------------------------------------------------------- pebe · 2022-04-03 17:54 Quote from: wpBut this in turn causes problems, when you have code in the datamodule which refers to one of the now not yet created forms... - this is an indication that you should rethink the dependencies in your project Precious Tip. heh, I processed this case. I had to approach certain issues/solutions in the application a little differently and it helped I think a similar approach would be to create a unity. In fact DataModule is such a unit, only with visual representation of non- visual controls