Add shadow to WS_EX_LAYERED

Hi,
I have a pop-up window that is centered in my main application. Its purpose is to display an image with some fade-in/fade-out properties. I would like to have it to drop a shadow, so it's easier to see its dimension. But I had no luck. I tried with CS_DROPSHADOW, but it has no effect. Is it possible to do, or do I need to draw it myself?

Here is the window initialization code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
	//Creates windows class information
	WNDCLASSEX wcex; 

	ZeroMemory(&wcex, sizeof(wcex));

	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.lpfnWndProc    = StaticWndShow;
	wcex.style			= CS_OWNDC;
	wcex.hInstance      = GetModuleHandle(NULL);
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground  = CreateSolidBrush(BACKGROUND);
	wcex.lpszClassName  = NAME;

	//Calls register, any error: create messagebox and exit program.
	if (!RegisterClassEx(&wcex)) { 
		MessageBox(NULL,_T("Window registration failed!"),NULL,NULL);
		PostQuitMessage(0);
	}

	//Creates window.
	HSHOW = CreateWindowEx( 
		WS_EX_LAYERED,
		NAME,
		NAME,
		WS_POPUP | WS_VISIBLE,
		0, 0,
		0, 0,
		hwnd,
		NULL,
		GetModuleHandle(NULL),
		(void*)this);
		
	//If any error occured, calls messagebox and exit program.
	if (!HSHOW) { 
		MessageBox(NULL,_T("Window creation failed!"),NULL,NULL);
		PostQuitMessage(0);
	}


Regards,

Simon H.A.
You should use SetLayeredWindowAttributes function:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633540(v=vs.85).aspx
It's not the transparency I'm having trouble with. I just want a shadow drop like you have with regular windows.
You should stick with UpdateLayeredWindow and draw your own shadow yourself, or discard the layered in favour of regions which also allow for 1bit transparency
Last edited on
Okay, I'll just do the shadow myself. Thanks for the answers.

Regards,

Simon H.A.
Topic archived. No new replies allowed.