Sign in to follow this  

Background problems

This topic is 4393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I make a simple window by using win32. I use WNDCLASSEX and the method CreateWindowEx:
HWND myWnd;
WNDCLASSEX WndClass;
...
WndClass.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
WndClass.lpszClassName = "MyWindow";
...
RegisterClassEx(&WndClass);
myWnd = CreateWindowEx(WS_EX_APPWINDOW, "MyWindow",...,NULL, hInstance,...);

Everything here work perfectly and my window is created with nice gray background. But when I add a child...
HWND TextTitle;
...
TextTitle = CreateWindowEx(WS_EX_TRANSPARENT, "STATIC",..., myWnd, hInstance,...);

The WS_EX_TRANSPARENT must set an transparent backgorund of the text, so everything around the text to be the same color as whole window. But background of the STATIC is still COLOR_BTNSHADOW. How can I set background of static to be the same as background of window ?

Share this post


Link to post
Share on other sites
You can't. You can use WM_CTLCOLOR to apply the same single color as the background window. If you want any image of the parent window you're better off to draw the text in WM_PAINT or better WM_ERASEBKGND of the parent.

WS_EX_TRANSPARENT does not to what most people think. It does not tell windows to ignore the background of the control. It actually means that if a window below gets repainted your window gets repainted as well.

Share this post


Link to post
Share on other sites
Nothing of this will work (I've tried WM_ERASEBKGND). This is because system draws background of STATICs - COLOR_BTNSHADOW and EDITs COLOR_WINDOWFRAME (White). I must use SS_OWNERDRAW style and draw the static text with background I want. The problem is I don't know exactly how to draw a STATIC, BUTTON or any other controls. :( Where can find some information about this ???

Share this post


Link to post
Share on other sites

This topic is 4393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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