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. ATL / WTL / STL
  4. Enable/Disable toolbar buttons

Enable/Disable toolbar buttons

Scheduled Pinned Locked Moved ATL / WTL / STL
question
3 Posts 3 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.
  • T Offline
    T Offline
    Tommy2k
    wrote on last edited by
    #1

    I made a nice toolbar like this: CToolBarCtrl ctrl; ctrl.Create(m_hWnd, NULL, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, 0, ATL_IDW_TOOLBAR); ctrl.SetImageList(largeImages); TBBUTTON ToolbarButtons[12]; memset(ToolbarButtons, 0, sizeof(ToolbarButtons)); int n = 0; ToolbarButtons[n].iBitmap = 0; ToolbarButtons[n].idCommand = ID_FILE_SIGNIN; ToolbarButtons[n].fsState = TBSTATE_ENABLED; ToolbarButtons[n].fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE; ...etc ctrl.SetButtonStructSize(); ctrl.AddButtons(n+1, ToolbarButtons); ctrl.AutoSize(); return ctrl.m_hWnd; The returned hWnd is added to the CMainFrame as a toolbar. Works perfectly. But how do i enable/disable buttons in my toolbar? Thank you!

    M E 2 Replies Last reply
    0
    • T Tommy2k

      I made a nice toolbar like this: CToolBarCtrl ctrl; ctrl.Create(m_hWnd, NULL, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, 0, ATL_IDW_TOOLBAR); ctrl.SetImageList(largeImages); TBBUTTON ToolbarButtons[12]; memset(ToolbarButtons, 0, sizeof(ToolbarButtons)); int n = 0; ToolbarButtons[n].iBitmap = 0; ToolbarButtons[n].idCommand = ID_FILE_SIGNIN; ToolbarButtons[n].fsState = TBSTATE_ENABLED; ToolbarButtons[n].fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE; ...etc ctrl.SetButtonStructSize(); ctrl.AddButtons(n+1, ToolbarButtons); ctrl.AutoSize(); return ctrl.m_hWnd; The returned hWnd is added to the CMainFrame as a toolbar. Works perfectly. But how do i enable/disable buttons in my toolbar? Thank you!

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

      Use the TB_ENABLEBUTTON message --Mike--    THERE IS NO     THERE IS NO    BUT THERE IS MAGIC PIXIE DUST  BUSINESS GENIE  CODE PROJECT Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me

      1 Reply Last reply
      0
      • T Tommy2k

        I made a nice toolbar like this: CToolBarCtrl ctrl; ctrl.Create(m_hWnd, NULL, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, 0, ATL_IDW_TOOLBAR); ctrl.SetImageList(largeImages); TBBUTTON ToolbarButtons[12]; memset(ToolbarButtons, 0, sizeof(ToolbarButtons)); int n = 0; ToolbarButtons[n].iBitmap = 0; ToolbarButtons[n].idCommand = ID_FILE_SIGNIN; ToolbarButtons[n].fsState = TBSTATE_ENABLED; ToolbarButtons[n].fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE; ...etc ctrl.SetButtonStructSize(); ctrl.AddButtons(n+1, ToolbarButtons); ctrl.AutoSize(); return ctrl.m_hWnd; The returned hWnd is added to the CMainFrame as a toolbar. Works perfectly. But how do i enable/disable buttons in my toolbar? Thank you!

        E Offline
        E Offline
        Ed Gadziemski
        wrote on last edited by
        #3

        Add them to the UPDATE_UI_MAP. For example, UPDATE_ELEMENT(ID_FILE_PRINT, UPDUI_TOOLBAR) and then in the OnIdle() handler, have something like this: UIEnable(ID_FILE_PRINT, /* your boolean condition here */);

        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