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

    João Paulo Figueira wrote: That was an obvious joke (forgot the smiley, though). As a matter of fact, if you want to do anything serious about UI development for the PPC 2002, you gotta read the MFC source. And for two reasons: 1) the eVC help sucks and 2) it is incomplete, at best. Yeah I know. :) João Paulo Figueira wrote: As for regular buttons, I think you need to access the underlying CToolBarCtrl object through GetToolBarCtrl(), just like I did in my last article on multiple toolbars. When you have a reference to that object, call EnableButton(nID, bEnable) where nID is the button ID and bEnable is the enabling / disabling BOOL. I already tried that, and I get the same behaviour as before (they disable for a split second, and then get re-enabled somehow. I guess I'll keep pounding on it, but if you happen to run across anything, don't be shy about sharing it. :) ------- 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

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

    John Simmons / outlaw programmer wrote: I already tried that, and I get the same behaviour as before (they disable for a split second, and then get re-enabled somehow. Are you using this technique with OnUpdate... handlers? They should be mutually exclusive. John Simmons / outlaw programmer wrote: I guess I'll keep pounding on it, but if you happen to run across anything, don't be shy about sharing it. You bet! :)

    realJSOPR 1 Reply Last reply
    0
    • J Joao Paulo Figueira

      John Simmons / outlaw programmer wrote: I already tried that, and I get the same behaviour as before (they disable for a split second, and then get re-enabled somehow. Are you using this technique with OnUpdate... handlers? They should be mutually exclusive. John Simmons / outlaw programmer wrote: I guess I'll keep pounding on it, but if you happen to run across anything, don't be shy about sharing it. You bet! :)

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

      If I put that code into OnUpdate, the buttons appear to blink. ------- 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

      J 1 Reply Last reply
      0
      • realJSOPR realJSOP

        If I put that code into OnUpdate, the buttons appear to blink. ------- 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

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

        I'm actually suggesting not using OnUpdate. Try updating the buttons without these handlers.

        realJSOPR 2 Replies Last reply
        0
        • J Joao Paulo Figueira

          I'm actually suggesting not using OnUpdate. Try updating the buttons without these handlers.

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

          I only tried OnUpdate after nothing else worked. :) ------- 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
          • J Joao Paulo Figueira

            I'm actually suggesting not using OnUpdate. Try updating the buttons without these handlers.

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

            I'm starting a new replay layer for this topic. :) ------- 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
            • 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

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

              Alrightie... More information: I decided to see what would happen if I removed the toolbar from the commandbar, leaving just the menu. When I disabled all of the menu items, the "Config" menu item (the last one in the menu) was no longer truncated when it was disabled. This leads me to believe there's a bug somewhere in the MFC CCeCommandBar code. For what it's worth, I still haven't figured out why the buttons in the toolbar don't stay disabled, but I think it might be because I'm not telling the commandbar they're disabled, so it might be re-enabling them on it's own. ------- 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

              J 1 Reply Last reply
              0
              • realJSOPR realJSOP

                Alrightie... More information: I decided to see what would happen if I removed the toolbar from the commandbar, leaving just the menu. When I disabled all of the menu items, the "Config" menu item (the last one in the menu) was no longer truncated when it was disabled. This leads me to believe there's a bug somewhere in the MFC CCeCommandBar code. For what it's worth, I still haven't figured out why the buttons in the toolbar don't stay disabled, but I think it might be because I'm not telling the commandbar they're disabled, so it might be re-enabling them on it's own. ------- 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

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

                John Simmons / outlaw programmer wrote: This leads me to believe there's a bug somewhere in the MFC CCeCommandBar code. You mean: just one bug? Oh, dear... ;) John Simmons / outlaw programmer wrote: For what it's worth, I still haven't figured out why the buttons in the toolbar don't stay disabled, but I think it might be because I'm not telling the commandbar they're disabled, so it might be re-enabling them on it's own. Is it possible that I take a look at you code? We could try to solve this in parallel... :)

                realJSOPR 1 Reply Last reply
                0
                • J Joao Paulo Figueira

                  John Simmons / outlaw programmer wrote: This leads me to believe there's a bug somewhere in the MFC CCeCommandBar code. You mean: just one bug? Oh, dear... ;) John Simmons / outlaw programmer wrote: For what it's worth, I still haven't figured out why the buttons in the toolbar don't stay disabled, but I think it might be because I'm not telling the commandbar they're disabled, so it might be re-enabling them on it's own. Is it possible that I take a look at you code? We could try to solve this in parallel... :)

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

                  Here's the applicable stuff.

                  CCeCommandBar m_wndCommandBar;
                  CToolBar m_barProcess;
                  CToolBar m_barAnnotate;
                  CToolBar m_barZoom;
                  CToolBar m_barVideo;
                  CToolBar m_barAVI;
                  UINT m_currentBar;

                  //----------------------------------------------------------------------
                  //----------------------------------------------------------------------
                  int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
                  {
                  m_menuBarPtr = NULL;
                  m_currentBar = 0;
                  if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
                  {
                  return -1;
                  }
                  m_wndCommandBar.m_bShowSharedNewButton = FALSE;
                  m_ToolTipsTable[0] = MakeString(IDS_NEW);
                  m_ToolTipsTable[1] = MakeString(IDS_FILE);
                  m_ToolTipsTable[2] = MakeString(IDS_MHELP);
                  m_ToolTipsTable[3] = MakeString(IDS_CUT);
                  m_ToolTipsTable[4] = MakeString(IDS_COPY);
                  m_ToolTipsTable[5] = MakeString(IDS_PASTE);
                  m_ToolTipsTable[6] = MakeString(IDS_ABOUT);

                  if (!m\_wndCommandBar.Create(this))
                  {
                  	TRACE(\_T("Failed to create CommandBar\\n"));
                  	return -1;      // fail to create
                  }
                  m\_menuBarPtr = m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME);
                  if (!m\_menuBarPtr ||
                  	!m\_wndCommandBar.InsertSeparator() ||
                          !m\_wndCommandBar.AddAdornments() ||
                          !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
                  	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable)))
                  {
                  	TRACE(\_T("Failed to create CommandBar\\n"));
                  	return -1;      // fail to create
                  }
                  
                  m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
                  
                  if (!CreateOtherCommandBars())
                  {
                  	TRACE(\_T("Failed to create one or more supplementary CommandBars\\n"));
                  	return -1;      // fail to create
                  }
                  
                  //BOOL bResult = SHFullScreen(GetSafeHwnd(), SHFS\_HIDESIPBUTTON);
                  
                  return 0;
                  

                  }

                  //----------------------------------------------------------------------
                  //----------------------------------------------------------------------
                  BOOL CMainFrame::CreateOtherCommandBars()
                  {
                  m_currentBar = IDR_MAINFRAME;
                  UINT barStyle = WS_CHILD | CBRS_BOTTOM | CBRS_BORDER_TOP; // | CBRS_TOOLTIPS | CBRS_FLYBY;
                  CRect rcBorder(0, 1, 0, 0);

                  if (!m\_barProcess.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+1) ||
                      !m\_barProcess.LoadToolBar(IDR\_PROCESSBAR))
                  {
                  	TRACE(\_T("Failed to create process toolbar\\n"));
                  	return FALSE;
                  }
                  if (!m\_barAnnotate.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+2) ||
                      !m\_barAnnotate.LoadToolBar(IDR\_ANNOTATEBAR))
                  {
                  	TRACE(\_T("
                  
                  J 4 Replies Last reply
                  0
                  • realJSOPR realJSOP

                    Here's the applicable stuff.

                    CCeCommandBar m_wndCommandBar;
                    CToolBar m_barProcess;
                    CToolBar m_barAnnotate;
                    CToolBar m_barZoom;
                    CToolBar m_barVideo;
                    CToolBar m_barAVI;
                    UINT m_currentBar;

                    //----------------------------------------------------------------------
                    //----------------------------------------------------------------------
                    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
                    {
                    m_menuBarPtr = NULL;
                    m_currentBar = 0;
                    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
                    {
                    return -1;
                    }
                    m_wndCommandBar.m_bShowSharedNewButton = FALSE;
                    m_ToolTipsTable[0] = MakeString(IDS_NEW);
                    m_ToolTipsTable[1] = MakeString(IDS_FILE);
                    m_ToolTipsTable[2] = MakeString(IDS_MHELP);
                    m_ToolTipsTable[3] = MakeString(IDS_CUT);
                    m_ToolTipsTable[4] = MakeString(IDS_COPY);
                    m_ToolTipsTable[5] = MakeString(IDS_PASTE);
                    m_ToolTipsTable[6] = MakeString(IDS_ABOUT);

                    if (!m\_wndCommandBar.Create(this))
                    {
                    	TRACE(\_T("Failed to create CommandBar\\n"));
                    	return -1;      // fail to create
                    }
                    m\_menuBarPtr = m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME);
                    if (!m\_menuBarPtr ||
                    	!m\_wndCommandBar.InsertSeparator() ||
                            !m\_wndCommandBar.AddAdornments() ||
                            !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
                    	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable)))
                    {
                    	TRACE(\_T("Failed to create CommandBar\\n"));
                    	return -1;      // fail to create
                    }
                    
                    m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
                    
                    if (!CreateOtherCommandBars())
                    {
                    	TRACE(\_T("Failed to create one or more supplementary CommandBars\\n"));
                    	return -1;      // fail to create
                    }
                    
                    //BOOL bResult = SHFullScreen(GetSafeHwnd(), SHFS\_HIDESIPBUTTON);
                    
                    return 0;
                    

                    }

                    //----------------------------------------------------------------------
                    //----------------------------------------------------------------------
                    BOOL CMainFrame::CreateOtherCommandBars()
                    {
                    m_currentBar = IDR_MAINFRAME;
                    UINT barStyle = WS_CHILD | CBRS_BOTTOM | CBRS_BORDER_TOP; // | CBRS_TOOLTIPS | CBRS_FLYBY;
                    CRect rcBorder(0, 1, 0, 0);

                    if (!m\_barProcess.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+1) ||
                        !m\_barProcess.LoadToolBar(IDR\_PROCESSBAR))
                    {
                    	TRACE(\_T("Failed to create process toolbar\\n"));
                    	return FALSE;
                    }
                    if (!m\_barAnnotate.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+2) ||
                        !m\_barAnnotate.LoadToolBar(IDR\_ANNOTATEBAR))
                    {
                    	TRACE(\_T("
                    
                    J Offline
                    J Offline
                    Joao Paulo Figueira
                    wrote on last edited by
                    #14

                    Unless I'm really missing something here, the code should work. You have removed the OnUpdate handlers, right? :eek:

                    realJSOPR 1 Reply Last reply
                    0
                    • J Joao Paulo Figueira

                      Unless I'm really missing something here, the code should work. You have removed the OnUpdate handlers, right? :eek:

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

                      Right. ------- 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
                      • realJSOPR realJSOP

                        Here's the applicable stuff.

                        CCeCommandBar m_wndCommandBar;
                        CToolBar m_barProcess;
                        CToolBar m_barAnnotate;
                        CToolBar m_barZoom;
                        CToolBar m_barVideo;
                        CToolBar m_barAVI;
                        UINT m_currentBar;

                        //----------------------------------------------------------------------
                        //----------------------------------------------------------------------
                        int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
                        {
                        m_menuBarPtr = NULL;
                        m_currentBar = 0;
                        if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
                        {
                        return -1;
                        }
                        m_wndCommandBar.m_bShowSharedNewButton = FALSE;
                        m_ToolTipsTable[0] = MakeString(IDS_NEW);
                        m_ToolTipsTable[1] = MakeString(IDS_FILE);
                        m_ToolTipsTable[2] = MakeString(IDS_MHELP);
                        m_ToolTipsTable[3] = MakeString(IDS_CUT);
                        m_ToolTipsTable[4] = MakeString(IDS_COPY);
                        m_ToolTipsTable[5] = MakeString(IDS_PASTE);
                        m_ToolTipsTable[6] = MakeString(IDS_ABOUT);

                        if (!m\_wndCommandBar.Create(this))
                        {
                        	TRACE(\_T("Failed to create CommandBar\\n"));
                        	return -1;      // fail to create
                        }
                        m\_menuBarPtr = m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME);
                        if (!m\_menuBarPtr ||
                        	!m\_wndCommandBar.InsertSeparator() ||
                                !m\_wndCommandBar.AddAdornments() ||
                                !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
                        	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable)))
                        {
                        	TRACE(\_T("Failed to create CommandBar\\n"));
                        	return -1;      // fail to create
                        }
                        
                        m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
                        
                        if (!CreateOtherCommandBars())
                        {
                        	TRACE(\_T("Failed to create one or more supplementary CommandBars\\n"));
                        	return -1;      // fail to create
                        }
                        
                        //BOOL bResult = SHFullScreen(GetSafeHwnd(), SHFS\_HIDESIPBUTTON);
                        
                        return 0;
                        

                        }

                        //----------------------------------------------------------------------
                        //----------------------------------------------------------------------
                        BOOL CMainFrame::CreateOtherCommandBars()
                        {
                        m_currentBar = IDR_MAINFRAME;
                        UINT barStyle = WS_CHILD | CBRS_BOTTOM | CBRS_BORDER_TOP; // | CBRS_TOOLTIPS | CBRS_FLYBY;
                        CRect rcBorder(0, 1, 0, 0);

                        if (!m\_barProcess.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+1) ||
                            !m\_barProcess.LoadToolBar(IDR\_PROCESSBAR))
                        {
                        	TRACE(\_T("Failed to create process toolbar\\n"));
                        	return FALSE;
                        }
                        if (!m\_barAnnotate.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+2) ||
                            !m\_barAnnotate.LoadToolBar(IDR\_ANNOTATEBAR))
                        {
                        	TRACE(\_T("
                        
                        J Offline
                        J Offline
                        Joao Paulo Figueira
                        wrote on last edited by
                        #16

                        I'm experiencing the same problem with my code. Apparently, there is some bug int the CCeCommandBar code because when I disable the menu "buttons", I also get the same "clipping" problem. I'll check it out and get back to you.

                        1 Reply Last reply
                        0
                        • realJSOPR realJSOP

                          Here's the applicable stuff.

                          CCeCommandBar m_wndCommandBar;
                          CToolBar m_barProcess;
                          CToolBar m_barAnnotate;
                          CToolBar m_barZoom;
                          CToolBar m_barVideo;
                          CToolBar m_barAVI;
                          UINT m_currentBar;

                          //----------------------------------------------------------------------
                          //----------------------------------------------------------------------
                          int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
                          {
                          m_menuBarPtr = NULL;
                          m_currentBar = 0;
                          if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
                          {
                          return -1;
                          }
                          m_wndCommandBar.m_bShowSharedNewButton = FALSE;
                          m_ToolTipsTable[0] = MakeString(IDS_NEW);
                          m_ToolTipsTable[1] = MakeString(IDS_FILE);
                          m_ToolTipsTable[2] = MakeString(IDS_MHELP);
                          m_ToolTipsTable[3] = MakeString(IDS_CUT);
                          m_ToolTipsTable[4] = MakeString(IDS_COPY);
                          m_ToolTipsTable[5] = MakeString(IDS_PASTE);
                          m_ToolTipsTable[6] = MakeString(IDS_ABOUT);

                          if (!m\_wndCommandBar.Create(this))
                          {
                          	TRACE(\_T("Failed to create CommandBar\\n"));
                          	return -1;      // fail to create
                          }
                          m\_menuBarPtr = m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME);
                          if (!m\_menuBarPtr ||
                          	!m\_wndCommandBar.InsertSeparator() ||
                                  !m\_wndCommandBar.AddAdornments() ||
                                  !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
                          	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable)))
                          {
                          	TRACE(\_T("Failed to create CommandBar\\n"));
                          	return -1;      // fail to create
                          }
                          
                          m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
                          
                          if (!CreateOtherCommandBars())
                          {
                          	TRACE(\_T("Failed to create one or more supplementary CommandBars\\n"));
                          	return -1;      // fail to create
                          }
                          
                          //BOOL bResult = SHFullScreen(GetSafeHwnd(), SHFS\_HIDESIPBUTTON);
                          
                          return 0;
                          

                          }

                          //----------------------------------------------------------------------
                          //----------------------------------------------------------------------
                          BOOL CMainFrame::CreateOtherCommandBars()
                          {
                          m_currentBar = IDR_MAINFRAME;
                          UINT barStyle = WS_CHILD | CBRS_BOTTOM | CBRS_BORDER_TOP; // | CBRS_TOOLTIPS | CBRS_FLYBY;
                          CRect rcBorder(0, 1, 0, 0);

                          if (!m\_barProcess.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+1) ||
                              !m\_barProcess.LoadToolBar(IDR\_PROCESSBAR))
                          {
                          	TRACE(\_T("Failed to create process toolbar\\n"));
                          	return FALSE;
                          }
                          if (!m\_barAnnotate.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+2) ||
                              !m\_barAnnotate.LoadToolBar(IDR\_ANNOTATEBAR))
                          {
                          	TRACE(\_T("
                          
                          J Offline
                          J Offline
                          Joao Paulo Figueira
                          wrote on last edited by
                          #17

                          I have it! Believe-me: it's hairy. :eek: If you didn't like PPC2K2 UI development, I'm giving you yet another reason... ;P I'm thinking about posting this change as a code update for the multi bar article. When it's ready, I'll let you know. ;)

                          1 Reply Last reply
                          0
                          • realJSOPR realJSOP

                            Here's the applicable stuff.

                            CCeCommandBar m_wndCommandBar;
                            CToolBar m_barProcess;
                            CToolBar m_barAnnotate;
                            CToolBar m_barZoom;
                            CToolBar m_barVideo;
                            CToolBar m_barAVI;
                            UINT m_currentBar;

                            //----------------------------------------------------------------------
                            //----------------------------------------------------------------------
                            int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
                            {
                            m_menuBarPtr = NULL;
                            m_currentBar = 0;
                            if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
                            {
                            return -1;
                            }
                            m_wndCommandBar.m_bShowSharedNewButton = FALSE;
                            m_ToolTipsTable[0] = MakeString(IDS_NEW);
                            m_ToolTipsTable[1] = MakeString(IDS_FILE);
                            m_ToolTipsTable[2] = MakeString(IDS_MHELP);
                            m_ToolTipsTable[3] = MakeString(IDS_CUT);
                            m_ToolTipsTable[4] = MakeString(IDS_COPY);
                            m_ToolTipsTable[5] = MakeString(IDS_PASTE);
                            m_ToolTipsTable[6] = MakeString(IDS_ABOUT);

                            if (!m\_wndCommandBar.Create(this))
                            {
                            	TRACE(\_T("Failed to create CommandBar\\n"));
                            	return -1;      // fail to create
                            }
                            m\_menuBarPtr = m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME);
                            if (!m\_menuBarPtr ||
                            	!m\_wndCommandBar.InsertSeparator() ||
                                    !m\_wndCommandBar.AddAdornments() ||
                                    !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
                            	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable)))
                            {
                            	TRACE(\_T("Failed to create CommandBar\\n"));
                            	return -1;      // fail to create
                            }
                            
                            m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
                            
                            if (!CreateOtherCommandBars())
                            {
                            	TRACE(\_T("Failed to create one or more supplementary CommandBars\\n"));
                            	return -1;      // fail to create
                            }
                            
                            //BOOL bResult = SHFullScreen(GetSafeHwnd(), SHFS\_HIDESIPBUTTON);
                            
                            return 0;
                            

                            }

                            //----------------------------------------------------------------------
                            //----------------------------------------------------------------------
                            BOOL CMainFrame::CreateOtherCommandBars()
                            {
                            m_currentBar = IDR_MAINFRAME;
                            UINT barStyle = WS_CHILD | CBRS_BOTTOM | CBRS_BORDER_TOP; // | CBRS_TOOLTIPS | CBRS_FLYBY;
                            CRect rcBorder(0, 1, 0, 0);

                            if (!m\_barProcess.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+1) ||
                                !m\_barProcess.LoadToolBar(IDR\_PROCESSBAR))
                            {
                            	TRACE(\_T("Failed to create process toolbar\\n"));
                            	return FALSE;
                            }
                            if (!m\_barAnnotate.CreateEx(this, TBSTYLE\_FLAT, barStyle, rcBorder, AFX\_IDW\_TOOLBAR+2) ||
                                !m\_barAnnotate.LoadToolBar(IDR\_ANNOTATEBAR))
                            {
                            	TRACE(\_T("
                            
                            J Offline
                            J Offline
                            Joao Paulo Figueira
                            wrote on last edited by
                            #18

                            And here is the new article on the subject: Disabling top-level popup menus in the PocketPC 2002[^] ;)

                            realJSOPR 1 Reply Last reply
                            0
                            • J Joao Paulo Figueira

                              And here is the new article on the subject: Disabling top-level popup menus in the PocketPC 2002[^] ;)

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

                              Man, that's BITCHIN'! I'll tinker around with it and see if I can't figure out why the buttons in the toolbar don't stay disabled. It may require adding one or more functions to your new class to make it happen. ------- 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

                              J 1 Reply Last reply
                              0
                              • realJSOPR realJSOP

                                Man, that's BITCHIN'! I'll tinker around with it and see if I can't figure out why the buttons in the toolbar don't stay disabled. It may require adding one or more functions to your new class to make it happen. ------- 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

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

                                John Simmons / outlaw programmer wrote: Man, that's BITCHIN'! You bet! ;) John Simmons / outlaw programmer wrote: It may require adding one or more functions to your new class to make it happen. Let me know what you find out!

                                1 Reply Last reply
                                0
                                • 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