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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Message Box

Message Box

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

    In part of my program, I made it give a "yes, no, cancel" MessageBox to the user, and it does that. But the text in it make it span all the way from one end of the screen to the other, making it look ugly. How do I tell it to go to the next line after the first line exceeds a certain length?

    R 1 Reply Last reply
    0
    • A Anonymous

      In part of my program, I made it give a "yes, no, cancel" MessageBox to the user, and it does that. But the text in it make it span all the way from one end of the screen to the other, making it look ugly. How do I tell it to go to the next line after the first line exceeds a certain length?

      R Offline
      R Offline
      RChin
      wrote on last edited by
      #2

      Just insert line breaks ("\n"), in your display string. If the length of your string varies, then you might want to write a simple funtion that breaks up your input string for you before passing it on to the messagebox


      I Dream of Absolute Zero

      A 1 Reply Last reply
      0
      • R RChin

        Just insert line breaks ("\n"), in your display string. If the length of your string varies, then you might want to write a simple funtion that breaks up your input string for you before passing it on to the messagebox


        I Dream of Absolute Zero

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

        Yeah, my text varies. Guess I will have to write a splitting function then, was wondering if there was already one included in MFC. Thanks.

        RaviBeeR 1 Reply Last reply
        0
        • A Anonymous

          Yeah, my text varies. Guess I will have to write a splitting function then, was wondering if there was already one included in MFC. Thanks.

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          Here you go. :)

          //! Wraps a string at a user specified boundary and and stores
          //! each individual line in a CStringArray.
          //! @param  strString   The string to be wrapped.
          //! @param  nWrap       Wrap margin.
          //! @param  lines       Collection of wrapped lines.
          

          /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          R J 2 Replies Last reply
          0
          • RaviBeeR RaviBee

            Here you go. :)

            //! Wraps a string at a user specified boundary and and stores
            //! each individual line in a CStringArray.
            //! @param  strString   The string to be wrapped.
            //! @param  nWrap       Wrap margin.
            //! @param  lines       Collection of wrapped lines.
            

            /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

            R Offline
            R Offline
            ryuki
            wrote on last edited by
            #5

            You could create a dialog in the ressource dialog editor, with 2 buttons and 1 Editbox. Press Strg+W and the Classwizzard will come up, here you can add variables linked to the Editfield or functions that operate when buttons are pressed and more. If you set up all fine you can include the dialogclass in your app, write the sentense you want to the variable in your dialogclass,say mydialog.DoModal();, react on buttons, and have a good time. No more than 10 minutes on it all.

            RaviBeeR 1 Reply Last reply
            0
            • R ryuki

              You could create a dialog in the ressource dialog editor, with 2 buttons and 1 Editbox. Press Strg+W and the Classwizzard will come up, here you can add variables linked to the Editfield or functions that operate when buttons are pressed and more. If you set up all fine you can include the dialogclass in your app, write the sentense you want to the variable in your dialogclass,say mydialog.DoModal();, react on buttons, and have a good time. No more than 10 minutes on it all.

              RaviBeeR Offline
              RaviBeeR Offline
              RaviBee
              wrote on last edited by
              #6

              ryuki wrote: You could create a dialog in the ressource dialog editor, ... No more than 10 minutes on it all. True. But I think my solution is "better" for at least these reasons:

              • It can be generically applied to any kind of message box.
              • Less internationalization required.
              • Takes less than 10 minutes to implement. :)

              /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

              1 Reply Last reply
              0
              • RaviBeeR RaviBee

                Here you go. :)

                //! Wraps a string at a user specified boundary and and stores
                //! each individual line in a CStringArray.
                //! @param  strString   The string to be wrapped.
                //! @param  nWrap       Wrap margin.
                //! @param  lines       Collection of wrapped lines.
                

                /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

                J Offline
                J Offline
                James R Twine
                wrote on last edited by
                #7

                Might want to add some handling for strings that do not use correct spacing (i.e. do not have a single space after a comma, colon, etc.).  Wrapping can also be done right after a hyphen.    Peace! -=- James


                If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                DeleteFXPFiles & CheckFavorites (Please rate this post!)

                RaviBeeR 1 Reply Last reply
                0
                • J James R Twine

                  Might want to add some handling for strings that do not use correct spacing (i.e. do not have a single space after a comma, colon, etc.).  Wrapping can also be done right after a hyphen.    Peace! -=- James


                  If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                  Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                  DeleteFXPFiles & CheckFavorites (Please rate this post!)

                  RaviBeeR Offline
                  RaviBeeR Offline
                  RaviBee
                  wrote on last edited by
                  #8

                  Good point. I'll genericize it and will post an article soon. Thanks! /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

                  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