| Subject: | Dynamically added TMenuItems |
| Posted by: | Mike Reublin (nf4l_NO_SP…@nf4l.com) |
| Date: | Sat, 4 Sep 2010 |
I'm adding items to a TMenu with the code below. In the onclick handler, I'd like to
get the checked state, and an index of the selected item. The idea of the index is to
be able to write it to an ini file, and on program start, read it back in to
programatically set an item's checked state.
Usually the loop will only create one mnuSub, sometimes two, rarely more than two.
If that's not doable, I'm open to suggestions.
{code}
while somecondition do
begin
mnuSub:=TMenuItem.Create(mainmenu1);
mnuSub.Caption := s;
inc(n);
mnuSub.AutoCheck := true;
mnuSub.RadioItem := true;
MainMenu1.Items[0].Add(mnuSub);
mnuSub.OnClick := SubMenuClick;
end;
{code}
Thanks, Mike