Sign in to follow this  
Illuminate

Background problems

Recommended Posts

Illuminate    139
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
Endurion    5408
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
Illuminate    139
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

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