Dialog Menu Check

I'm trying to write my own version of Minesweep, just like the one that comes with windows. On the menu I want to put checks next to Beginner, Intermediate, Expert, or Custom. I tried using ON_UPDATE_COMMAND_UI; pCmdUI->SetCheck(TRUE); but that doesn't work, all the menu items stay unchecked. I even tried getting a pointer to the sub menu and calling subMenu->CheckItem(ID_FILE_BEGIN, TRUE) (or whatever the function is called), and that didn't work either. Is there a step I'm missing or is there a different way to do this for dialog based apps; I've used the exact same method for window apps before and it works fine.


  • [b][red]This message was edited by kuphryn at 2002-10-13 16:27:48[/red][/b][hr]
    Override OnInitMenuPopup() and add this code.

    void CWordCountDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
    // Enables this dialog based app to handle ON_UPDATE_COMMAND_UI messages.
    // For updating items in menu.
    CDialog::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
    CCmdUI cmdUI;
    cmdUI.m_pMenu = pPopupMenu;
    cmdUI.m_nIndexMax = pPopupMenu->GetMenuItemCount();

    for (cmdUI.m_nIndex = 0; cmdUI.m_nIndex < cmdUI.m_nIndexMax; cmdUI.m_nIndex++)
    cmdUI.m_nID = pPopupMenu->GetMenuItemID(cmdUI.m_nIndex);

    if (cmdUI.m_nID == 0)

    cmdUI.DoUpdate(this, FALSE);

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion