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. MessageBox variation

MessageBox variation

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadminhelpquestion
5 Posts 5 Posters 1 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.
  • J Offline
    J Offline
    J B 0
    wrote on last edited by
    #1

    Hello guys, I am looking for a function that is similiar to MessageBox function, however, would have ability to include formatted variable in the pop-up windows box. Best way to illustrate, is something in combination of printf and MessageBox int number = 3; printf("Number is : %d", number); so, might mean doing that in forms of MessageBox MessageBox("Number is : %d", number); Is there funtion MFC that could server that purpose? Thanks in advance for any help.

    B N J J 4 Replies Last reply
    0
    • J J B 0

      Hello guys, I am looking for a function that is similiar to MessageBox function, however, would have ability to include formatted variable in the pop-up windows box. Best way to illustrate, is something in combination of printf and MessageBox int number = 3; printf("Number is : %d", number); so, might mean doing that in forms of MessageBox MessageBox("Number is : %d", number); Is there funtion MFC that could server that purpose? Thanks in advance for any help.

      B Offline
      B Offline
      Brian Shifrin
      wrote on last edited by
      #2

      CString myMessage; myMessage.Format("Number is : %d", number); MessageBox(myMessage, ..., MB_OK); Brian

      1 Reply Last reply
      0
      • J J B 0

        Hello guys, I am looking for a function that is similiar to MessageBox function, however, would have ability to include formatted variable in the pop-up windows box. Best way to illustrate, is something in combination of printf and MessageBox int number = 3; printf("Number is : %d", number); so, might mean doing that in forms of MessageBox MessageBox("Number is : %d", number); Is there funtion MFC that could server that purpose? Thanks in advance for any help.

        N Offline
        N Offline
        Neville Franks
        wrote on last edited by
        #3

        There isn't an MFC function for this. I use code like the following in ED (see sig) for it's "Do not ask again" message boxs. MsgBox( TCHAR* pStr, ... ) { va_list marker; va_start( marker, pStr ); const int nMaxMsgSize = 10 * 1024; // we don't know how to calc required size, so pick something large enough. TCHAR substmsg[ nMaxMsgSize+1 ] = {0}; _vsnprintf( substmsg, nMaxMsgSize, pStr, marker ); MessageBox( hWnd, substmsg, Caption, uType ); va_end( marker ); } You need to fill in the missing bits like hWnd etc, Hope that helps. Neville Franks, Author of ED for Windows. www.getsoft.com Make money with our new Affilate program

        1 Reply Last reply
        0
        • J J B 0

          Hello guys, I am looking for a function that is similiar to MessageBox function, however, would have ability to include formatted variable in the pop-up windows box. Best way to illustrate, is something in combination of printf and MessageBox int number = 3; printf("Number is : %d", number); so, might mean doing that in forms of MessageBox MessageBox("Number is : %d", number); Is there funtion MFC that could server that purpose? Thanks in advance for any help.

          J Offline
          J Offline
          Jean Marc Molina
          wrote on last edited by
          #4

          Hello, The solution is to first format your string, then display the message box. The best way is probably to use a varlist and to implement your own function. Here is my own: int AfxMessageBoxFormat (LPCTSTR lpszFormat, ...) { // Build message from parameters CString s; va_list args; va_start (args, lpszFormat); s.FormatV (lpszFormat, args); va_end (args); // Message box return AfxMessageBox (s); } Hope that helps, JM Web: http://goa.ifrance.com

          1 Reply Last reply
          0
          • J J B 0

            Hello guys, I am looking for a function that is similiar to MessageBox function, however, would have ability to include formatted variable in the pop-up windows box. Best way to illustrate, is something in combination of printf and MessageBox int number = 3; printf("Number is : %d", number); so, might mean doing that in forms of MessageBox MessageBox("Number is : %d", number); Is there funtion MFC that could server that purpose? Thanks in advance for any help.

            J Offline
            J Offline
            J Dunlap
            wrote on last edited by
            #5

            I don't think there is, but I'm working on just such a thing in C#.

            "Do unto others as you would have them do unto you." - Jesus
            "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

            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