简体   繁体   中英

Changing MFC Menu Popup text in C++

I'm writing an MFC C++ application. I have the following menu in my main window. I am trying to change the text via C++ for the FIRST POPUP item entitled "&File". How can I do this?

IDR_ISOPROTYPE MENU
BEGIN
    POPUP "&File"
    BEGIN
        POPUP "second"
        BEGIN
            MENUITEM "third",                   ID_33280
        END
        MENUITEM "&Open...\tCtrl+O",            ID_FILE_OPEN
        MENUITEM "Rever&t",                     ID_FILE_REVERT

First, get the handle to the menu , like

HMENU hMenu = GetMenu(AfxGetApp()->m_pMainWnd->GetSafeHwnd());

Then, call the ModifyMenu function

ModifyMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, 0, "New&File");

If you need to modify the text of a submenu, you can still use the ModifyMenu function, but using a submenu handle

HMENU hSubMenu = GetSubMenu(hMenu, 1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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