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. CFrameWnd :: OnBarCheck

CFrameWnd :: OnBarCheck

Scheduled Pinned Locked Moved C / C++ / MFC
c++designquestionannouncementlearning
5 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.
  • J Offline
    J Offline
    Jake Palmer
    wrote on last edited by
    #1

    One of my visual c++ books tells me that in order to control the showing and hiding of toolbars, create the View menu item with the same ID as the toolbar resource, and map the ON_COMMAND_EX to OnBarCheck and the update UI to OnUpdateControlBarMenu. This compiles, but it isn't doing a damn thing - the menu items aren't checked and selecting them does nothing. Has anyone else gotten this to work? thanks, Jake

    B 1 Reply Last reply
    0
    • J Jake Palmer

      One of my visual c++ books tells me that in order to control the showing and hiding of toolbars, create the View menu item with the same ID as the toolbar resource, and map the ON_COMMAND_EX to OnBarCheck and the update UI to OnUpdateControlBarMenu. This compiles, but it isn't doing a damn thing - the menu items aren't checked and selecting them does nothing. Has anyone else gotten this to work? thanks, Jake

      B Offline
      B Offline
      Ben Burnett
      wrote on last edited by
      #2

      Works fine for me, maybe you could post the code in question so we can take a look at it. cheers, Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)

      J 1 Reply Last reply
      0
      • B Ben Burnett

        Works fine for me, maybe you could post the code in question so we can take a look at it. cheers, Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)

        J Offline
        J Offline
        Jake Palmer
        wrote on last edited by
        #3

        I'm trying to get this message map code in my CMainFrame class to control showing/hiding my toolbars. I know the menu IDs are correct, because I changed the message map as a test to map to some functions I wrote, and they worked. This, however, isn't doing anything. ON_COMMAND_EX(IDR_TOOLBAR1, OnBarCheck) ON_COMMAND_EX(IDR_TOOLBAR2, OnBarCheck) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR1, OnUpdateControlBarMenu) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR2, OnUpdateControlBarMenu) This is the only code related to this - do I need anything else? Is there a problem with the CMainFrame class handling this? Ideas? thanks, Jake

        B 1 Reply Last reply
        0
        • J Jake Palmer

          I'm trying to get this message map code in my CMainFrame class to control showing/hiding my toolbars. I know the menu IDs are correct, because I changed the message map as a test to map to some functions I wrote, and they worked. This, however, isn't doing anything. ON_COMMAND_EX(IDR_TOOLBAR1, OnBarCheck) ON_COMMAND_EX(IDR_TOOLBAR2, OnBarCheck) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR1, OnUpdateControlBarMenu) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR2, OnUpdateControlBarMenu) This is the only code related to this - do I need anything else? Is there a problem with the CMainFrame class handling this? Ideas? thanks, Jake

          B Offline
          B Offline
          Ben Burnett
          wrote on last edited by
          #4

          These are fine ON_COMMAND_EX ( IDR_TOOLBAR1, OnBarCheck ) ON_COMMAND_EX ( IDR_TOOLBAR2, OnBarCheck ) This wont work the way you expect it too. This is because your OnUpdateControlBarMenu() handler has no way of differentiating between the two toolbars. ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateControlBarMenu ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateControlBarMenu ) You'll need to use two functions to get the desired effect. ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateToolBar1 ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateToolBar2 ) -or- You could use the ON_UPDATE_COMMAND_UI_RANGE macro.

          void CMainFrame::OnBarCheck ( UINT nID ) {

          switch ( nID ) {
          
          case IDR\_TOOLBAR1: 
          	ShowControlBar ( &m\_wndToolBar1, !m\_wndToolBar1.IsVisible (), FALSE );
          	break;
          
          case IDR\_TOOLBAR2: 
          	ShowControlBar ( &m\_wndToolBar2, !m\_wndToolBar2.IsVisible (), FALSE );
          	break;
          
          default:
          	break;
          
          }
          
          RecalcLayout ();
          

          }

          // ...

          void CMainFrame::OnUpdateToolBar1 ( CCmdUI * pCmdUI ) {

          pCmdUI->SetCheck ( m\_wndToolBar1.IsVisible () );
          

          }

          void CMainFrame::OnUpdateToolBar2 ( CCmdUI * pCmdUI ) {

          pCmdUI->SetCheck ( m\_wndToolBar2.IsVisible () );
          

          }

          That should get it working for you. Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)

          J 1 Reply Last reply
          0
          • B Ben Burnett

            These are fine ON_COMMAND_EX ( IDR_TOOLBAR1, OnBarCheck ) ON_COMMAND_EX ( IDR_TOOLBAR2, OnBarCheck ) This wont work the way you expect it too. This is because your OnUpdateControlBarMenu() handler has no way of differentiating between the two toolbars. ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateControlBarMenu ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateControlBarMenu ) You'll need to use two functions to get the desired effect. ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateToolBar1 ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateToolBar2 ) -or- You could use the ON_UPDATE_COMMAND_UI_RANGE macro.

            void CMainFrame::OnBarCheck ( UINT nID ) {

            switch ( nID ) {
            
            case IDR\_TOOLBAR1: 
            	ShowControlBar ( &m\_wndToolBar1, !m\_wndToolBar1.IsVisible (), FALSE );
            	break;
            
            case IDR\_TOOLBAR2: 
            	ShowControlBar ( &m\_wndToolBar2, !m\_wndToolBar2.IsVisible (), FALSE );
            	break;
            
            default:
            	break;
            
            }
            
            RecalcLayout ();
            

            }

            // ...

            void CMainFrame::OnUpdateToolBar1 ( CCmdUI * pCmdUI ) {

            pCmdUI->SetCheck ( m\_wndToolBar1.IsVisible () );
            

            }

            void CMainFrame::OnUpdateToolBar2 ( CCmdUI * pCmdUI ) {

            pCmdUI->SetCheck ( m\_wndToolBar2.IsVisible () );
            

            }

            That should get it working for you. Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)

            J Offline
            J Offline
            Jake Palmer
            wrote on last edited by
            #5

            Thanks a lot for your help. It's finally working. Jake:-D

            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