«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» 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 »