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. Problem in Enable and disable ToolBar

Problem in Enable and disable ToolBar

Scheduled Pinned Locked Moved C / C++ / MFC
help
7 Posts 4 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.
  • M Offline
    M Offline
    mohindar_kks
    wrote on last edited by
    #1

    Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....

    P S M 3 Replies Last reply
    0
    • M mohindar_kks

      Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      mohindar_kks wrote:

      m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED);

      Are you sure, GetToolBarCtrl is returning some valid pointer. Probably, it is returing NULL value.

      mohindar_kks wrote:

      (abnormal termination error are occure)

      This statement leads to above guess.


      Prasad MS MVP -  VC++

      M 1 Reply Last reply
      0
      • P prasad_som

        mohindar_kks wrote:

        m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED);

        Are you sure, GetToolBarCtrl is returning some valid pointer. Probably, it is returing NULL value.

        mohindar_kks wrote:

        (abnormal termination error are occure)

        This statement leads to above guess.


        Prasad MS MVP -  VC++

        M Offline
        M Offline
        mohindar_kks
        wrote on last edited by
        #3

        Hi, Am also try to run the following code, here also abnormal termination error are occured CToolBar c_oToolBar; CToolBarCtrl & a_roCtrl = c_oToolBar.GetToolBarCtrl(); a_roCtrl.EnableButton(ID_FILE_OPEN,FALSE);

        1 Reply Last reply
        0
        • M mohindar_kks

          Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....

          S Offline
          S Offline
          Sameer_Thakur
          wrote on last edited by
          #4

          I am not sure about the approach that u have specified here. But the following approach will server the purpose of enabling / disabling the tool bar controls. You need to add a function in your view class. For example… Add ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) at location shown. CMyView.cpp file ======================================================= BEGIN_MESSAGE_MAP(CMyView, CScrollView) //{{AFX_MSG_MAP(CMyView) other message handler functions... ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) other message handler functions... END_MESSAGE_MAP() Void CMyView:: OnUpdateFileNew(CCmdUI* pCmdUI) { if( some_Condition) pCmdUI->Enable(true); else pCmdUI->Enable(false); } CMyView.h file Public: void OnUpdateFileNew (CCmdUI* pCmdUI); Framework will keep calling OnUpdateFileNew function frequently and will keep the tool bar option enabled or disabled in a way u want.

          Sameer Thakur

          M 1 Reply Last reply
          0
          • M mohindar_kks

            Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            You're getting a failed assert because m_wndToolBar is just a C++ object, it's not a window so you can't use the methods that operate on the underlying toolbar window.

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Dunder-Mifflin, this is Pam.

            1 Reply Last reply
            0
            • S Sameer_Thakur

              I am not sure about the approach that u have specified here. But the following approach will server the purpose of enabling / disabling the tool bar controls. You need to add a function in your view class. For example… Add ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) at location shown. CMyView.cpp file ======================================================= BEGIN_MESSAGE_MAP(CMyView, CScrollView) //{{AFX_MSG_MAP(CMyView) other message handler functions... ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) other message handler functions... END_MESSAGE_MAP() Void CMyView:: OnUpdateFileNew(CCmdUI* pCmdUI) { if( some_Condition) pCmdUI->Enable(true); else pCmdUI->Enable(false); } CMyView.h file Public: void OnUpdateFileNew (CCmdUI* pCmdUI); Framework will keep calling OnUpdateFileNew function frequently and will keep the tool bar option enabled or disabled in a way u want.

              Sameer Thakur

              M Offline
              M Offline
              mohindar_kks
              wrote on last edited by
              #6

              I had solve the problem from your valuable reply

              S 1 Reply Last reply
              0
              • M mohindar_kks

                I had solve the problem from your valuable reply

                S Offline
                S Offline
                Sameer_Thakur
                wrote on last edited by
                #7

                Excellent. :)

                Sameer Thakur

                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