Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

window invisible when using WS_EX_LAYERED

766 views
Skip to first unread message

Vincent Torri

unread,
May 2, 2009, 9:46:14 AM5/2/09
to
Hi,

I want to test the function UpdateLayeredWindow, so i wrote a small test
app that created a window with a blue content.

If I do not use WS_EX_LAYERED, the window is correctly displayed

If I use WS_EX_LAYERED, the window is created (it appears in the task
bar) but it is invisible

The windows is not a child one.

The source code can be found here:

http://www.maths.univ-evry.fr/pages_perso/vtorri/files/layer.c

does someone see the problem ?

thank you

Sylvain SF

unread,
May 2, 2009, 11:02:45 AM5/2/09
to
Vincent Torri a �crit :

> Hi,
>
> I want to test the function UpdateLayeredWindow, so i wrote a small test
> app that created a window with a blue content.
>
> If I do not use WS_EX_LAYERED, the window is correctly displayed
>
> If I use WS_EX_LAYERED, the window is created (it appears in the task
> bar) but it is invisible

according MSDN, when WS_EX_LAYERED is set:
"the layered window will not become visible until the
"SetLayeredWindowAttributes or UpdateLayeredWindow
"function has been called for this window"

it appears you don't use any of them.
your handler for WM_PAINT contains UpdateLayeredWindow
in a comment block, may be one of your tries; but you
can NOT use it at this location: your window is not visible
so the WM_PAINT won't be called and this late-call does not
change the things.

you can use UpdateLayeredWindow() in a paint proc. to change
the layout of the layer but only it is visible ie if it was
initialised using SetLayeredWindowAttributes.

other remarks:
- the layer_shutdown function is useless, you never need to
free the exec. module.
- the initialisation of layer_data is constant, it should
be done in init_layer instead of paint_layer.
- whereever this init. of layer_data is done I didn't suceess
to have it to work with the layered style - I didnt check it
in details but simply remove it.

rewrote file is available at <http://cjoint.com/?fegNAlYJIx>

Sylvain.

Vincent Torri

unread,
May 2, 2009, 11:41:35 AM5/2/09
to
Sylvain SF <syl...@boiteaspam.info> �crivait
news:49fc6088$0$17077$ba4a...@news.orange.fr:

> Vincent Torri a �crit :
>> Hi,
>>
>> I want to test the function UpdateLayeredWindow, so i wrote a small
>> test app that created a window with a blue content.
>>
>> If I do not use WS_EX_LAYERED, the window is correctly displayed
>>
>> If I use WS_EX_LAYERED, the window is created (it appears in the task
>> bar) but it is invisible
>
> according MSDN, when WS_EX_LAYERED is set:
> "the layered window will not become visible until the
> "SetLayeredWindowAttributes or UpdateLayeredWindow
> "function has been called for this window"

hooo, i didn't read the documentation carefully. Thank you !

> it appears you don't use any of them.
> your handler for WM_PAINT contains UpdateLayeredWindow
> in a comment block, may be one of your tries; but you
> can NOT use it at this location: your window is not visible
> so the WM_PAINT won't be called and this late-call does not
> change the things.

ok, i understand why UpdateLayeredWindow is not sufficient in that
function

> you can use UpdateLayeredWindow() in a paint proc. to change
> the layout of the layer but only it is visible ie if it was
> initialised using SetLayeredWindowAttributes.
>
> other remarks:
> - the layer_shutdown function is useless, you never need to
> free the exec. module.

ok, but i usually prefer freeing the resources that i have allocated

> - the initialisation of layer_data is constant, it should
> be done in init_layer instead of paint_layer.

yes. I do that in the 'real' program. The code is just a test one.

> - whereever this init. of layer_data is done I didn't suceess
> to have it to work with the layered style - I didnt check it
> in details but simply remove it.

well, it works for me. Maybe the remark : "Note that once
SetLayeredWindowAttributes has been called for a layered window,
subsequent UpdateLayeredWindow calls will fail until the layering style
bit is cleared and set again." is what you want.

> rewrote file is available at <http://cjoint.com/?fegNAlYJIx>
>
> Sylvain.
>

thank you very much. I've spent 2 days to find the problem. It's just me
not reading the doc carefully enough.

PS: the code that seems to work for me:

http://www.maths.univ-evry.fr/pages_perso/vtorri/files/layer2.c

Sylvain SF

unread,
May 2, 2009, 12:42:57 PM5/2/09
to
Vincent Torri a �crit :

>>
>> - the layer_shutdown function is useless, you never need to
>> free the exec. module.
>
> ok, but i usually prefer freeing the resources that i have allocated

good habit.
you would do this way for a library (a .DLL) that _you_ have
loaded with LoadLibrary(), here you're trying to free the exec.
module that the system (not you) have loaded, because the running
code obviously belong to that module, your call has no effect.

> well, it works for me. Maybe the remark : "Note that once
> SetLayeredWindowAttributes has been called for a layered window,
> subsequent UpdateLayeredWindow calls will fail until the layering style
> bit is cleared and set again." is what you want.

exact, I called CreateDIBSection before SetLayeredWindowAttributes.

Sylvain.

0 new messages