POPUP "&File"
        MENUITEM "E&xit",                IDM_EXIT
    POPUP "&Help"
        MENUITEM "&About ...",           IDM_ABOUT

This is an example of a part of the default Foo.rc file distributed with VisualC++ 2010(Express), this is how this section of code was shipped. I'm interested in knowing why Exit is expressed in the code as "E&xit" and all the other elements are the 'right way around'. Obviously, it's a string, it means nothing in terms of code, which leads me onto my next point. Why do these strings require "&" at all? Removing them has no effect, as I assumed, so why are they there in the first place?

As for any oddity in any language, it's either there, 'for historical or hysterical reasons'. Or it's not an oddity, which is it?

I recognise that this is not really a C++ question, more of a win32 API question.

Edited 4 Years Ago by Alochai

The ampersand actually marks the character which is to be used as the hotkey; if you look at the menu as it actually is rendered, you'll see that those letters all are underscored. In the case of 'Exit', the 'x' is the hotkey character (that is to say, if you hit ALT-X, it would cause the program to exit), so the ampersand is directly before it. It only seems out of place because all of the other items have hotkeys with the first letter of the word, but this does not need to be the case, as you can see.

As for why 'x' is used for exit rather than 'E', it is because, according to the Windows style standard, Alt-E is used as the hotkey for the Edit menu, even if it isn't present in the application.

Edited 4 Years Ago by Schol-R-LEA

Thanks! I can't help but feel that I should have recognised that, admittedly I rarely use shortcuts at all. If only google had supplied the answer before I made myself look like a tool, again.

This question has already been answered. Start a new discussion instead.