Making controls semi-transparent? Not having much luck..
I have searched up and down and could not find what I need. Several post on these forums have revealed themselves but nothing of use.
What I am trying to do is make a specific control have an adjust opacity value. I have tried using the technique for forms but it does not work with controls.
Code:
Call SetWindowLong(theControl.hwnd, GWL_EXSTYLE, GetWindowLong(theControl.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
Call SetLayeredWindowAttributes(theControl.hwnd, 0, bytOpacity, LWA_ALPHA)
I've been able to make the background completely transparent but I only need partial, or a way to fill behind the object with another transparent color.
The control I am trying to work with is an RichTextBox.
Re: Making controls semi-transparent? Not having much luck..
In order to set a window as layered, you have to add the ws_ex_layered attribute, as your code shows.
But reading the msdn documentation for that attribute, you will see it does NOT apply to child windows
Quote:
Originally Posted by MSDN
WS_EX_LAYERED
The window is a layered window. Note that this cannot be used for child windows. Also, this cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.
There is no easy solution and a couple have been discussed on this forum several times. You may want to try searching on this forum for: SetLayeredWindowAttributes child
Re: Making controls semi-transparent? Not having much luck..
Hmm, I guess what would actually work is to have a look at how vbAccelerator's RichEdit control manages it's background image drawing and then take LaVolpe's hacked method to draw transparency in some controls, then simply apply a custom drawing routine that'll handle the semitransparent drawing (I guess easiest would be the AlphaBlend API).
So this should sound like a possible project, but it'll be complex, it would use advanced techniques and it is unlikely anyone would do it for you.
Re: Making controls semi-transparent? Not having much luck..
Thank you for the suggestions, I however am not interested in adding additional components to my application. I have discovered that making a control have a completely transparent background, while painting a picture-box beneath it can have an equally as appealing look.