Microsoft KB Archive/125675

-

{| The information in this article applies to: Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows 95 version 4.0
 * width="100%"|

SUMMARY
In Windows 95, right-justify (right-align) a menu item by using the MFT_RIGHTJUSTIFY type in MENUITEMINFOSTRUCTURE.

MORE INFORMATION
There is a new menu type in Windows 95, MFT_RIGHTJUSTIFY type, which you can use to right justify a menu item. The Windows version 3.1 method of prefixing the string with "\a" or "\b" will no longer work.

To right justify a menu item in Windows 95:


 * 1) Get the menu handle of the original menu.
 * 2) Get the original menu item information stored in the MENUITEMINFO structure.
 * 3) Change the menu item type to include MFT_RIGHTJUSTIFY by or'ing the original value with MFT_RIGHTJUSTIFY.
 * 4) Set the new menu item information.

For example, to create a right-justified menu item, add the following code to WM_CREATE: HMENU hMenu; MENUITEMINFO mii; char szBuffer [80];

hMenu = GetMenu (hwnd);

// Get the original value of mii.fType first // and OR that with MFT_RIGHTJUSTIFY mii.cbSize = sizeof (MENUITEMINFO); mii.fMask = MIIM_TYPE; mii.dwTypeData= szBuffer; mii.cch  = sizeof (szBuffer);

GetMenuItemInfo(hMenu, 1, TRUE, &mii);

// OR in MFT_RIGHTJUSTIFY type mii.fMask = MIIM_TYPE; mii.fType = mii.fType | MFT_RIGHTJUSTIFY;

// Right justify the specified item and all those following it  SetMenuItemInfo(hMenu, 1, TRUE,   &mii);

return 0;