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. General Programming
  3. C / C++ / MFC
  4. Putting CMFCToolBar in CFormView problem

Putting CMFCToolBar in CFormView problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpannouncement
4 Posts 2 Posters 0 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.
  • H Offline
    H Offline
    Harsh Shankar
    wrote on last edited by
    #1

    Hi Guys,
    Need help in the current task..
    I was  trying to put a CMFCToolBar inside the CFormView and i thought will have no problems and used the code bellow. Now this form view is to be kept a Dockable pane. But while doing this i got few problems. To put the toolbar in the FormView, i did this..
    The TOOLBAR in the RC File is like this..

    IDR_TOOLBAR1 TOOLBAR 16, 16
    BEGIN
    BUTTON IDC_BTN_1
    BUTTON IDC_BTN_2
    BUTTON IDC_BTN_3
    END

    The InitialUpdate of the FormView Derived class is like this: -

    void CMyFormView::OnInitialUpdate()
    {
    CFormView::OnInitialUpdate();
    CWnd *pWnd = NULL;
    CRect rcPos;
    if(!m_wndToolView.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_TOOLBAR1))
    {
    TRACE0("Failed to Create Dialog Toolbar\n");
    }
    m_wndToolView.LoadToolBar(IDR_TOOLBAR1, 0, 0, TRUE /* Is locked */);
    m_wndToolView.CleanUpLockedImages();
    m_wndToolView.LoadBitmap(IDR_TOOLBAR1, 0, 0, TRUE /* Locked */);
    m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | WS_CHILD | WS_TABSTOP);
    m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
    m_wndToolView.SetOwner(this);
    CSize szToolBar = m_wndToolView.CalcFixedLayout( FALSE, TRUE ); // returning CSize(69,24).. which should have been CSize(48, 16)
    }

    Now a few problems i am getting are: -
    1. The Toolbar images are not coming proper
    2. The Update of the Toolbar items is not coming.

    HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

    E 1 Reply Last reply
    0
    • H Harsh Shankar

      Hi Guys,
      Need help in the current task..
      I was  trying to put a CMFCToolBar inside the CFormView and i thought will have no problems and used the code bellow. Now this form view is to be kept a Dockable pane. But while doing this i got few problems. To put the toolbar in the FormView, i did this..
      The TOOLBAR in the RC File is like this..

      IDR_TOOLBAR1 TOOLBAR 16, 16
      BEGIN
      BUTTON IDC_BTN_1
      BUTTON IDC_BTN_2
      BUTTON IDC_BTN_3
      END

      The InitialUpdate of the FormView Derived class is like this: -

      void CMyFormView::OnInitialUpdate()
      {
      CFormView::OnInitialUpdate();
      CWnd *pWnd = NULL;
      CRect rcPos;
      if(!m_wndToolView.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_TOOLBAR1))
      {
      TRACE0("Failed to Create Dialog Toolbar\n");
      }
      m_wndToolView.LoadToolBar(IDR_TOOLBAR1, 0, 0, TRUE /* Is locked */);
      m_wndToolView.CleanUpLockedImages();
      m_wndToolView.LoadBitmap(IDR_TOOLBAR1, 0, 0, TRUE /* Locked */);
      m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | WS_CHILD | WS_TABSTOP);
      m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
      m_wndToolView.SetOwner(this);
      CSize szToolBar = m_wndToolView.CalcFixedLayout( FALSE, TRUE ); // returning CSize(69,24).. which should have been CSize(48, 16)
      }

      Now a few problems i am getting are: -
      1. The Toolbar images are not coming proper
      2. The Update of the Toolbar items is not coming.

      HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #2

      May be also done as following :)

      // class CDiaFrame : public CFrameWnd

      int CDiaFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
      {
      if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
      return -1;

      ModifyStyle(0, WS_CLIPCHILDREN);
      ModifyStyleEx(WS_EX_CLIENTEDGE, 0);

      m_cToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, 1);
      m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
      m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
      m_cToolBar.LoadToolBar(IDR_DIATOOLBAR, 0, 0, TRUE);

      return 0;
      }

      void CDiaFrame::OnSize(UINT nType, int cx, int cy)
      {
      CFrameWnd::OnSize(nType, cx, cy);

      static CSize sizeToolBar(m_cToolBar.CalcFixedLayout(TRUE, TRUE));

      CRect crClient;
      GetClientRect(crClient);

      crClient.bottom = sizeToolBar.cy;
      m_cToolBar.MoveWindow(crClient);
      }

      And then - create/size this frame in a docable pane. Of course you have to define the frame's reactions/updates for all commands from your bar as well :)

      They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

      H 1 Reply Last reply
      0
      • E Eugen Podsypalnikov

        May be also done as following :)

        // class CDiaFrame : public CFrameWnd

        int CDiaFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        {
        if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

        ModifyStyle(0, WS_CLIPCHILDREN);
        ModifyStyleEx(WS_EX_CLIENTEDGE, 0);

        m_cToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, 1);
        m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
        m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
        m_cToolBar.LoadToolBar(IDR_DIATOOLBAR, 0, 0, TRUE);

        return 0;
        }

        void CDiaFrame::OnSize(UINT nType, int cx, int cy)
        {
        CFrameWnd::OnSize(nType, cx, cy);

        static CSize sizeToolBar(m_cToolBar.CalcFixedLayout(TRUE, TRUE));

        CRect crClient;
        GetClientRect(crClient);

        crClient.bottom = sizeToolBar.cy;
        m_cToolBar.MoveWindow(crClient);
        }

        And then - create/size this frame in a docable pane. Of course you have to define the frame's reactions/updates for all commands from your bar as well :)

        They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

        H Offline
        H Offline
        Harsh Shankar
        wrote on last edited by
        #3

        Thanks for the relpy Eugen Podsypalnikov, however i have done the same in my code its not working :( and i have no clues why is it so.. the bitmaps are still improper, buttons are disabled and i am getting no update message for them..

        HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

        E 1 Reply Last reply
        0
        • H Harsh Shankar

          Thanks for the relpy Eugen Podsypalnikov, however i have done the same in my code its not working :( and i have no clues why is it so.. the bitmaps are still improper, buttons are disabled and i am getting no update message for them..

          HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.

          E Offline
          E Offline
          Eugen Podsypalnikov
          wrote on last edited by
          #4

          You can try to go from a level to another, here would be a possible check list :) : 1. Own dockable pane 2. Own frame window 2a. Embedding of the frame into the pane (what can you see at this stage ?) 3. Own toolbar 3a. Embedding of the bar into the frame 4. Implementing of the frame's update/reactions functions

          They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

          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