Discussion:
own Button
(too old to reply)
Dirk Hennings
2004-01-24 14:05:14 UTC
Permalink
Hi,

I made my own Button and derived it from TCustomControl to have the
focused-property and taborder.
The Button has different states and in the paint-procedure I paint on the
canvas.
Now I want the button to be transparent.
I place the button on an image and want the image to be seen through at a
specific color of my button.

Is this possible with OS Win 2000, Win XP and Win 98?
Any ideas?

Dirk
Yorai Aminov (TeamB)
2004-01-25 06:05:25 UTC
Permalink
Post by Dirk Hennings
Now I want the button to be transparent.
Windows doesn't really support control transparency. There are several
hacks that can be used to emulate transparency.

Under Windows XP, you can implement transparent controls, provided
that your application uses visual styles.

Try searching the newsgroups (http://groups.google.com) and Delphi
component sites - this issue has been discussed in length in the past,
and several third party controls supporting transparency are
available.

---
Yorai Aminov (TeamB)
http://develop.shorterpath.com/yorai
(TeamB cannot answer questions received via email.)
Florent Ouchet
2004-01-26 09:47:03 UTC
Permalink
Post by Yorai Aminov (TeamB)
Under Windows XP, you can implement transparent controls, provided
that your application uses visual styles.
It works for windows 2k pro too.

For windows 9x, I have seen some component doing transparency.

Florent
David Powell
2004-01-26 08:40:11 UTC
Permalink
Controls based on TGraphic control can be truly transparent because they
draw themselves on the parent control, for example TLabel. However this may
not suit your purpose.

You could however specifiy a property "BackgroundTImage" and use that
property in the drawing stage to simply copy the area from the TImage to you
button. this works well for fake transparency. The main problem with this
method is that if the image proportions change then you have to re-render
the button so it fits with the background image.


Dave
Dirk Hennings
2004-01-26 09:50:11 UTC
Permalink
Hmm,

I'm thinking about that.
But how can I copy the exact portion of my parent into a picture?

Dirk
Post by David Powell
You could however specifiy a property "BackgroundTImage" and use that
property in the drawing stage to simply copy the area from the TImage to you
button.
David Powell
2004-01-26 12:08:41 UTC
Permalink
Well you can use CopyRect from the TImage's canvas, but you will need to
convert from your components client co-ordinate system to the TImage's
co-ordinate system. This can be done like this:

ARect.TopLeft :=
AImage.ScreenToClient(MyControl.ClientToScreen(MyControl.ClientRect.TopLeft)
);

ARect.BottomRight :=
AImage.ScreenToClient(MyControl.ClientToScreen(MyControl.ClientRect.BottomRi
ght));

This will give you the rect to copy from the TImage.


Dave
Post by Dirk Hennings
Hmm,
I'm thinking about that.
But how can I copy the exact portion of my parent into a picture?
Dirk
Post by David Powell
You could however specifiy a property "BackgroundTImage" and use that
property in the drawing stage to simply copy the area from the TImage to
you
Post by David Powell
button.
Loading...