Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TMemo and Vertical Alignment

844 views
Skip to first unread message

Cooper

unread,
Apr 18, 2010, 11:56:06 AM4/18/10
to
Hello,
I have a TMemo in a form. This TMemo has a Height and a Weight. I want that
text in this TMemo is align vertically. I have checked for property:
Memo.Aligment and scrolling help from delphi found: "taAlignTop" but is of
type: TVerticalAlignment and of course not are compatible type.
I need use other property? Or there is some solution for solve it?
Thanks very much.
Cooper.

Jamie

unread,
Apr 19, 2010, 1:51:07 AM4/19/10
to
Cooper wrote:

I think what you mean is the FONT to be formatted the same on all lines.
for that, you don't use a true type font.

Use a raster type font. try the SYSTEM font..

Maarten Wiltink

unread,
Apr 19, 2010, 3:28:21 AM4/19/10
to
"Cooper" <coo...@blueware.it> wrote in message
news:qYFyn.159163$9f6.2...@twister1.libero.it...

> [...] I want that text in this TMemo is align vertically.

What do you mean by that?

Groetjes,
Maarten Wiltink


Cooper

unread,
Apr 19, 2010, 7:15:33 AM4/19/10
to
"Maarten Wiltink" <maa...@kittensandcats.net> ha scritto nel messaggio
news:4bcc0665$0$22945$e4fe...@news.xs4all.nl...

> "Cooper" <coo...@blueware.it> wrote in message
> news:qYFyn.159163$9f6.2...@twister1.libero.it...
>
>> [...] I want that text in this TMemo is align vertically.
>
> What do you mean by that?
>
for example try with a simple design:

****************************
* *
* My text *
* *
****************************

I have solved this problem changing value to margin top in function of
lenght of text (if one, two or more row). But i have hoped in a better
solution.
Thanks again.
Cooper.

alang...@aol.com

unread,
Apr 19, 2010, 9:46:47 AM4/19/10
to
On 19 Apr, 12:15, "Cooper" <coo...@blueware.it> wrote:
<snip>

> I have solved this problem changing value to margin top in function of
> lenght of text (if one, two or more row).

Here's one which counts the lines for you.
var
TextHt, MemoLines, TextLines, TopLines, i : integer;
begin
TextHt := -1 * Memo1.Font.Height;
MemoLines := (Memo1.Height - 2) div TextHt;
Memo1.Lines.BeginUpdate;
Memo1.Text := '';
Memo1.Text := MyText;
TextLines := Memo1.Lines.Count;
TopLines := (MemoLines - TextLines) div 2;
for i := 1 to TopLines - 1 do
Memo1.Lines.Insert(0,' ');
Memo1.Lines.EndUpdate;
end;

> But i have hoped in a better
> solution.

You could draw on the Form's surface on TForm.Canvas, or on a
TIMmage.Canvas on the form. Set .Canvas.Brush.Color & use FillRect to
draw the background. Then DrawText() with DT_CALCRECT to get the
rectangle containing the text & then placing that on the background
with another DrawText() call.

DrawText() is a windows API - look in Win32 Help.

Alan Lloyd

Cooper

unread,
Apr 19, 2010, 12:09:47 PM4/19/10
to

<alang...@aol.com> ha scritto nel messaggio
news:c41a53fe-6cf5-4252...@k36g2000yqb.googlegroups.com...

Thanks very much :) i try.

Jamie

unread,
Apr 20, 2010, 6:35:55 AM4/20/10
to
Have you tried using TAB characters in the strings?


Cooper

unread,
Apr 19, 2010, 6:50:25 PM4/19/10
to
"Jamie" <jamie_ka1lpa_not_v...@charter.net> ha scritto nel
messaggio news:sU4zn.224693$wr5....@newsfe22.iad...

> Have you tried using TAB characters in the strings?
>
Mmm, not understood :( in sense?

Maarten Wiltink

unread,
Apr 20, 2010, 3:22:41 AM4/20/10
to
"Jamie" <jamie_ka1lpa_not_v...@charter.net> wrote in message
news:sU4zn.224693$wr5....@newsfe22.iad...

> Cooper wrote:
>> "Maarten Wiltink" <maa...@kittensandcats.net> ha scritto nel messaggio
>> news:4bcc0665$0$22945$e4fe...@news.xs4all.nl...
>>> "Cooper" <coo...@blueware.it> wrote in message
>>> news:qYFyn.159163$9f6.2...@twister1.libero.it...

>>>> [...] I want that text in this TMemo is align vertically.
>>>
>>> What do you mean by that?
>>
>> for example try with a simple design:
>>
>> ****************************
>> * *
>> * My text *
>> * *
>> ****************************
>>
>> I have solved this problem changing value to margin top in function of
>> lenght of text (if one, two or more row). But i have hoped in a better
>> solution.
>

> Have you tried using TAB characters in the strings?

Vertical tabs?

Groetjes,
Maarten Wiltink


0 new messages