Board index » delphi » Items[0].Items[0].Items[0]...

Items[0].Items[0].Items[0]...

Please help, its driving me nuts! I need a general routine to access a
TMenuItem on a TMainMenu via the Tag only instead of all those
Items[#].Items[#]. My fingers are tired.

 

Re:Items[0].Items[0].Items[0]...


Quote
zolic wrote in message <351BED92....@pdq.net>...
>Please help, its driving me nuts! I need a general routine to access a
>TMenuItem on a TMainMenu via the Tag only instead of all those
>Items[#].Items[#]. My fingers are tired.

Try something like:

function ItemByTag(Root: TMenuItem; Tag: Integer): TMenuItem;
var
  i: Integer;
begin
  Result := nil;
  if Root.Tag = Tag then
    Result := Root else
    for i := 0 to Root.Count - 1 do
    begin
      Result := ItemByTag(Root[i], Tag);
      if Result <> nil then Break;
    end;
end;

--
Yorai Aminov
El-On Software Systems
http://ourworld.compuserve.com/homepages/yaminov

Other Threads