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

WordWrap text on Canvas?

24 views
Skip to first unread message

Bob

unread,
Aug 20, 2001, 5:04:26 AM8/20/01
to
Hi,

I can write a text on Canvas, but the text can be longer than Canvas width.
Is there any function (or algorithm) in Delphi, which wraps text written on
the Canvas?

Thanks Bob


Quasidata

unread,
Aug 20, 2001, 5:29:31 AM8/20/01
to
Hello Bob,

There is a Win32 API function, DrawText.

const
AlignFlags: array[TAlignment] of Integer = (DT_LEFT, DT_RIGHT, DT_CENTER);

var
MyFlags: Integer;
MyText: string;
MyRect: TRect;
MyAlignment:TAlignment;
MyCanvas: TCanvas;

MyFlags := AlignFlags[MyAlignment];
Windows.DrawText(MyCanvas.Handle, PChar(MyText), -1, MyRect, MyFlags);

--
Andrei Fomine.
Add full-blown clipboard and drag-and-drop capabilities to any control with
Transfer@once.
DbAltGrid allows multi-line layout and RTF text in a DBGrid descendant.
http://www.quasidata.com/


"Bob" <little...@seznam.cz> wrote in message news:3b80d2a3_1@dnews...

Bob

unread,
Aug 20, 2001, 9:01:26 AM8/20/01
to
Thanks Andrei

"Quasidata" <quasidata AT quasidata DOT com> wrote in message
news:3b80d86a_2@dnews...

Peter Below (TeamB)

unread,
Aug 20, 2001, 9:04:28 AM8/20/01
to

You have to use an API function for this, DrawText (see win32.hlp). Pass it
the canvas.handle as first parameter. Search the newsgroup archives or the
VCL source for examples.

http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Manuel Algora

unread,
Aug 20, 2001, 11:56:48 AM8/20/01
to
On Mon, 20 Aug 2001 13:29:31 +0400, "Quasidata" <quasidata AT
quasidata DOT com> wrote:

>There is a Win32 API function, DrawText.
>
>const
> AlignFlags: array[TAlignment] of Integer = (DT_LEFT, DT_RIGHT, DT_CENTER);

He rather needs

Const
WordWrap: array[Boolean] of Word = (DT_SINGLELINE, DT_WORDBREAK);

Manuel Algora
m...@encomix.es

0 new messages