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. Creating ToolBar with enabled buttons

Creating ToolBar with enabled buttons

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
3 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.
  • B Offline
    B Offline
    Budric B
    wrote on last edited by
    #1

    Hi, I have a simple question. I copied the following code into my own subclass of CFrameWnd:if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_IMAGEVIEWER_TOOLBAR)) { TRACE0("Failed to create first main toolbar\n"); return -1; // fail to create }
    The toolbar shows up but all the buttons are disabled. I did not want to write UPDATE_COMMAND_UI handler for each button because I never plan on disabling most (if not all of them). What am I missing from my code? For any SDI app you create in the wizard the toolbar shows up with buttons enabled. I copied the same code and it doesn't work for me. Thanks.

    PJ ArendsP 1 Reply Last reply
    0
    • B Budric B

      Hi, I have a simple question. I copied the following code into my own subclass of CFrameWnd:if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_IMAGEVIEWER_TOOLBAR)) { TRACE0("Failed to create first main toolbar\n"); return -1; // fail to create }
      The toolbar shows up but all the buttons are disabled. I did not want to write UPDATE_COMMAND_UI handler for each button because I never plan on disabling most (if not all of them). What am I missing from my code? For any SDI app you create in the wizard the toolbar shows up with buttons enabled. I copied the same code and it doesn't work for me. Thanks.

      PJ ArendsP Offline
      PJ ArendsP Offline
      PJ Arends
      wrote on last edited by
      #2

      You have to have code to handle the command generated by a click on the button. If there is no code in your program to handle the click, the button will be disabled.


      "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!


      Honoured as one of The Most Helpful Members of 2004

      Within you lies the power for good; Use it!

      B 1 Reply Last reply
      0
      • PJ ArendsP PJ Arends

        You have to have code to handle the command generated by a click on the button. If there is no code in your program to handle the click, the button will be disabled.


        "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!


        Honoured as one of The Most Helpful Members of 2004

        B Offline
        B Offline
        Budric B
        wrote on last edited by
        #3

        Thanks.

        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