Board index » delphi » Making memo text resize

Making memo text resize

This seems like a easy thing to do but I cant seem to find a way to do it.
I want to have the text adjust in the trichedit control as I resize the
window.  It works if I sqeeze the window but not if I enlarge it.

thanks,

t

 

Re:Making memo text resize


Quote
In article <3d1c918a$1_1@dnews>, "Tim" <tteasd...@mmm.com> wrote:
> This seems like a easy thing to do but I cant seem to find a way to do it.
> I want to have the text adjust in the trichedit control

You have a Memo or a RichEdit? You don't seem sure.
Never mind, its the same answer for both.
Quote
> as I resize the
> window.  It works if I sqeeze the window

and if you just squeeze it just a little bit, does it break one line into
two, with the second line being very short? ..
Quote
> but not if I enlarge it.

.. because I think you have put Carriage Return characters in the text. Take
them out, except where you really want one, say at a new paragraph.

-Iain.

Re:Making memo text resize


On Sat, 29 Jun 2002 04:53:04 +0100, "Iain Macmillan"

Quote
<h...@ariesps.co.uk> wrote:
>.. because I think you have put Carriage Return characters in the text.

It's the control itself that does it. Open the Lines property editor
in the Object Inspector. Write a long line of  text. Close the editor.
Reopen it: you'll see the long line is formatted into several lines
with carriage returns, according to the size of the memo. Resize the
memo to a smaller width: more carriage returns are added, but in such
a way that now the lines display broken. Make the memo of a longer
width: no change at all, same bad display.

I would like to know the solution myself -other than deriving a fixed
TMemo descendant, preferably.

Manuel Algora
ceni...@wanadoo.es

Re:Making memo text resize


Quote
"Manuel Algora" wrote...
> >.. because I think you have put Carriage Return characters in the text.

> It's the control itself that does it. Open the Lines property editor
> in the Object Inspector. Write a long line of  text. Close the editor.
> Reopen it: you'll see the long line is formatted into several lines
> with carriage returns, according to the size of the memo. Resize the
> memo to a smaller width: more carriage returns are added, but in such
> a way that now the lines display broken. Make the memo of a longer
> width: no change at all, same bad display.

> I would like to know the solution myself -other than deriving a fixed
> TMemo descendant, preferably.

At design time set WordWrap to False and at runtime
set it back to True (in the Form.OnShow for instance).

--
Pieter

Re:Making memo text resize


On Sat, 29 Jun 2002 16:37:08 +0200, "Pieter Zijlstra"

Quote
<pzijlstr...@freeler.nl> wrote:
>At design time set WordWrap to False and at runtime
>set it back to True (in the Form.OnShow for instance).

I put it in the Form's OnCreate, and works great, thanks! (The only
problem is when having to edit long lines in the editor without
wordwrap, but one cannot have everything it seems).

Manuel Algora
ceni...@wanadoo.es

Re:Making memo text resize


In article <ce9rhukiv2ipl94tqqtq63u3erfo50c...@4ax.com>, Manuel Algora

Quote
<ceni...@wanadoo.es> wrote:
>>.. because I think you have put Carriage Return characters in the text.
> It's the control itself that does it. Open the Lines property editor
> in the Object Inspector.

Oh, using the object inspector!
(it's the editor rather than the 'control itself')
And if you ask it to edit 'Lines' I suppose lines is what you will get,
reasonably enough.
I have been thinking about whether RAD really has any place in a finished
program, perhaps it is just for knocking up a quick prototype. (I intend to
refine my argument about this, I'm not really ready to kick off a full
discussion of it yet - and I know there are arguments against, too).
But this is yet another example, for my casebook, where loading at runtime
is better than using RAD.

Quote
> I would like to know the solution myself -other than deriving a fixed
> TMemo descendant, preferably.

M.Text:='Some line';
M.Lines[M.Lines.Count-1]:=M.Lines[M.Lines.Count-1]+'  and some more stuff.';
 .. etc. (I usually stick this last line in a proc called Addtext or
something).
If you use it often enough, making a descendant with an Addtext method looks
like a good way to go.

Another way: stick the text into a file and loadfromfile!

There should be a solution using SetTextBuffer, too (is this not what this
method is for?), but I haven't played with this.

Other Threads