Enabling menu items

This is a discussion on Enabling menu items within the Windows Programming forums, part of the Platform Specific Boards category; When I enable previously disabled/grayed menu item (I mean an item in the MAIN MENU BAR only) by calling EnableMenuItem, ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    12

    Unhappy Enabling menu items

    When I enable previously disabled/grayed menu item (I mean an item in the MAIN MENU BAR only) by calling EnableMenuItem, it will be still grayed, though enabled! Windows won't PAINT IT BLACK! I can force Windows to repaint the main menu bar by SetMenu(GetMenu(hwnd)) . Does anybody know a better solution?

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    Enabling Menu Items

    You can try this.....(using MFC) ON_UPDATE_COMMAND_UI

    Code:
    //////////////////////////////////////////////////////////
    ///in MainFrm.h
    
    afx_msg void OnUpdateMyItem(CCmdUI* pCmdUI);
    
    /////////////************************
    ////////////in MainFrm.cpp
    
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    
          .....OTHER MSGS
         ON_UPDATE_COMMAND_UI(IDC_MYITEM, OnUpdateMyItem)
         .......OTHER MSGS
    
    END_MESSAGE_MAP()
    
    ...other funcitons
    
    
    void CMainFrame::OnUpdateMyItem(CCmdUI * pCmdUI)
    {
        //** Specific to the item updated
        //** each menu item requires its own OnUpdate.. function
        //** see also ON_UPDATE_COMMAND_UI_RANGE   
        pCmdUI->Enable( bMyCondition == TRUE ); 
    }
    zMan

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Try

    DrawMenuBar()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  3. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  4. enabling menu items
    By lambs4 in forum Windows Programming
    Replies: 7
    Last Post: 01-26-2003, 06:17 PM
  5. enabling and disabling menu items
    By poopy_pants2 in forum Windows Programming
    Replies: 2
    Last Post: 08-21-2002, 05:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21