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. Multiple line in MessageBox

Multiple line in MessageBox

Scheduled Pinned Locked Moved C / C++ / MFC
7 Posts 5 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
    Cedric Moonen
    wrote on last edited by
    #1

    Hello, I have a long text to print in a MessageBox so I want it on several lines. I tried something like: MessageBox(NULL,"Test\n\rTest","",MB_OK); but it doesn't work!! I want also the string to be loaded from a file so the 'escape sequences' will be in the string! Thanks

    Z J J C 4 Replies Last reply
    0
    • C Cedric Moonen

      Hello, I have a long text to print in a MessageBox so I want it on several lines. I tried something like: MessageBox(NULL,"Test\n\rTest","",MB_OK); but it doesn't work!! I want also the string to be loaded from a file so the 'escape sequences' will be in the string! Thanks

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      It works wonderfully for me (also, you can omit the \r part). Test sample follows:

      #include <windows.h>

      int main()
      {
      MessageBox(NULL,"Test\nTest","",MB_OK);

      return 0;
      }

      Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      1 Reply Last reply
      0
      • C Cedric Moonen

        Hello, I have a long text to print in a MessageBox so I want it on several lines. I tried something like: MessageBox(NULL,"Test\n\rTest","",MB_OK); but it doesn't work!! I want also the string to be loaded from a file so the 'escape sequences' will be in the string! Thanks

        Z Offline
        Z Offline
        Zdeslav Vojkovic
        wrote on last edited by
        #3

        i tried MessageBox(NULL,"Test\n\rTest","",MB_OK); on my system(win2K) and it works fine???

        1 Reply Last reply
        0
        • C Cedric Moonen

          Hello, I have a long text to print in a MessageBox so I want it on several lines. I tried something like: MessageBox(NULL,"Test\n\rTest","",MB_OK); but it doesn't work!! I want also the string to be loaded from a file so the 'escape sequences' will be in the string! Thanks

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

          hello, try

          MessageBox(NULL,"Test\r\nTest","",MB_OK);
          

          i have try

          MessageBox(NULL,"Test\n\rTest","",MB_OK);
          

          on my system(XP) and it works fine ...

          1 Reply Last reply
          0
          • C Cedric Moonen

            Hello, I have a long text to print in a MessageBox so I want it on several lines. I tried something like: MessageBox(NULL,"Test\n\rTest","",MB_OK); but it doesn't work!! I want also the string to be loaded from a file so the 'escape sequences' will be in the string! Thanks

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            Thanks everybody ! Sorry, in fact I did not try the MessageBox(NULL,"Test\n\rTest","",MB_OK); but loaded the string from a file !! So the \n is no more interpreted as an escape sequence but as normal text !! So I think it will not be possible to have such an escape sequence in a text file! Or do you have any suggestion ??

            R 1 Reply Last reply
            0
            • C Cedric Moonen

              Thanks everybody ! Sorry, in fact I did not try the MessageBox(NULL,"Test\n\rTest","",MB_OK); but loaded the string from a file !! So the \n is no more interpreted as an escape sequence but as normal text !! So I think it will not be possible to have such an escape sequence in a text file! Or do you have any suggestion ??

              R Offline
              R Offline
              Rage
              wrote on last edited by
              #6

              This depends on the way you are "loading" your text. With a standard fopen(filename,"r") will throw the problem you mentioned, whereas fopen(filename,"rt") won't. Check the fopen for this in the MSDN. ~RaGE();

              C 1 Reply Last reply
              0
              • R Rage

                This depends on the way you are "loading" your text. With a standard fopen(filename,"r") will throw the problem you mentioned, whereas fopen(filename,"rt") won't. Check the fopen for this in the MSDN. ~RaGE();

                C Offline
                C Offline
                Cedric Moonen
                wrote on last edited by
                #7

                Yes, thanks :) ! I'll take a look at that !!

                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