Right justifying menu items
To justify menu items on the right side of the main menu bar, you must do like this:
{It will right justify all menu items to the right of the one selected}
procedure SetJustify(Menu: TMenu; MenuItem: TMenuItem; Justify: Byte);
{$IFDEF WIN32}
var
ItemInfo: TMenuItemInfo;
Buffer: array[0..80] of Char;
{$ENDIF}
begin
{$IFDEF VER80}
MenuItem.Caption := Chr(8) + MenuItem.Caption;
{$ELSE}
ItemInfo.cbSize := SizeOf(TMenuItemInfo);
ItemInfo.fMask := MIIM_TYPE;
ItemInfo.dwTypeData := Buffer;
ItemInfo.cch := SizeOf(Buffer);
GetMenuItemInfo(Menu.Handle, MenuItem.Command, False, ItemInfo);
if Justify = 1 then
ItemInfo.fType := ItemInfo.fType or MFT_RIGHTJUSTIFY;
SetMenuItemInfo(Menu.Handle, MenuItem.Command, False, ItemInfo);
{$ENDIF}
end;

0 Comments:
Post a Comment
<< Home