Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Menus

Menus

Scheduled Pinned Locked Moved Mobile
questionlearninghelp
24 Posts 3 Posters 93 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • realJSOPR realJSOP

    I want to disable all of the items in commandbar, but it doesn't seem to be working. Here's what I'm doing:

    // make sure we have or can get a pointer to the menu
    if (m\_menuBarPtr)
    {
    	m\_menuBarPtr = GetMenu();
    }
    // if we have a pointer to the menu, we can disable everything (theoretically)
    if (m\_menuBarPtr)
    {
    	MessageBeep(0);
    	// Since these are all top-level menu items, they don't have ID's, so we 
    	// have to disable according to their relative positions in the menu.
    	// Further, the MF\_DISABLED flag is not supported in CE, so all we 
    	// can/should do is gray out the menu item, and that should do the trick.
    	UINT menuStyle = MF\_BYPOSITION | ((m\_currentBar == 0) ?  MF\_ENABLED : MF\_GRAYED);
    	m\_menuBarPtr->EnableMenuItem(0, menuStyle);
    	m\_menuBarPtr->EnableMenuItem(1, menuStyle);
    	m\_menuBarPtr->EnableMenuItem(2, menuStyle);
    	m\_menuBarPtr->EnableMenuItem(3, menuStyle);
    }
    

    I've also tried setting ther m_menuBarPtr by using the return value of the CCeCommandBar::InsertMenu() function. If you'll notice the

    MessageBeep(0);

    call, I hear that beep when this code is encountered, indicating that I do indeed have a valid CMenu*, but the menu items are still active. According to the CE help, MF_DISABLED is not supported by CE (what an arbitrarily stupid fucking decision on Microsoft's part), so I can't use it (although I did try it just to make sure, and of course, my app wouldn't compile with it included in the code). Why does the interface stuff in CE suck so bad? Why is the documentation a complete waste of a CD? Why hasn't there been a decent book written for PPC2K2 development? BTW, I also added this line in the constructor to CMainFrame

    m\_bAutoMenuEnable = FALSE;
    

    :confused: ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

    A Offline
    A Offline
    Amit Dey
    wrote on last edited by
    #21

    Hi, In my app, I do not face any such problem. I have followed this thread, and am still not getting it. I'm compiling on evc3.0 PPC2000,but I think this should work with PPC2002 too. here's what I do to enable/disable menuitems and buttons on commandbars(new toolband). FOr every new item, I map UPDATE_COMMAND_UI(), where based on a variable I toggle Enable flag like: void CMainFrame::OnUpdateAddfiles(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here if(m_bAddFiles) { pCmdUI->Enable(TRUE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),TRUE); } else { pCmdUI->Enable(FALSE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),FALSE); } } BOOL CMainFrame::EnableMenuItem(LPCTSTR szParent,LPCTSTR szChild,BOOL bEnable) { CMenu *pMenu = GetMenu(); int pos = FindMenuItem(pMenu, szParent); if (pos == -1) return FALSE; CMenu* submenu = pMenu->GetSubMenu(pos); int nPos = FindMenuItem(submenu,szChild); if(nPos == -1) return FALSE; if(!bEnable) submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_GRAYED); else submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_ENABLED); return TRUE; } BOOL CMainFrame::EnableCommandBarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndCommandBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } BOOL CMainFrame::EnableToolbarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndToolBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } finally, whenever I set m_bAddFiles to TRUE, toolbar button gets enabled and viceversa. EnableCOmmandBarItem() and EnableToolbarItem() is what I tried too, but without ON_UPDATE_UI handlers, things don't happen. What do you think?

    Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
    PocketPC New menu Office addin

    realJSOPR 1 Reply Last reply
    0
    • J Joao Paulo Figueira

      John Simmons / outlaw programmer wrote: Why does the interface stuff in CE suck so bad? Well, it really is not what you think. The menu visual element is not a menu, but instead a toolbar button. If you want to disable them, you have to know their IDs, which start at 0xF000 (yes, I had to go to MFC's source again). So, to do what you want, here's a suggestion:

      //
      // Disable first button
      //
      m_wndCommandBar.SendMessage(TB_ENABLEBUTTON, 0xf000, MAKELONG(FALSE,0));

      //
      // Disable second button
      //
      m_wndCommandBar.SendMessage(TB_ENABLEBUTTON, 0xf001, MAKELONG(FALSE,0));

      Intuitive, right?

      A Offline
      A Offline
      Amit Dey
      wrote on last edited by
      #22

      Hi, In my app, I do not face any such problem. I have followed this thread, and am still not getting it. I'm compiling on evc3.0 PPC2000,but I think this should work with PPC2002 too. here's what I do to enable/disable menuitems and buttons on commandbars(new toolband). FOr every new item, I map UPDATE_COMMAND_UI(), where based on a variable I toggle Enable flag like: void CMainFrame::OnUpdateAddfiles(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here if(m_bAddFiles) { pCmdUI->Enable(TRUE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),TRUE); } else { pCmdUI->Enable(FALSE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),FALSE); } } BOOL CMainFrame::EnableMenuItem(LPCTSTR szParent,LPCTSTR szChild,BOOL bEnable) { CMenu *pMenu = GetMenu(); int pos = FindMenuItem(pMenu, szParent); if (pos == -1) return FALSE; CMenu* submenu = pMenu->GetSubMenu(pos); int nPos = FindMenuItem(submenu,szChild); if(nPos == -1) return FALSE; if(!bEnable) submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_GRAYED); else submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_ENABLED); return TRUE; } BOOL CMainFrame::EnableCommandBarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndCommandBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } BOOL CMainFrame::EnableToolbarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndToolBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } finally, whenever I set m_bAddFiles to TRUE, toolbar button gets enabled and viceversa. EnableCOmmandBarItem() and EnableToolbarItem() is what I tried too, but without ON_UPDATE_UI handlers, things don't happen. What do you think?

      Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
      PocketPC New menu Office addin

      J 1 Reply Last reply
      0
      • A Amit Dey

        Hi, In my app, I do not face any such problem. I have followed this thread, and am still not getting it. I'm compiling on evc3.0 PPC2000,but I think this should work with PPC2002 too. here's what I do to enable/disable menuitems and buttons on commandbars(new toolband). FOr every new item, I map UPDATE_COMMAND_UI(), where based on a variable I toggle Enable flag like: void CMainFrame::OnUpdateAddfiles(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here if(m_bAddFiles) { pCmdUI->Enable(TRUE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),TRUE); } else { pCmdUI->Enable(FALSE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),FALSE); } } BOOL CMainFrame::EnableMenuItem(LPCTSTR szParent,LPCTSTR szChild,BOOL bEnable) { CMenu *pMenu = GetMenu(); int pos = FindMenuItem(pMenu, szParent); if (pos == -1) return FALSE; CMenu* submenu = pMenu->GetSubMenu(pos); int nPos = FindMenuItem(submenu,szChild); if(nPos == -1) return FALSE; if(!bEnable) submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_GRAYED); else submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_ENABLED); return TRUE; } BOOL CMainFrame::EnableCommandBarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndCommandBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } BOOL CMainFrame::EnableToolbarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndToolBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } finally, whenever I set m_bAddFiles to TRUE, toolbar button gets enabled and viceversa. EnableCOmmandBarItem() and EnableToolbarItem() is what I tried too, but without ON_UPDATE_UI handlers, things don't happen. What do you think?

        Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
        PocketPC New menu Office addin

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #23

        Well, I tried *all* of that before posting my original message. You must not have read my final post entrirely. The toolbar buttons are *not* associated with *any* menu items. Because of this, you can't use the standard OnUpdate coding. You have to prop it up with extra coding. You're not the only one that said "it looks like it should work". You're right - it does *look* like it should work. ------- signature starts "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 Please review the Legal Disclaimer in my bio. ------- signature ends

        1 Reply Last reply
        0
        • A Amit Dey

          Hi, In my app, I do not face any such problem. I have followed this thread, and am still not getting it. I'm compiling on evc3.0 PPC2000,but I think this should work with PPC2002 too. here's what I do to enable/disable menuitems and buttons on commandbars(new toolband). FOr every new item, I map UPDATE_COMMAND_UI(), where based on a variable I toggle Enable flag like: void CMainFrame::OnUpdateAddfiles(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here if(m_bAddFiles) { pCmdUI->Enable(TRUE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),TRUE); } else { pCmdUI->Enable(FALSE); // EnableMenuItem(TEXT("Archive"),TEXT("Add Files"),FALSE); } } BOOL CMainFrame::EnableMenuItem(LPCTSTR szParent,LPCTSTR szChild,BOOL bEnable) { CMenu *pMenu = GetMenu(); int pos = FindMenuItem(pMenu, szParent); if (pos == -1) return FALSE; CMenu* submenu = pMenu->GetSubMenu(pos); int nPos = FindMenuItem(submenu,szChild); if(nPos == -1) return FALSE; if(!bEnable) submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_GRAYED); else submenu->EnableMenuItem(nPos,MF_BYPOSITION|MF_ENABLED); return TRUE; } BOOL CMainFrame::EnableCommandBarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndCommandBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } BOOL CMainFrame::EnableToolbarItem(UINT nID, BOOL bEnable) { CToolBarCtrl& pCtrl = m_wndToolBar.GetToolBarCtrl(); pCtrl.EnableButton(nID,bEnable); return TRUE; } finally, whenever I set m_bAddFiles to TRUE, toolbar button gets enabled and viceversa. EnableCOmmandBarItem() and EnableToolbarItem() is what I tried too, but without ON_UPDATE_UI handlers, things don't happen. What do you think?

          Hush,hush... thought I heard you call my name now. Kula Shaker. Amit Dey Latest articles at CP -
          PocketPC New menu Office addin

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #24

          Amit Dey wrote: I think this should work with PPC2002 too This might be the problem, Amit. Both me and John experienced the same problem on the PPC 2002, and this led me to write an article on the subject. Have a look at it here: Disabling top-level popup menus in the PocketPC 2002 [^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups