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. Multiple Toolbars

Multiple Toolbars

Scheduled Pinned Locked Moved Mobile
question
11 Posts 2 Posters 27 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

    How does one implement muiltiple toolbars? Our app starts out with a commandbar (menu + buttons), but depending on what the user does in the menu, we want to display another toolbar (or even better, a commandbar with just buttons that replaces the original one until they're done with the new toolbar). Does anyone have any hints they'd like to share? ------- 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
    #2

    The project I'm working on right now has a similar functionality. I supports the normal command bar, plus a toolbar at the top of the screen. Here is the code I've used: Header for frame:

    .
    .
    .
    protected: // control bar embedded members
    CCeCommandBar m_wndCommandBar;
    CChildView m_wndView;

    CToolBar	m\_tbDummy;
    

    .
    .
    .

    Implementarion of frame:

    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    return -1;
    // create a view to occupy the client area of the frame
    if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
    CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
    {
    TRACE0("Failed to create view window\n");
    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) ||
       !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) ||
       !m\_wndCommandBar.AddAdornments() ||
       !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
    	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(6), (LPARAM)(&m\_ToolTipsTable\[1\])))
    {
    	TRACE0("Failed to create CommandBar\\n");
    	return -1;      // fail to create
    }
    
    
    m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() |
    	CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
    
    if(!m\_tbDummy.Create(this, WS\_CHILD | WS\_VISIBLE | CBRS\_TOP) || !m\_tbDummy.LoadToolBar(IDR\_DUMMY))
    {
    	AfxMessageBox(\_T("Failed to create dummy!"));
    	return -1;
    }
    m\_tbDummy.SetHeight(20);
    return 0;
    

    }

    Cheers.

    realJSOPR 1 Reply Last reply
    0
    • J Joao Paulo Figueira

      The project I'm working on right now has a similar functionality. I supports the normal command bar, plus a toolbar at the top of the screen. Here is the code I've used: Header for frame:

      .
      .
      .
      protected: // control bar embedded members
      CCeCommandBar m_wndCommandBar;
      CChildView m_wndView;

      CToolBar	m\_tbDummy;
      

      .
      .
      .

      Implementarion of frame:

      int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
      {
      if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
      return -1;
      // create a view to occupy the client area of the frame
      if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
      CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
      {
      TRACE0("Failed to create view window\n");
      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) ||
         !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) ||
         !m\_wndCommandBar.AddAdornments() ||
         !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
      	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(6), (LPARAM)(&m\_ToolTipsTable\[1\])))
      {
      	TRACE0("Failed to create CommandBar\\n");
      	return -1;      // fail to create
      }
      
      
      m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() |
      	CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
      
      if(!m\_tbDummy.Create(this, WS\_CHILD | WS\_VISIBLE | CBRS\_TOP) || !m\_tbDummy.LoadToolBar(IDR\_DUMMY))
      {
      	AfxMessageBox(\_T("Failed to create dummy!"));
      	return -1;
      }
      m\_tbDummy.SetHeight(20);
      return 0;
      

      }

      Cheers.

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

      This is what I did, and all I've managed to do is to get the CommandBar to dissappear altogether. What's more, when I shut the app down and restart it, the original commandbar is STILL gone (in the emulator). In MainFrm.h:

      class CMainFrame
      {
      ...
      ...
      private:
      CToolBar m_barProcess;
      CToolBar m_barAnnotate;
      CToolBar m_barZoom;
      CToolBar m_barVideo;
      CToolBar m_barAVI;
      CChildView m_wndView;
      UINT m_currentBar;

      BOOL CreateOtherCommandBars();
      void HideCurrentToolbar    ();
      void ShowThisBar           (UINT newBar);
      void ShowMainCommandBar    ();
      

      };

      In MainFrm.cpp:

      //---------------------------------------------------------------------------
      //---------------------------------------------------------------------------
      int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
      {

      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) ||
         !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) ||
         !m\_wndCommandBar.AddAdornments() ||
         !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
      	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable)))
      {
      	TRACE0("Failed to create CommandBar\\n");
      	return -1;      // fail to create
      }
      
      m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() |
      	CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
      
      CreateOtherCommandBars();
      
      return 0;
      

      }

      //---------------------------------------------------------------------------
      //---------------------------------------------------------------------------
      BOOL CMainFrame::CreateOtherCommandBars()
      {
      m_currentBar = IDR_MAINFRAME;
      UINT barStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM/* | CBRS_TOOLTIPS | CBRS_FLYBY*/;
      UINT barStyleEx = CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED;
      if (!m_barProcess.Create(this, TBSTYLE_FLAT, barStyle) ||
      !m_barProcess.LoadToolBar(IDR_PROCESSBAR))
      {
      return FALSE;
      }
      if (!m_barAnnotate.Create(this, TBSTYLE_FLAT, barStyle) ||
      !m_barAnnotate.LoadToolBar(IDR_ANNOTATEBAR))
      {
      return FALSE;
      }
      if (!m_barZoom.Create(this, TBSTYLE_FLAT, barStyle) ||
      !m_barZoom.LoadToolBar(

      J 1 Reply Last reply
      0
      • realJSOPR realJSOP

        This is what I did, and all I've managed to do is to get the CommandBar to dissappear altogether. What's more, when I shut the app down and restart it, the original commandbar is STILL gone (in the emulator). In MainFrm.h:

        class CMainFrame
        {
        ...
        ...
        private:
        CToolBar m_barProcess;
        CToolBar m_barAnnotate;
        CToolBar m_barZoom;
        CToolBar m_barVideo;
        CToolBar m_barAVI;
        CChildView m_wndView;
        UINT m_currentBar;

        BOOL CreateOtherCommandBars();
        void HideCurrentToolbar    ();
        void ShowThisBar           (UINT newBar);
        void ShowMainCommandBar    ();
        

        };

        In MainFrm.cpp:

        //---------------------------------------------------------------------------
        //---------------------------------------------------------------------------
        int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        {

        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) ||
           !m\_wndCommandBar.InsertMenuBar(IDR\_MAINFRAME) ||
           !m\_wndCommandBar.AddAdornments() ||
           !m\_wndCommandBar.LoadToolBar(IDR\_MAINFRAME)  ||
        	!m\_wndCommandBar.SendMessage(TB\_SETTOOLTIPS, (WPARAM)(7), (LPARAM)(m\_ToolTipsTable)))
        {
        	TRACE0("Failed to create CommandBar\\n");
        	return -1;      // fail to create
        }
        
        m\_wndCommandBar.SetBarStyle(m\_wndCommandBar.GetBarStyle() |
        	CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_FIXED);
        
        CreateOtherCommandBars();
        
        return 0;
        

        }

        //---------------------------------------------------------------------------
        //---------------------------------------------------------------------------
        BOOL CMainFrame::CreateOtherCommandBars()
        {
        m_currentBar = IDR_MAINFRAME;
        UINT barStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM/* | CBRS_TOOLTIPS | CBRS_FLYBY*/;
        UINT barStyleEx = CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED;
        if (!m_barProcess.Create(this, TBSTYLE_FLAT, barStyle) ||
        !m_barProcess.LoadToolBar(IDR_PROCESSBAR))
        {
        return FALSE;
        }
        if (!m_barAnnotate.Create(this, TBSTYLE_FLAT, barStyle) ||
        !m_barAnnotate.LoadToolBar(IDR_ANNOTATEBAR))
        {
        return FALSE;
        }
        if (!m_barZoom.Create(this, TBSTYLE_FLAT, barStyle) ||
        !m_barZoom.LoadToolBar(

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

        I don't know if this will work better: create one toolbar at a time, destroying the previous one.

        realJSOPR 1 Reply Last reply
        0
        • J Joao Paulo Figueira

          I don't know if this will work better: create one toolbar at a time, destroying the previous one.

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

          What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- 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 3 Replies Last reply
          0
          • realJSOPR realJSOP

            What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- 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

            I believe you should create a CToolBar in your main frame using the CBRS_BOTTOM style. Hope this is not another blind alley...

            1 Reply Last reply
            0
            • realJSOPR realJSOP

              What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- 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
              #7

              I have it. How do I send you the code?

              1 Reply Last reply
              0
              • realJSOPR realJSOP

                What I'm trying to get is what Pocket Word does. There's a button on the commandbar that brings up an additional toolbar. I have tried a number of approaches to this, but I can't get it to work. I've almost decided that PocketPC 2002 is equivalent to "hell on earth". ------- 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

                John Simmons / outlaw programmer wrote: I've almost decided that PocketPC 2002 is equivalent to "hell on earth". Here comes a bit of "heaven", I hope! ;) Multiple Toolbars in the PocketPC 2002 [^]

                realJSOPR 2 Replies Last reply
                0
                • J Joao Paulo Figueira

                  John Simmons / outlaw programmer wrote: I've almost decided that PocketPC 2002 is equivalent to "hell on earth". Here comes a bit of "heaven", I hope! ;) Multiple Toolbars in the PocketPC 2002 [^]

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

                  I'll have a look - at first glance, it appears to be exactly what i need. Many thanks! ------- 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

                    John Simmons / outlaw programmer wrote: I've almost decided that PocketPC 2002 is equivalent to "hell on earth". Here comes a bit of "heaven", I hope! ;) Multiple Toolbars in the PocketPC 2002 [^]

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

                    It works! But you gotta tell me where you found out how to do that... :) ------- 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

                      It works! But you gotta tell me where you found out how to do that... :) ------- 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
                      #11

                      (teeth gnashing) I had to go through the MFC source code... :eek:

                      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