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 - incrementing values

MFC - incrementing values

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
5 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.
  • A Offline
    A Offline
    Ashman
    wrote on last edited by
    #1

    I am having a difficult time trying to get a value to increment. What I mean is if I have a static control for example called CValue that each time a button is pressed it will increase the value by one. So if CValue = 10 and the button is pressed, I want it to change the value of CValue to 11. Each time I try to do this, the compiler says some crap about converting CString to an int is impossible or something. I cannot remember because I just got out of bed to write this so that I may have a reply by the morning. Can someone please help me. I know this is easy 'i think' but it has me tickled pink. Thankyou Ashman :confused:

    D 1 Reply Last reply
    0
    • A Ashman

      I am having a difficult time trying to get a value to increment. What I mean is if I have a static control for example called CValue that each time a button is pressed it will increase the value by one. So if CValue = 10 and the button is pressed, I want it to change the value of CValue to 11. Each time I try to do this, the compiler says some crap about converting CString to an int is impossible or something. I cannot remember because I just got out of bed to write this so that I may have a reply by the morning. Can someone please help me. I know this is easy 'i think' but it has me tickled pink. Thankyou Ashman :confused:

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

      Have you tried something like:

      CString strValue;
      CValue.GetWindowText(strValue);
      int nValue = atoi(strValue) + 1;
      CValue.SetWindowText(strValue);


      A rich person is not the one who has the most, but the one that needs the least.

      J 1 Reply Last reply
      0
      • D David Crow

        Have you tried something like:

        CString strValue;
        CValue.GetWindowText(strValue);
        int nValue = atoi(strValue) + 1;
        CValue.SetWindowText(strValue);


        A rich person is not the one who has the most, but the one that needs the least.

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        DavidCrow wrote:

        CString strValue;
        CValue.GetWindowText(strValue);
        int nValue = atoi(strValue) + 1;
        CValue.SetWindowText(strValue);

        Whoops!

        CString strValue;
        CValue.GetWindowText(strValue);
        int nValue = atoi(strValue) + 1;
        strValue.Format(_T("%d"), nValue);
        CValue.SetWindowText(strValue);

        INTP

        D 1 Reply Last reply
        0
        • J John R Shaw

          DavidCrow wrote:

          CString strValue;
          CValue.GetWindowText(strValue);
          int nValue = atoi(strValue) + 1;
          CValue.SetWindowText(strValue);

          Whoops!

          CString strValue;
          CValue.GetWindowText(strValue);
          int nValue = atoi(strValue) + 1;
          strValue.Format(_T("%d"), nValue);
          CValue.SetWindowText(strValue);

          INTP

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

          No, BIG whoops! Thanks.


          A rich person is not the one who has the most, but the one that needs the least.

          B 1 Reply Last reply
          0
          • D David Crow

            No, BIG whoops! Thanks.


            A rich person is not the one who has the most, but the one that needs the least.

            B Offline
            B Offline
            basementman
            wrote on last edited by
            #5

            What about GetDlgItemInt()? SetDlgItemInt(IDC_MYCONTROL,MyCtrl.GetDlgItemInt(IDC_MYCONTROL) + 1);  onwards and upwards...

            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