Hallo,
ich würde es so probieren:
Delphi-Quellcode:
type
TEnumMenuItemProc = procedure (item: TMenuItem) of object;
procedure TDemoForm.EnumMenuItem(item: TMenuItem);
begin
with item do
if IsLine then
begin
OnDrawItem := SeparatorDrawItem;
OnMeasureitem := MeasureSeparator;
end else
begin
onDrawItem := MenuItemDrawItem;
OnMeasureitem := MenuItemMeasureItem;
end;
end;
procedure EnumerateMenuItems(item: TMenuItem; proc: TEnumMenuItemProc);
var
i: Integer;
subItem: TMenuItem;
begin
for i := 0 to Pred(item.Count) do
begin
subItem := item.Items[i];
proc(subItem);
if subItem.Count > 0 then
EnumerateMenuItems(subItem, proc);
end;
end;
procedure TDemoForm.Button3Click(Sender: TObject);
begin
EnumerateMenuItems(MainMenu.Items, EnumMenuItem);
end;
Grüße vom marabu