Solved
dynamic popupmenu creation
Posted on 1998-12-01
I need to create a popup menu dynamicly. It has to change the number of items in it, every time it loads. I have been having a lot of trouble with it because if it has a number of items; the next time it loads, if it has less items, it has the first number of items, it just show the new items in the bottom slots with the old items on top.
Here is the procedure I have right now:
procedure TMainfrm.MenuChange;
var
PopUpItems: array[0..99] of TMenuItem;
i: integer;
begin
for i := 1 to {always changing variable} do begin
popupitems[i].free;
PopUpItems[i] := TMenuItem.Create(Self);
PopUpItems[i].Caption := IntToStr(i);
PopUpItems[i].Tag := i;
PopupItems[i].hint := popupitems[i].caption;
Popupitems[i].Radioitem := true;
popupItems[i].OnClick := PopUpevent;
PopUpMenu1.Items.add(PopUpItems[i]);
end;
end;
A solution to this problem is greatly appreciated.
thanks
spat