Jump to content
David Duffy

Run Time Sub Menu Gap

Recommended Posts

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?
 

Submenu Gap.png

Share this post


Link to post

It would help if you showed the code that you tried.

 

You could also create one sub-menu at design-time, then look at the text view of the .dfm to see all the properties it sets to give you a clue.

Share this post


Link to post

Here's the 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
  begin
    MI := TMenuItem.Create(mnShortcutList);
    MI.Caption := Prefs.Shortcuts[x].HelpCaption;
    MI.ShortCut := Prefs.Shortcuts[x].Shortcut;
    mnShortcutList.Add(MI);
  end;
end;

 

Share this post


Link to post

Ah! TAdvMainMenu! That explains it. I was thinking that didn't look like the regular TMainMenu. My attempt to replicate it also failed.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×