Win32 menu text alignment

Started by
4 comments, last by Kippesoep 15 years, 10 months ago
I am adding menu text to my drop down menus so that users will know which quick keys to use. If you need an example of what I am trying to accomplish it is basically the Ctrl+O, Ctrl+N, Ctrl+S that you would find under the "File" menu of Internet Explorer or pretty much any "File" menu of any program. I am having a problem with alignment of the text. I am currently creating the menu structure via a resource file. However, the CTRL+ text is several pixels off on each line and it makes my menus look shabby. How can I go about aligning my menu text to match horizonally? Here is my menu setup.

IDC_SPRITEVIEWER MENU
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "&Open...   CTRL+O",                IDM_OPEN
        MENUITEM "&Close       CTRL+C",               IDM_CLOSE, GRAYED
        MENUITEM "E&xit          CTRL+X",             IDM_EXIT
    END
    POPUP "&Help"
    BEGIN
        MENUITEM "&About...",           IDM_ABOUT
    END
END

Advertisement
Maybe you could try adding a \a inside the text's? According to MSDN, the \a aligns the rest of the text to the right.

EDIT: like this:
IDC_SPRITEVIEWER MENUBEGIN    POPUP "&File"    BEGIN        MENUITEM "&Open...\aCTRL+O",                IDM_OPEN        MENUITEM "&Close\aCTRL+C",               IDM_CLOSE, GRAYED        MENUITEM "E&xit\aCTRL+X",             IDM_EXIT    END    POPUP "&Help"    BEGIN        MENUITEM "&About...",           IDM_ABOUT    ENDEND
\a aligns everything to the right. Use \t instead.
Kippesoep
Quote:Original post by Kippesoep
\a aligns everything to the right. Use \t instead.


From MSDN:
Quote:
The \a character aligns all text that follows it flush right to the menu bar or pop-up menu.

So, no, it doesn't align everything (unless you of course start the string with \a...)
Worked perfect, thanks!
I meant the accelerator text itself is actually right-aligned, which it shouldn't be. The accelerators should be left aligned, but to the right.
Kippesoep

This topic is closed to new replies.

Advertisement