 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Vladimir Stefanovic Guest
|
Posted: Wed Apr 28, 2004 1:56 pm Post subject: String special formating |
|
|
Hello,
I saw some apps that have a TreeView or ListBox
which can host string items that are formated (colors
and font syles) . The classic example can be some
'Grep' like app that marks the words it has found.
I mean - the SAME string item has more than one
color and font style.
Is there some way to accomplish that with standard
VCL components? I need just tips...
Thanks,
Vladimir Stefanovic
|
|
| Back to top |
|
 |
Eelke Klein Guest
|
Posted: Wed Apr 28, 2004 2:08 pm Post subject: Re: String special formating |
|
|
Vladimir Stefanovic wrote:
| Quote: | Hello,
I saw some apps that have a TreeView or ListBox
which can host string items that are formated (colors
and font syles) . The classic example can be some
'Grep' like app that marks the words it has found.
I mean - the SAME string item has more than one
color and font style.
Is there some way to accomplish that with standard
VCL components? I need just tips...
The TTreeView has some CustomDraw events while the TListView has the |
OwnerDraw property and some events. More information can be found in the
BCB help.
Eelke
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Apr 28, 2004 5:21 pm Post subject: Re: String special formating |
|
|
"Vladimir Stefanovic" <antivari (AT) ptt (DOT) yu> wrote
| Quote: | Is there some way to accomplish that with
standard VCL components?
|
Simply owner-drawn the standard components. Many have an OwnerDraw property
and cooresponding OnDraw event(s). Simply draw on the component's Canvas
anyway you want. In the case of drawing a multi-colored string, you will
have to first change the Canvas's Pen/Font Color, then draw a piece of text,
then calculate the length of the piece using the Canvas's TextWidth()
method, then change the Color again, then draw another text piece of text
offsetted by the positioning and width of the previous piece, then calculate
the length of the new piece, and so on for all the colors that you want to
draw.
Gambit
|
|
| Back to top |
|
 |
Vladimir Stefanovic Guest
|
Posted: Wed Apr 28, 2004 6:36 pm Post subject: Re: String special formating |
|
|
| Quote: | [...] In the case of drawing a multi-colored string, you will
have to first change the Canvas's Pen/Font Color, then draw a piece of
text,
then calculate the length of the piece using the Canvas's TextWidth()
method, then change the Color again, then draw another text piece of text
offsetted by the positioning and width of the previous piece, then
calculate
the length of the new piece, and so on for all the colors that you want to
draw.
|
This is quite enough information to start.
Thanks Remy.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|