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. How to display a double value as text in a CEdit window

How to display a double value as text in a CEdit window

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 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.
  • R Offline
    R Offline
    Reagan Conservative
    wrote on last edited by
    #1

    Does anyone have a suggestion as to how to convert a double value to text so it can be displayed in a CEdit window? Thanks.

    John P.

    D J 2 Replies Last reply
    0
    • R Reagan Conservative

      Does anyone have a suggestion as to how to convert a double value to text so it can be displayed in a CEdit window? Thanks.

      John P.

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

      Since you are using MFC, try:

      CString str;
      str.Format("%f", 123.45);
      m_edit.SetWindowText(str);

      Or:

      char szStr[16];
      sprintf(szStr, "%f", 123.45);
      m_edit.SetWindowText(szStr);


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      R 1 Reply Last reply
      0
      • D David Crow

        Since you are using MFC, try:

        CString str;
        str.Format("%f", 123.45);
        m_edit.SetWindowText(str);

        Or:

        char szStr[16];
        sprintf(szStr, "%f", 123.45);
        m_edit.SetWindowText(szStr);


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        R Offline
        R Offline
        Reagan Conservative
        wrote on last edited by
        #3

        Thanks, David --- you da man!

        John P.

        1 Reply Last reply
        0
        • R Reagan Conservative

          Does anyone have a suggestion as to how to convert a double value to text so it can be displayed in a CEdit window? Thanks.

          John P.

          J Offline
          J Offline
          JudyL_MD
          wrote on last edited by
          #4

          Since you're usimg MFC, just associate a double variable instead of a string with the windows. DDX will handle the conversions for you. Judy

          R 1 Reply Last reply
          0
          • J JudyL_MD

            Since you're usimg MFC, just associate a double variable instead of a string with the windows. DDX will handle the conversions for you. Judy

            R Offline
            R Offline
            Reagan Conservative
            wrote on last edited by
            #5

            Thanks, Judy. I was not aware of that. That is very useful to know. I appreciate your response.

            John P.

            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