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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC Check Box

MFC Check Box

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
6 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.
  • F Offline
    F Offline
    Freddie Code
    wrote on last edited by
    #1

    How do you check if a check box has been checked? I created a check box named IDC_checkbox and assigned a member variable of type Value named m_checkBox.

    C J 2 Replies Last reply
    0
    • F Freddie Code

      How do you check if a check box has been checked? I created a check box named IDC_checkbox and assigned a member variable of type Value named m_checkBox.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      There's a member method called GetCheck. It returns a BOOL, which is an int, 0 is not checked. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • F Freddie Code

        How do you check if a check box has been checked? I created a check box named IDC_checkbox and assigned a member variable of type Value named m_checkBox.

        J Offline
        J Offline
        Jose Lamas Rios
        wrote on last edited by
        #3

        If you used Class Wizard and added a variable of type Value, it must have defined it as BOOL. When you want to check the state of the checkbox, you can call UpdateData(TRUE) and that will copy the state of the control in your variable

        UpdateData(TRUE);
        if (m_checkBox)
        {
          // checkbox is checked
        }
        else
        {
          // checkbox isn't checked
        }

        To change the state of the control, assign a new value to your variable and call UpdateData(FALSE) Note UpdateData() processes all controls that have associated "Value" variables at once. -- jlr http://jlamas.blogspot.com/[^]

        C F 2 Replies Last reply
        0
        • J Jose Lamas Rios

          If you used Class Wizard and added a variable of type Value, it must have defined it as BOOL. When you want to check the state of the checkbox, you can call UpdateData(TRUE) and that will copy the state of the control in your variable

          UpdateData(TRUE);
          if (m_checkBox)
          {
            // checkbox is checked
          }
          else
          {
            // checkbox isn't checked
          }

          To change the state of the control, assign a new value to your variable and call UpdateData(FALSE) Note UpdateData() processes all controls that have associated "Value" variables at once. -- jlr http://jlamas.blogspot.com/[^]

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Jose Lamas Rios wrote: If you used Class Wizard and added a variable of type Value, it must have defined it as BOOL Damn, I missed that bit. I hate that updatedata stuff, I never use it ( although I know all about it, I just missed it in his question ). Christian Graus - Microsoft MVP - C++

          J 1 Reply Last reply
          0
          • C Christian Graus

            Jose Lamas Rios wrote: If you used Class Wizard and added a variable of type Value, it must have defined it as BOOL Damn, I missed that bit. I hate that updatedata stuff, I never use it ( although I know all about it, I just missed it in his question ). Christian Graus - Microsoft MVP - C++

            J Offline
            J Offline
            Jose Lamas Rios
            wrote on last edited by
            #5

            Christian Graus wrote: I hate that updatedata stuff, I never use it. Yep, I don't like it much myself... :) Christian Graus wrote: ( although I know all about it, I just missed it in his question ). I'm sure you do ;) -- jlr http://jlamas.blogspot.com/[^]

            1 Reply Last reply
            0
            • J Jose Lamas Rios

              If you used Class Wizard and added a variable of type Value, it must have defined it as BOOL. When you want to check the state of the checkbox, you can call UpdateData(TRUE) and that will copy the state of the control in your variable

              UpdateData(TRUE);
              if (m_checkBox)
              {
                // checkbox is checked
              }
              else
              {
                // checkbox isn't checked
              }

              To change the state of the control, assign a new value to your variable and call UpdateData(FALSE) Note UpdateData() processes all controls that have associated "Value" variables at once. -- jlr http://jlamas.blogspot.com/[^]

              F Offline
              F Offline
              Freddie Code
              wrote on last edited by
              #6

              Thanks, this is what I needed! :)

              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