Board index » delphi » Transparent TLabels and Canvas draws

Transparent TLabels and Canvas draws

I have an application where I allow a user to drag TLabels around on a
form.  If I set their transparent property to True, then when I drag one
TLabel over another TLabel, I can see both captions (albeit overlaid) as
I would expect.  However, if I also display on this same form, lines and
circles drawn using methods of the Canvas object, the TLabel obscures
the lines and circles with the rectangle that the TLabel caption resides
in even though its background color is the same as the form's background
color.  What must I do to allow the lines and cirlces to "show through"
the background of the TLabel as I pass it over those lines and circles?
Thanks.
 

Re:Transparent TLabels and Canvas draws


On 18 Jun 2003, Bob Ogle <ro...@marketfacts.com> wrote:

Quote
> What must I do to allow the lines and cirlces to "show through"
> the background of the TLabel as I pass it over those lines and circles?

Do the circles and lines also have a problem if you drag another window in
front and then uncover it?  You didn't say where you were using the Canvas
draw routines and what canvas you're drawing on.  The form's canvas is not
persistent.

--
-Mike

Re:Transparent TLabels and Canvas draws


Yes, I am drawing on the form's canvas, and, yes, if I place another window
over my form, I loose the circles and lines.  For this reason, when the user
moves a TLabel, I am repetitively redrawing the circles and lines.  Still, I
would have though that if the TLabel is set to transparent, it would not wipe
out those lines and circles, if it really was transparent.  Currently, I am
redrawing the lines and circles and then repainting the TLabels.  Aha!  I just
tested not repainting the TLabels after redrawing the lines and circles and
achieved success.  Thanks.
Quote
"Mike Williams (TeamB)" wrote:
> On 18 Jun 2003, Bob Ogle <ro...@marketfacts.com> wrote:

> > What must I do to allow the lines and cirlces to "show through"
> > the background of the TLabel as I pass it over those lines and circles?

> Do the circles and lines also have a problem if you drag another window in
> front and then uncover it?  You didn't say where you were using the Canvas
> draw routines and what canvas you're drawing on.  The form's canvas is not
> persistent.

> --
> -Mike

Re:Transparent TLabels and Canvas draws


Quote
"Bob Ogle" <ro...@marketfacts.com> wrote in message

news:3EF1E593.56D93A4B@marketfacts.com...

Quote
> Yes, I am drawing on the form's canvas, and, yes, if I place another
window
> over my form, I loose the circles and lines.  For this reason, when the
user
> moves a TLabel, I am repetitively redrawing the circles and lines.  Still,
I
> would have though that if the TLabel is set to transparent, it would not
wipe
> out those lines and circles, if it really was transparent.  Currently, I
am
> redrawing the lines and circles and then repainting the TLabels.  Aha!  I
just
> tested not repainting the TLabels after redrawing the lines and circles
and
> achieved success.  Thanks.

You're better off using a TPaintBox for this; then you won't have to repaint
the circles and lines.

Cheers,
  Ignacio

Re:Transparent TLabels and Canvas draws


Thanks for the suggestion.  I may try that.  The placement of my lines and
circles can change based on the positioning and font of my TLabels, so there are
times when the original lines and circles will need to be moved.  I suppose I
can repaint the paintbox to wipe out the old placements and write the new if I
go that route.
Quote
Ignacio Vazquez wrote:
> "Bob Ogle" <ro...@marketfacts.com> wrote in message
> news:3EF1E593.56D93A4B@marketfacts.com...
> > Yes, I am drawing on the form's canvas, and, yes, if I place another
> window
> > over my form, I loose the circles and lines.  For this reason, when the
> user
> > moves a TLabel, I am repetitively redrawing the circles and lines.  Still,
> I
> > would have though that if the TLabel is set to transparent, it would not
> wipe
> > out those lines and circles, if it really was transparent.  Currently, I
> am
> > redrawing the lines and circles and then repainting the TLabels.  Aha!  I
> just
> > tested not repainting the TLabels after redrawing the lines and circles
> and
> > achieved success.  Thanks.

> You're better off using a TPaintBox for this; then you won't have to repaint
> the circles and lines.

> Cheers,
>   Ignacio

Re:Transparent TLabels and Canvas draws


Quote
"Bob Ogle" <ro...@marketfacts.com> wrote in message

news:3EF21CDB.341D146@marketfacts.com...

Quote
> Thanks for the suggestion.  I may try that.  The placement of my lines and
> circles can change based on the positioning and font of my TLabels, so
there are
> times when the original lines and circles will need to be moved.  I
suppose I
> can repaint the paintbox to wipe out the old placements and write the new
if I
> go that route.

You could also use components to draw the shapes, then move them as
required.

Cheers,
  Ignacio

Re:Transparent TLabels and Canvas draws


Hy Bob,
i did some similar movable label component. But I didn't do it as
complicated as you. I just XOR draw the picture of the label text to the
parent canvas.
Fast and simple.

Regards Horst

Other Threads