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.
Here's how to align a form's Help menu item (for example) on the right side of the menu bar, in Delphi applications.
- Add a TMainMenu component to a form (Form1)
- Add several (top level) menu items (with sub items)
- Have a menu item named "HelpMenuItem"
- Use the code below in the form's OnCreate event.
- Run the project ... note that the "Help" item is aligned on the right side of the menu bar.
procedure TForm1.FormCreate(Sender: TObject) ;
var
mii: TMenuItemInfo;
MainMenu: hMenu;
Buffer: array[0..79] of Char;
begin
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) ;
end;
Delphi tips navigator:
» How to Change the Colors of the TProgressBar
« ing Custom Code Templates in Delphi 2006


