Click to See Complete Forum and Search --> : Transparent Controls?
MikeThrel
May 18th, 2000, 03:27 AM
I'm using VB6.
I have a form with a gradient background that fades from blue to white, going from the top of the form to the bottom of the form.
I also have some frames on the form that contain some controls. Is there a way I can make the frames transparent so with the border of the frame still visible so that the user see's the controls grouped together? If not, what container control should I use to accomplish the same functionality that the frames are currently providing for me?
I want to do this so that my form's gradient background is visible and the frames won't throw a big chunk of solid color into the middle of the form.
Thanks in advance,
Mike T.
use the shape control, and use a square.. make sure the backstyle is transparent and not opaque
MikeThrel
May 18th, 2000, 04:11 AM
I tried that but couldn't put controls inside the shape control.....was I doing something wrong? Can the shape control be used as container control?
Oh, I didnt know you needed a container..
I use the shape as a grouping tool...
I cannot find a container that can have a transparent background...
sorry.....
MikeThrel
May 18th, 2000, 05:36 AM
OK, Thanks Dennis.
Anybody else?
Stevie-O
May 19th, 2000, 01:06 AM
It's possible to create a transparent control.
However, due to Microsoft's bumbling, there's one big restriction: you can't move it around.
This means making transparent areas on anything that the user can move around is impossible.
This applies to transparent areas that are part of the window; i.e. the window can blit over them and it will affect the image below it (example: a "highlighter" window that would highlight anything below it).
The other type of transparency is created by using SetWindowRegion. That type of transparency is created by changing the visible part ("region") of the window from its usual rectangle to a complex area. This has a 'cookie cutter' effect on the window; any part of the window that lies outside the cookie cutter shape is not drawn, and if the user clicks in those areas, it goes right through to the window under it.
I believe you wish to have the first type of transparency, since the cookie-cutter method cuts out any contained controls.
I recommend this algorithm:
Give each frame the WS_EX_TRANSPARENT extended style.
Subclass the frames and intercept WM_ERASEBKGND and WM_PAINT, to do your own painting.
These API functions will be extraordinarily helpful to you (all may be found on MSDN):
GetWindowLong - Window style and subclassing
SetWindowLong - Window style and subclassing
CallWindowProc - Subclassing
SetProp - Subclassing
GetProp - Subclassing
RemoveProp - Subclassing
BeginPaint - Painting
DrawText - Painting
DrawEdge - Painting (automatically draws a frame border)
EndPaint - Painting
And this undocumented VB function:
ObjPtr - Subclassing
A PictureBox is a container. Just create a BMP file of how you want the frame to look like, convert it to GIF (so it has a transparent background) and then load it up into a PictureBox.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.