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. Damn button!

Damn button!

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

    I can't seem to disable a button, so that it is showed as grayed-over. However, if I call IsWindowEnabled() after attempting to disable it, it says that it is disabled. Disabling it by setting its property to disabled doesn't work either. It still shows itself as enabled when the app launches. The button is on a dialog-bar, and I attempt to disable it via the following:

    m_wndDialogBar.GetDlgItem(IDC_MY_BUTTON)->EnableWindow(FALSE);

    Calling UpdateWindow() doesn't seem to help at all either. - John

    F D 2 Replies Last reply
    0
    • J John Uhlenbrock

      I can't seem to disable a button, so that it is showed as grayed-over. However, if I call IsWindowEnabled() after attempting to disable it, it says that it is disabled. Disabling it by setting its property to disabled doesn't work either. It still shows itself as enabled when the app launches. The button is on a dialog-bar, and I attempt to disable it via the following:

      m_wndDialogBar.GetDlgItem(IDC_MY_BUTTON)->EnableWindow(FALSE);

      Calling UpdateWindow() doesn't seem to help at all either. - John

      F Offline
      F Offline
      Frank Deo
      wrote on last edited by
      #2

      I may be wrong here...as always. ;) But... I think your on the right track, but using the wrong thinking. A dialog bar is a dialog...but its not really a Dialog in the normal sense of things. Its really derrived from CControlBar like CToolbar. I think. Try treating your CButton's like standard everyday toolbar buttons and use GetToolbarCtrl. ie:

      CToolBarCtrl& myControl = m_wndToolBar.GetToolBarCtrl();
      myControl.EnableButton(IDC_MYBUTTON, FALSE);

      I'm really stabbing at shadows here, so if I'm wrong I never posted this. If I'm right...you bet I posted it. ;) Frank

      D 1 Reply Last reply
      0
      • F Frank Deo

        I may be wrong here...as always. ;) But... I think your on the right track, but using the wrong thinking. A dialog bar is a dialog...but its not really a Dialog in the normal sense of things. Its really derrived from CControlBar like CToolbar. I think. Try treating your CButton's like standard everyday toolbar buttons and use GetToolbarCtrl. ie:

        CToolBarCtrl& myControl = m_wndToolBar.GetToolBarCtrl();
        myControl.EnableButton(IDC_MYBUTTON, FALSE);

        I'm really stabbing at shadows here, so if I'm wrong I never posted this. If I'm right...you bet I posted it. ;) Frank

        D Offline
        D Offline
        Diarrhio
        wrote on last edited by
        #3

        Unfortunately, that is not correct. You need to ON_UPDATE_COMMAND_UI handler for each button in the dialog bar, just like you would for a button on a control bar.

        1 Reply Last reply
        0
        • J John Uhlenbrock

          I can't seem to disable a button, so that it is showed as grayed-over. However, if I call IsWindowEnabled() after attempting to disable it, it says that it is disabled. Disabling it by setting its property to disabled doesn't work either. It still shows itself as enabled when the app launches. The button is on a dialog-bar, and I attempt to disable it via the following:

          m_wndDialogBar.GetDlgItem(IDC_MY_BUTTON)->EnableWindow(FALSE);

          Calling UpdateWindow() doesn't seem to help at all either. - John

          D Offline
          D Offline
          Derek Waters
          wrote on last edited by
          #4

          Yeah, Frank had the right idea. Because the button is on a dialog bar, you need to enable/disable it like it was a toolbar button. That is, you need to create an Update UI handler for it in your message map:

          ON_UPDATE_COMMAND_UI(IDC_MY_BUTTON, OnUpdateMyButton)

          And then in the handler, set the state of the button:

          void CMyClass::OnUpdateMyButton(CCmdUI* pCmdUI)
          {
          if (i_want_the_button_to_be_enabled)
          pCmdUI->Enable();
          else
          pCmdUI->Disable();
          }

          Hope this helps. ------------------------ Derek Waters derek@lj-oz.com

          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