How can I remove a menuitem I dynamically added to a menu?
I add dynamically menu items with for example:
m:=TMenuItem.Create(nil);
m.Text:='bla bla bla';
mnuMain.AddObject(m);
I could not find ANY function to remove the entry again. I tried delete, free, removeobject etc. and the item is still nor removed and still visible. What is the trick?
If you are adding a item like so :
Then you are just giving it a parent, just set the parent of the menu items to
nilARC will then swoop in and do the rest seeing as there are no more references to the objectJust write a loop to go through and set all the parents to nil/ Or if you are targeting Windows as well (Or only Windows) in your code, make use of DisposeOf, or make use of compiler directives