Sign in to follow this  
Sfpiano

(Win/C++) Transparent textbox idea?

Recommended Posts

I'm trying to get a transparent textbox working in windows. My idea was to grab the region of the screen where the text is going and convert it to a bitmap and use that as the background for the textbox. However I'm not sure a) how to grab just a section of the screen and b) if it's going to create too much overhead performing this operation every time the text changes.

Share this post


Link to post
Share on other sites
If you plan to target Windows 2000 and layer, you can just use SetLayeredWindowAttributes() to set a transparent color key.

Share this post


Link to post
Share on other sites
Transparency is generally easiest to achieve to ignore or disable the component's WM_ERASEBKGND. Although then you'd need to make sure parent's WM_PAINT triggers as needed, or you end up with artifacts.

This also isn't recommended for existing controls, since you have no guarantee what gets drawn on each pass.

But it's been a while, maybe there's some other way. I have a vague feeling that there's a flag you can set, or even that there is a "transparent" color.

Share this post


Link to post
Share on other sites
Ok, I disabled the onerasebackground message and put SetLayeredWindowAttributes() in my onpaint function before I do any drawing which got rid of the grey region behind the text. The problem now is anywhere there is text there's still a white box.

I tried:
SetLayeredWindowAttributes(handle(), 0xffffff, 0, LWA_ALPHA);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this