简体   繁体   English

在.rc文件中的Ampersand(&)的含义

[英]Meaning of Ampersand(&), in .rc files

When coding Windows Applications using WIN32 on Windows, to non-dynamically load resources, one must load a *.rc file, which contains resource definition statements meant for defining common features in apps, such as buttons and menus. 在Windows上使用WIN32对Windows应用程序进行编码时,要非动态加载资源,必须加载*.rc文件,该文件包含用于定义应用程序中常见功能的资源定义语句,如按钮和菜单。 While reading a tutorial for the WIN32 API, from WinProg , I came across this code that confused me: 在从WinProg阅读WIN32 API的教程时,我遇到了这个令我困惑的代码:

IDR_MYMENU MENU
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "E&xit", ID_FILE_EXIT
    END

    POPUP "&Stuff"
    BEGIN
        MENUITEM "&Go", ID_STUFF_GO
        MENUITEM "G&o somewhere else", 0, GRAYED
    END
END

Looking at the code above, it is understandable what the function is. 看看上面的代码,可以理解这个函数是什么。 I myself understand what the code is doing in the .rc file, but the one thing that confused me was the ampersands,( & ), that are visible in the middle of the strings, such as "G&o somewhere else" (Between G and O), or "E&xit" (Between E and X). 我自己理解代码在.rc文件中做了什么,但让我感到困惑的一件事就是字符串中间可见的&符号( & ),例如"G&o somewhere else""G&o somewhere else"之间) O),或"E&xit" (E和X之间)。 My specific questions to Stack Overflow are: What do the ampersands mean in the .rc files? 我对Stack Overflow的具体问题是:&符号在.rc文件中的含义是什么? Where do I have to put them when coding apps? 在编写应用程序时,我必须在哪里放置它们? I already looked in the MSDN link describing the function of the files, but I couldn't get an answer in the docs. 我已经查看了描述文件功能的MSDN链接,但我无法在文档中得到答案。

Those & s are only for menus, and they define the "menu access keys", or "mnemonics" , also called accelerators and shortcuts by others. 这些& s为仅适用于菜单,他们定义“菜单快捷键”或“记忆术”被别人,也被称为加速器和快捷方式。 And yes, the terminology is overloaded and confusing. 是的,术语过载且令人困惑。

More reading: why you probably didn't realize these were there . 更多阅读: 为什么你可能没有意识到这些是存在的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM