Board index » delphi » transparent background with textout

transparent background with textout

Hi,

when Canvas.Textout writes text onto a canvas it first clears the
background of that rectangled area and than writes the text. Is there a
way to avoid this background clearing? I guess Canvas.Copymode would
feature the functionality I need, if it affected  TextOut.

Can anyone tell me which is the equivalent to Canvas.Copymode for
Canvas.Textout?

Thanks.

Jens

 

Re:transparent background with textout


Canvas.Textout doesn't clear any rectangle with me ?

Quote
beate Reinhardt wrote:
> Hi,

> when Canvas.Textout writes text onto a canvas it first clears the
> background of that rectangled area and than writes the text. Is there a
> way to avoid this background clearing? I guess Canvas.Copymode would
> feature the functionality I need, if it affected  TextOut.

> Can anyone tell me which is the equivalent to Canvas.Copymode for
> Canvas.Textout?

> Thanks.

> Jens

  gge.vcf
< 1K Download

Re:transparent background with textout


Use SetBkMode( hDC, TRANSPARENT);

so that the current hDC has a transparent background.

Bonny,

"beate Reinhardt" <ata.scha...@web.de> schreef in bericht
news:3A1BB1B1.9E036F5D@web.de...

Quote
> Hi,

> when Canvas.Textout writes text onto a canvas it first clears the
> background of that rectangled area and than writes the text. Is there a
> way to avoid this background clearing? I guess Canvas.Copymode would
> feature the functionality I need, if it affected  TextOut.

> Can anyone tell me which is the equivalent to Canvas.Copymode for
> Canvas.Textout?

> Thanks.

> Jens

Re:transparent background with textout


"beate Reinhardt" <ata.scha...@web.de> wrote

Quote
> when Canvas.Textout writes text onto a canvas it first clears the
> background of that rectangled area and than writes the text. Is
there a
> way to avoid this background clearing? I guess Canvas.Copymode would
> feature the functionality I need, if it affected  TextOut.

> Can anyone tell me which is the equivalent to Canvas.Copymode for
> Canvas.Textout?

This Borland TI may be what you are looking for (sorry, I don't have
the number).

----------------------------------------------------
How do I make the text background transparent?

Answer:
Use the Windows API function SetBkMode().

Example:

procedure TForm1.Button1Click(Sender: TObject);
var
  OldBkMode : integer;
begin
  with Form1.Canvas do begin
    Brush.Color := clRed;
    FillRect(Rect(0, 0, 100, 100));
    Brush.Color := clBlue;
    TextOut(10, 20, 'Not Transparent!');
    OldBkMode := SetBkMode(Handle, TRANSPARENT);
    TextOut(10, 50, 'Transparent!');
    SetBkMode(Handle, OldBkMode);
  end;
end;
----------------------------------------------------

--
Regards,
Chris Luck.
Responses to newsgroup please.

Re:transparent background with textout


Quote
In article <3A1BB1B1.9E036...@web.de>, beate Reinhardt wrote:
> when Canvas.Textout writes text onto a canvas it first clears the
> background of that rectangled area and than writes the text. Is there a
> way to avoid this background clearing?

Set canvas.brush.style to bsClear, that has the same effect as using
SetBkMode( canvas.handle, TRANSPARENT ). The default bkMode is OPAQUE, so
the space between characters is filled with the brush color.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads