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. Outputting variables in a MessageBox

Outputting variables in a MessageBox

Scheduled Pinned Locked Moved C / C++ / MFC
c++sales
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
    AbhishekBK
    wrote on last edited by
    #1

    Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf: printf("Hello! Your are customer number %d \n", CustomerNumber); That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(

    Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya

    M D M 3 Replies Last reply
    0
    • A AbhishekBK

      Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf: printf("Hello! Your are customer number %d \n", CustomerNumber); That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(

      Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Use CString and the Format() method:

      CString str;
      str.Format(_T("Hello! You are customer number: %d"), CustomerNumber);
      AfxMessageBox(str);

      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

      A 1 Reply Last reply
      0
      • M Michael Dunn

        Use CString and the Format() method:

        CString str;
        str.Format(_T("Hello! You are customer number: %d"), CustomerNumber);
        AfxMessageBox(str);

        --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

        A Offline
        A Offline
        AbhishekBK
        wrote on last edited by
        #3

        Thanks a lot Mike. :)

        Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya

        1 Reply Last reply
        0
        • A AbhishekBK

          Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf: printf("Hello! Your are customer number %d \n", CustomerNumber); That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(

          Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya

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

          In addition to Michael's suggestion, there's also AfxFormatString1().


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          1 Reply Last reply
          0
          • A AbhishekBK

            Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf: printf("Hello! Your are customer number %d \n", CustomerNumber); That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(

            Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            I would use the TRACE macro to output variable in the output window in the DEBUG mode, instead of using message box.


            Maximilien Lincourt Your Head A Splode - Strong Bad

            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