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. Clear Checkbox??

Clear Checkbox??

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • A Offline
    A Offline
    Aoife
    wrote on last edited by
    #1

    I have two checkboxes. The second becomes enabled when the first is checked and disabled when the first is unchecked, but I also need the second to be unchecked automatically when the first is unchecked by the user. The following code disables the second but doesn't clear it. *********************************************************** void CTab3_SMS::OnSaveToPCcb() { //Get the current values from the screen UpdateData(TRUE); //Is the "FIRST" checkbox checked? if (m_bSaveToPC == TRUE) { //Enable the "SECOND" checkbox GetDlgItem(IDC_DELETEFROMSIMCB)->EnableWindow(TRUE); } else { //No; clear and disable the "SECOND" checkbox GetDlgItem(IDC_DELETEFROMSIMCB)->EnableWindow(FALSE); } } *********************************************************** What other command goes into the else{} statement? Thanks, Aoife

    R 1 Reply Last reply
    0
    • A Aoife

      I have two checkboxes. The second becomes enabled when the first is checked and disabled when the first is unchecked, but I also need the second to be unchecked automatically when the first is unchecked by the user. The following code disables the second but doesn't clear it. *********************************************************** void CTab3_SMS::OnSaveToPCcb() { //Get the current values from the screen UpdateData(TRUE); //Is the "FIRST" checkbox checked? if (m_bSaveToPC == TRUE) { //Enable the "SECOND" checkbox GetDlgItem(IDC_DELETEFROMSIMCB)->EnableWindow(TRUE); } else { //No; clear and disable the "SECOND" checkbox GetDlgItem(IDC_DELETEFROMSIMCB)->EnableWindow(FALSE); } } *********************************************************** What other command goes into the else{} statement? Thanks, Aoife

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      CheckDlgButton (IDC_FOO, FALSE);

      /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

      J 1 Reply Last reply
      0
      • R Ravi Bhavnani

        CheckDlgButton (IDC_FOO, FALSE);

        /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        Ravi Bhavnani wrote: CheckDlgButton (IDC_FOO, FALSE);    You may want to be wary of doing things like that: while passing in FALSE works, because it evaluates to zero, same as BST_UNCHECKED, it is not really correct to do so.    Also, when newer (less experienced) developers see things like they they may be confused into thinking that TRUE (1) and FALSE (0) are not only correct, but are the only values that can be used with that function.  That is, of course, an incorrect conclusion, as BST_INDETERMINATE (2) can be used as well.    Peace! -=- James.

        R 1 Reply Last reply
        0
        • J James R Twine

          Ravi Bhavnani wrote: CheckDlgButton (IDC_FOO, FALSE);    You may want to be wary of doing things like that: while passing in FALSE works, because it evaluates to zero, same as BST_UNCHECKED, it is not really correct to do so.    Also, when newer (less experienced) developers see things like they they may be confused into thinking that TRUE (1) and FALSE (0) are not only correct, but are the only values that can be used with that function.  That is, of course, an incorrect conclusion, as BST_INDETERMINATE (2) can be used as well.    Peace! -=- James.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          You're absolutely right. It should be CheckDlgButton (IDC_FOO, BST_UNCHECKED). /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.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