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. cannot retrieve dialog user inputs

cannot retrieve dialog user inputs

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

    i have a query: i use a dialog to take in user input for a rect dimensions but i tested it using AfxMessagebox and encounter assertion error, may i know where is the problem? i have a variable m_length of float type. void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; AfxMessageBox(length); }

    Y R 2 Replies Last reply
    0
    • C coda_x

      i have a query: i use a dialog to take in user input for a rect dimensions but i tested it using AfxMessagebox and encounter assertion error, may i know where is the problem? i have a variable m_length of float type. void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; AfxMessageBox(length); }

      Y Offline
      Y Offline
      YaronNir
      wrote on last edited by
      #2

      Hi, this could occur due to several problems: 1) look in the DDX method of the class that the m_length is defined there. if it is not than the UpdataData(TRUE) will not be valid for m_length. 2) use format string for the float variable as follows:

      CString szLength;
      szLength.Format(_T("%d"),m_length);
      AfxMessageBox(length);

      hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application

      C 1 Reply Last reply
      0
      • Y YaronNir

        Hi, this could occur due to several problems: 1) look in the DDX method of the class that the m_length is defined there. if it is not than the UpdataData(TRUE) will not be valid for m_length. 2) use format string for the float variable as follows:

        CString szLength;
        szLength.Format(_T("%d"),m_length);
        AfxMessageBox(length);

        hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application

        C Offline
        C Offline
        coda_x
        wrote on last edited by
        #3

        the DDX method shows: DDX_Text(pDX, IDC_LENGTH, m_length); does that mean that the UpDateData(TRUE) is unable to take in the float m_length? i need my member variables to be float preferably because i am using it for OpenGL rendering and as i encountered problems putting my variables into OpenGl that why i was testing to check whether my function can take in the float values.... is there a better way?

        Y 1 Reply Last reply
        0
        • C coda_x

          the DDX method shows: DDX_Text(pDX, IDC_LENGTH, m_length); does that mean that the UpDateData(TRUE) is unable to take in the float m_length? i need my member variables to be float preferably because i am using it for OpenGL rendering and as i encountered problems putting my variables into OpenGl that why i was testing to check whether my function can take in the float values.... is there a better way?

          Y Offline
          Y Offline
          YaronNir
          wrote on last edited by
          #4

          ok, i see the problem now... open the class wizard (CTRL+W) and go to the definition of IDC_LENGTH and delete the m_str_length member. add a new member called m_length which will be not from CString type but from float type. then you should see an entry in the DDX as follows:

          DDX_Text(pDX, IDC_LENGTH, m_length);

          now the update data will hold the number within the m_length...and all u have to do is convert it to string and display it.... hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application

          C 1 Reply Last reply
          0
          • Y YaronNir

            ok, i see the problem now... open the class wizard (CTRL+W) and go to the definition of IDC_LENGTH and delete the m_str_length member. add a new member called m_length which will be not from CString type but from float type. then you should see an entry in the DDX as follows:

            DDX_Text(pDX, IDC_LENGTH, m_length);

            now the update data will hold the number within the m_length...and all u have to do is convert it to string and display it.... hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application

            C Offline
            C Offline
            coda_x
            wrote on last edited by
            #5

            erm okie thanx but actually i made a typo error in my earlier message, it is really DDX_Text(pDX, IDC_LENGTH, m_length) already.. so that means AfxMessageBox cannot display a float directly? need to convert to String?

            Y D 2 Replies Last reply
            0
            • C coda_x

              erm okie thanx but actually i made a typo error in my earlier message, it is really DDX_Text(pDX, IDC_LENGTH, m_length) already.. so that means AfxMessageBox cannot display a float directly? need to convert to String?

              Y Offline
              Y Offline
              YaronNir
              wrote on last edited by
              #6

              yes, just do it like this:

              UpdateData(TRUE);
              CString sz;
              sz.Format(_T("%f"),m_length);
              AfxMessageBox(sz);

              Yaron Ask not what your application can do for you, Ask what you can do for your application

              1 Reply Last reply
              0
              • C coda_x

                i have a query: i use a dialog to take in user input for a rect dimensions but i tested it using AfxMessagebox and encounter assertion error, may i know where is the problem? i have a variable m_length of float type. void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; AfxMessageBox(length); }

                R Offline
                R Offline
                Rafael Fernandez Lopez
                wrote on last edited by
                #7

                You cannot use AfxMessageBox with a float variable. You need a CString with the float variable this way: void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; CString my_string; my_string.Format("%f", length); AfxMessageBox(my_string); } That's all, hope it helped.


                Rafael Fernández López.

                I didn't fail hundred times, I found hundred ways that didn't work.

                No fallé cien veces, encontré cien maneras de que no funcionara.

                1 Reply Last reply
                0
                • C coda_x

                  erm okie thanx but actually i made a typo error in my earlier message, it is really DDX_Text(pDX, IDC_LENGTH, m_length) already.. so that means AfxMessageBox cannot display a float directly? need to convert to String?

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

                  coda_x wrote: so that means AfxMessageBox cannot display a float directly? Correct. Check the docs and the function prototypes.


                  Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

                  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