What is a layered window?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Yamiko_Hikari
Posts: 9
Joined: 03 Nov 2020, 14:19

What is a layered window?

Post by Yamiko_Hikari » 07 Nov 2020, 10:01

I have tried to find out what a layered window is a lot, but google results and search results on this forum give no explanation to what a layered window actually is.
Please help me understand what it is and maybe also why it is used for drawing with GDI+

User avatar
boiler
Posts: 16932
Joined: 21 Dec 2014, 02:44

Re: What is a layered window?

Post by boiler » 07 Nov 2020, 11:09

This page explains what layered windows are and what their benefits are. They are used for GDI+ because that's how Windows has implemented it. That is also described (referencing GDI) in the linked page.

Yamiko_Hikari
Posts: 9
Joined: 03 Nov 2020, 14:19

Re: What is a layered window?

Post by Yamiko_Hikari » 07 Nov 2020, 21:41

boiler wrote:
07 Nov 2020, 11:09
This page explains what layered windows are and what their benefits are. They are used for GDI+ because that's how Windows has implemented it. That is also described (referencing GDI) in the linked page.
Thank you!

stretchymantis
Posts: 10
Joined: 13 Nov 2021, 22:24

Re: What is a layered window?

Post by stretchymantis » 20 May 2022, 10:37

This was very resourceful, thanks!

doubledave22
Posts: 343
Joined: 08 Jun 2019, 17:36

Re: What is a layered window?

Post by doubledave22 » 20 May 2022, 12:36

I have grown to love layered windows

The positives:
1) I use them to display very high quality icons/images/text/custom drawings with background transparency that have no artifacts (as opposed to using winset, transcolor or a GUI). Imagine perfectly displayed circles, or rectangles with rounded edges. Not really possible with standard guis.

2) It can also be good for more animation based GUI's since updating frames on various layers can be very smooth.

3)You also end up with several ways to hide/show the GUI which I find useful such as clearing the graphics, using UpdateLayeredWindow with the 0 for the alpha channel, setting the image or text itself to 0 transparency, not to mention the standard hide/show/create/destroy gui commands. It gives a lot of flexibility for moving around and hiding/showing windows without the need for detecthiddenwindows.

The drawbacks:
1) You have to update the layered window's X/Y/W/H whenever you move or resize before your next update of the window's graphics otherwise the window will be redraw at its previous location. Also if the layered window is resized larger then the graphics need to rebuilt for the window (however it's quite fast to do so).

2) You can't really mix the standard windows/gui controls like gui, add, button to a layered window. Everything you draw has to be custom.

3) On operating systems below Windows 8 I believe, you cant attach child layered windows to a parent layered window. Therefore you end up with a +owner relationship which can be hard to manage when moving or resizing the parent/owner window.

4) You have to set your own triggers to events on controls. Again on OS < Windows 8 you also cant overlay a default control (like gui, add, text) below your custom drawn control. This means if we want to support Win 7 and below we cant just put a glabel on a hidden text control under our custom drawn control. We have to rely on windows messages like WM_LBUTTONUP and process the click locations to trigger events. It's quite tedious work but ultimately gives you much more control and performance if done right

Post Reply

Return to “Ask for Help (v1)”