Notice Of Closure

Please note that this website is due to close down on 15th June 2020.

In the interim I will try to move as much content as possible over to my GitHub account. Thanks to everyone who has supported the site over the years.

» Help

Right align main menu items


In most applications all (top level) menu items are aligned at the left side of the menu bar. I'm sure you have seen applications with at least one item aligned on the right side. In most cases this was the "Help" menu item.

  1. Add a TMainMenu component to a form (Form1)
  2. Add several (top level) menu items (with sub items)
  3. Have a menu item named "HelpMenuItem"
  4. Use the code below in the form's OnCreate event.
procedure TForm1.FormCreate(Sender: TObject) ;
  mii: TMenuItemInfo;
  MainMenu: hMenu;
  Buffer: array[0..79] of Char;
  MainMenu := Self.Menu.Handle;

  //GET Help Menu Item Info
  mii.cbSize := SizeOf(mii) ;
  mii.fMask := MIIM_TYPE;
  mii.dwTypeData := Buffer;
  mii.cch := SizeOf(Buffer) ;
  GetMenuItemInfo(MainMenu, HelpMenuItem.Command, false, mii) ;

  //SET Help Menu Item Info
  mii.fType := mii.fType or MFT_RIGHTJUSTIFY;
  SetMenuItemInfo(MainMenu, HelpMenuItem.Command, false, mii) ;
Author: Shlomo Abuisak
Contributor: Shlomo Abuisak
Added: 2009-11-05
Last updated: 2009-11-05

« Return to contents »