Board index » delphi » Setting the font background in an image control

Setting the font background in an image control

Quote
war...@apci.com (Martin Ward) wrote:
>Hi all,
>Can anyone explain what I'm doing wrong here?
>I have an image control, into which I am putting some text, using the
>Canvas.TextOut function.  I can change the font type and colour quite happily,
>by altering the Canvas.Font values, and am quite happily changing the colour of
>the text that is being printed out.
>The problem is that I can't get the background to change properly.
>Currently I'm doing the following:
>with imgWallpaper.Picture.Bitmap do
>begin
>    { Set the colour for the image background }
>    Canvas.Brush.Color := iBg;
>    Canvas.Brush.Style := bsSolid;
>... (Code deleted for brevity) ...
>    { Wipe the background of the image to set the background colour }
>    r.Left := 0;
>    r.Top := 0;
>    r.Right := mx - 1;
>    r.Bottom := my - 1;
>    Canvas.FillRect(r);

If you change the Canvas.FillRect(r) to a Canvas.Rectangle(..) then it
will probably work the way you want it to unless I'm missing the
problem..

Brien King
bk...@primenet.com

 

Re:Setting the font background in an image control


bk...@primenet.com (Brien King) typed:

Quote
>>        { Wipe the background of the image to set the background colour }
>>        r.Left := 0;
>>        r.Top := 0;
>>        r.Right := mx - 1;
>>        r.Bottom := my - 1;
>>        Canvas.FillRect(r);
>If you change the Canvas.FillRect(r) to a Canvas.Rectangle(..) then it
>will probably work the way you want it to unless I'm missing the
>problem..

I use FillRect() because I need to fill in the background, which Rectangle()
doesn't do.  I've been poking around and it seems to be something to do with
which colours you select for the text background.  Are there some colours that
you can't set text text backgound to?

|\/|

Re:Setting the font background in an image control


In article <4epsu3$...@netnews1.apci.com>, war...@apci.com says...

Quote

>bk...@primenet.com (Brien King) typed:

>>>      { Wipe the background of the image to set the background colour }
>>>      r.Left := 0;
>>>      r.Top := 0;
>>>      r.Right := mx - 1;
>>>      r.Bottom := my - 1;
>>>      Canvas.FillRect(r);

>>If you change the Canvas.FillRect(r) to a Canvas.Rectangle(..) then it
>>will probably work the way you want it to unless I'm missing the
>>problem..

>I use FillRect() because I need to fill in the background, which Rectangle()
>doesn't do.  I've been poking around and it seems to be something to do with
>which colours you select for the text background.  Are there some colours
that
>you can't set text text backgound to?

>|\/|

I too have had this problem.  I wanted a nice light yellow background.  
Trouble is, the TextOut method of canvas. won't allow a light yellow
background...only a very bright yellow.  It seems that none of the "dithered
colors" can be used as a Font.Color when using TextOut.

I'm looking for a solution too.

Bob

Other Threads