How to Right-Justify Menu Items in Windows 95

Last reviewed: September 29, 1995
Article ID: Q125675
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows 95 version 4.0
    

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;

REFERENCES

For additional information on right justifying menus in Windows 3.1, please see the following article in the Microsoft Knowledge Base:

ARTICLE-ID: Q67063

TITLE     : Inserting Right Justified Text in a Menu in Windows


Additional reference words: 4.00 alignment align
KBCategory: kbui
KBSubcategory: UsrMen


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.