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. MFC fetching value

MFC fetching value

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
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.
  • M Offline
    M Offline
    missnazar
    wrote on last edited by
    #1

    Hi, I have placed a Check Box on 1st property page. The propertysheet containing this property page is on the form view of my MDI MFC Appwizaerd Application. I have placed a push button on form view of the application. In its(push buton's) member function, named OnPress, I want to fetch the value of the checkbox of that propertypage. ID of Check Box is IDC_CHECK_SUBFOLDER If I place the code as follows in OnPress member function, I get an access violation error when I run it. (((CButton *)GetDlgItem(IDC_CHECK_SUBFOLDER))->GetCheck() == 1); Please Help me to fetch the value. Drushti

    D 1 Reply Last reply
    0
    • M missnazar

      Hi, I have placed a Check Box on 1st property page. The propertysheet containing this property page is on the form view of my MDI MFC Appwizaerd Application. I have placed a push button on form view of the application. In its(push buton's) member function, named OnPress, I want to fetch the value of the checkbox of that propertypage. ID of Check Box is IDC_CHECK_SUBFOLDER If I place the code as follows in OnPress member function, I get an access violation error when I run it. (((CButton *)GetDlgItem(IDC_CHECK_SUBFOLDER))->GetCheck() == 1); Please Help me to fetch the value. Drushti

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      missnazar wrote: (((CButton *)GetDlgItem(IDC_CHECK_SUBFOLDER))->GetCheck() == 1); It's never a good idea to use hard-coded values like this. Compare against BST_CHECKED instead. That's not the cause of the access violation, however. Rather than lump all that into one convoluted statement that makes debugging rather difficult, how about breaking it up into something like:

      CButton *pButton = (CButton *) GetDlgItem(IDC_CHECK_SUBFOLDER);
      if (NULL != pButton)
      {
      if (pButton->GetCheck() == BST_CHECKED)
      ;
      }

      Now you can get a better idea as to where it's failing.


      "Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow

      M 1 Reply Last reply
      0
      • D David Crow

        missnazar wrote: (((CButton *)GetDlgItem(IDC_CHECK_SUBFOLDER))->GetCheck() == 1); It's never a good idea to use hard-coded values like this. Compare against BST_CHECKED instead. That's not the cause of the access violation, however. Rather than lump all that into one convoluted statement that makes debugging rather difficult, how about breaking it up into something like:

        CButton *pButton = (CButton *) GetDlgItem(IDC_CHECK_SUBFOLDER);
        if (NULL != pButton)
        {
        if (pButton->GetCheck() == BST_CHECKED)
        ;
        }

        Now you can get a better idea as to where it's failing.


        "Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow

        M Offline
        M Offline
        Malcolm Smart
        wrote on last edited by
        #3

        DavidCrow wrote: Rather than lump all that into one convoluted statement that makes debugging rather difficult, how about breaking it up into something like: Once the problem is fixed, would you put the code back to a single line? Whilst it is not as 'nice' to read I imagine it would execute quicker, not that the difference in speed will amount to much anyway. I just wondered what other people thought - more convulated, easier to read/maintain code, or 'many commands nested on one line'. Cheers Angel *********************************************************** The sooner you fall behind, the longer you have to catch up

        D 1 Reply Last reply
        0
        • M Malcolm Smart

          DavidCrow wrote: Rather than lump all that into one convoluted statement that makes debugging rather difficult, how about breaking it up into something like: Once the problem is fixed, would you put the code back to a single line? Whilst it is not as 'nice' to read I imagine it would execute quicker, not that the difference in speed will amount to much anyway. I just wondered what other people thought - more convulated, easier to read/maintain code, or 'many commands nested on one line'. Cheers Angel *********************************************************** The sooner you fall behind, the longer you have to catch up

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Angel1058 wrote: Once the problem is fixed, would you put the code back to a single line? I personally would not. Angel1058 wrote: ...I imagine it would execute quicker... True, assuming your stopwatch can measure things in nanoseconds.


          "Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow

          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