Re: dynamic menu problem



"Marty" <bmadmarty@xxxxxxxxxxx> wrote in news:1118903232.902916.307570
@g49g2000cwa.googlegroups.com:

> does anyone know how to get this going or improve with better code

It is not clear to me, either from the description or from the program (it's
too complicated), what exactly you are trying to achieve. Perhaps you could
write a simple, test program to create a dynamic menu without all the
database stuff (which just serves to confuse) - it will be easier for you
and easier for us.

Here is a bit of code from one of my programs to create a submenu from the
strings of a TStrings object (e.g. a stringlist):

function PopulateSubMenu(ParentMenuItem: TMenuItem; TheStrings: TStrings;
TheNotifyEvent: TNotifyEvent; Current: String): Boolean;
var
I: Integer;
S: String;
TheMenuItem: TMenuItem;
begin
Result := False; // prime to indicate no submenu items
with ParentMenuItem do
begin
// add new subitems
for I := 0 to Pred(TheStrings.Count) do
begin
S := TheStrings[I];
TheMenuItem := NewItem(S, 0, False, True, TheNotifyEvent, 0, '');
Add(TheMenuItem);
end;
Enabled := (Count > 0);
end;
end;

Hope it helps. BTW I suspect that you might need a main menu item (as in my
ParentManuItem) to hang your submenu on to.
.