Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips


#60: How can I align a menu item to right?

The Microsoft GUI guide not allow to change the align of some menu item but from DOS-time personally I like to align a Help menu item to right.

But in some applications from Microsoft I saw the right-aligned menu item too:) If you want to align the item in own application, you can call the ModifyMenu function with MF_POPUP or MF_HELP flag.

View example:

uses 
  Windows; 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
  ModifyMenu(yourMainMenu.Handle, 0, MF_BYPOSITION or MF_POPUP or MF_HELP, yourMenuItem.Handle, 'yourCaption'); 
end; 

The altrenative method:

var
  MMI: TMenuItemInfo;
  MyMenu: hMenu;
  Buffer: array[0..79] of Char;
begin
  MyMenu := GetMenu(Handle);
  // Handle is the handle of the form that contains the menu
  MMI.cbSize := SizeOf(MMI);
  MMI.fMask := MIIM_TYPE;
  MMI.dwTypeData := Buffer;
  MMI.cch := SizeOf(Buffer);
  GetMenuItemInfo(MyMenu, 1, True, MMI);
  // (..., 1, True, ...)  means that help is the second menu item.
  MMI.fType := MMI.fType or MFT_RIGHTJUSTIFY;
  SetMenuItemInfo(MyMenu, 1, True, MMI);
end;

PS: I'm not sure that this code will work on each Windows platform.


Published: January 18, 2000

See also
 
Excel Reader (dll)
ABA Spreadsheet Convert
Paradox Viewer
SMReport
SMImport suite
DBLoad
Viewer for TNEF-files (winmail.dat)
MAPIMail
dBase Viewer
ABA Document Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising