[Windows] Layered windows with per-pixel alpha

BlitzMax Forums/BlitzMax Programming/[Windows] Layered windows with per-pixel alpha

grable(Posted 2017) [#1]
This sample uses UpdateLayeredWindow for per-pixel alpha transparency of a window.
Im posting it here as well for future reference.

The image i used: coca.png
But you can use any image with an alpha channel.




Henri(Posted 2017) [#2]
Hi,

at some point you can't drag the picture anymore ?

-Henri


grable(Posted February) [#3]
Hmm, a friend of mine complained about the same thing, he is also running Windows 7.
Im on Windows 10 and i can drag it as much as i want :/

Must be some incompatibility between UpdateLayeredWindow in W7 and W10 then....

Could you check if the various move states are entered?
MouseDown/Up, ismoving and that pos really is changing.

Other than that its UpdateLayeredWindow that is moving the image.

EDIT: I added some error checking, it should print an error if any of the APIs complain.


grable(Posted February) [#4]
I think i nailed it down.

In Windows 10, UpdateLayeredWindow moves the window in addition to drawing at the supplied position, Windows 7 does not.
This ends up with MOUSE_UP not firing when moving outside the 256x256 region, the size of the window.

Adding this after UpdateLayeredWindow on Windows 7 will make it work the same as Windows 10.
SetGadgetShape window, pos[0],pos[1], window.Width,window.Height
Added it to top post.