Hi all,
In my Delphi XE application I have a main menu and some of the menu items have a sub menu.
The sub menus that are created at design time are aligned to the parent menu item correctly, but the ones I create in code always have a gap between the menu item and the sub menu.
Is there some other property of the sub menu items I need to set apart from owner and parent to get them to display correctly?
Current code:
procedure TfmMain.UpdateHelpMenu;
var
MI: TMenuItem;
x: Integer;
begin
while mnShortcutList.Count > 0 do
mnShortcutList.Delete(0);
for x := 0 to Prefs.Shortcuts.Count-1 do
if Prefs.Shortcuts[x].Key <> 0 then
begin
MI := TMenuItem.Create(mnShortcutList);
MI.Caption := Prefs.Shortcuts[x].HelpCaption;
MI.ShortCut := Prefs.Shortcuts[x].Shortcut;
MI.ImageIndex := 79;
mnShortcutList.Add(MI);
end;
end;
Yes, Windows 10. No difference if the image is not set.
I did find that I’m using the TAdvMainMenu from TMS and that’s where the issue is.
If I use a plain TMainMenu it draws correctly.
Something else I noticed with the TMS menu is that the drawing style of the design time sub menus are correct, but the run time versions look plain by comparison.
I checked the form code and the TMS menu is using TMenuItem for the design time objects so not sure why they behave differently at run time.
It was interesting in that the TAdvMainMenu (which descends from TMainMenu) actually introduced the BeginUpdate/EndUpdate methods. They don’t exist on the ancestor TMainMenu, so they’re easily missed by those used to the standard menu components.