Coloring a Memo
I know with a richtext this can be done, but is there any way to have
different lines in a memo be a different color? I load a tppmemo at
run time with events from a game and would like all away games for
example to be red and home games be blue. Can this be done without
having to switch to a richtext?
different lines in a memo be a different color? I load a tppmemo at
run time with events from a game and would like all away games for
example to be red and home games be blue. Can this be done without
having to switch to a richtext?
This discussion has been closed.
Comments
fonts.
The only other way to do this without the rich text component is to
dynamically create TppDrawText objects (one for each line of memo text) and
set the font color on the DrawText command. You can access the lines of teh
memo after it has generated in the band by using the OnDrawCommandCreate
event to get a handle to the draw command on the page which is create for
the memo. Then you'll need to use the Report.OnEndPage event to loop
through the draw commands which have been created for the page. I would
stick them in a TList in the OnDrawCommandCreate events, so you can quickly
get at them at the end of the page in case more than one memo prints on a
page. Then you can read the draw commands TList at the end of each page and
pull out the lines by reading the property WrappedText which is a TStrings.
Then just create TppDrawText object and assign the page. Here is a demo of
dynamically creating draw commands for a page. You'll want to take the
memo's top, left,width and height ot figure out where on the page to start
creating the darw commands. Once all of the draw text commands have been
created, you can free the memo DrawText commands form the page.
http://www.digital-metaphors.com/tips/AddDrawCommandToPage.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com