Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I text wrap the message Dialog box? 3

Status
Not open for further replies.

Jayz

ISP
Feb 17, 2002
59
0
0
Is there a way to text wrap the message that is in a messageDlg box?. Much more pleasing to the eye than having this one one long box.

The only other option I can think of is to open my message in another form.
 
hi

MessageDlg('text..bla.. bla.. bla.. + #13#10 + #13#10 +
'more text... ' + #13#10 +
'more text... ', mtError, [mbYes, mbNo], 0)

//#13#10 := line break;

Hope this help.

cheers, m
 
Try this line:
Code:
  MessageDlg('Hi this is my very long line.' + #13#10 + 'And this is a new line', mtInformation, [mbOK], 0);
or
Code:
  MessageDlg('Hi this is my very long line.'#13#10'And this is a new line', mtInformation, [mbOK], 0);
Either line works but the former may be more readable!
The #13#10 does a carriage-return–line-feed Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Thankyou both for your great tips.
 
Or for a wrap that works regardless of which text you put in (especially when handling user input of varying length), you could use an own derivate of TCustomDialog (I think that's the appropriate base class but I'm not sure).

Give it a nice big TLabel and set it's Wrap property on, have the FormCreate resize the label as appropriate, give it a method to change the label's caption and you're set - Just create an object of your new class, set it's label and size in code, and call it with ShowModal.

For just one message of which you know the contents beforehand, this is of course a lot of unnecessary work... In such a context, just using line breaks is a lot simpler and more efficient. But eventually you're going to need this sort of custom dialog quite a few times throughout your various applications. The good news is that, if written right, you only have to write it once and can then use it in all your new applications.
 
Hehe, it's actually laziness on my behalf...

I've come from Java, but I had to write 6 weeks in Delphi for a specific project. Rather than spending all my time trying to get to know all the existing components and picking appropriate ones, I went the java way and wrote almost anything I needed that seemed even slightly exotic myself :)

Seeing as Delphi ships with a huge amount of mostly redundant components, I wouldn't even be surprised if there was one among the many that did exactly what I just described, lol... But I didn't want to browse through them all looking for it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top