Adobe Air with WS_EX_LAYERED window style
Asked Answered
B

1

1

I am trying to set the WS_EX_LAYERED extended window style on an external Adobe Air application. See this question if you want to know why. The problem I am facing is that as soon as I set the style, the window stops rendering. Here's the my code:

auto style = GetWindowLong(hwnd, GWL_EXSTYLE);
SetWindowLong(hwnd, GWL_EXSTYLE, style | WS_EX_LAYERED);
// If I skip the next line, the window is suddenly white.
// With the next line, the image in the window freezes.
SetLayeredWindowAttributes(hwnd, 0, 255, LWA_ALPHA);

The window continues to work perfectly fine (clicks etc.), it just doesn't get redrawn anymore (f.e. when resized). The window does not have the CS_OWNDC or CS_CLASSDC style.

Can anyone tell me what the reason could be?

Blockhead answered 24/4, 2019 at 18:36 Comment(4)
Maybe Air uses UpdateLayeredWindow? Have you checked if the window has the WS_EX_LAYERED style before you add it?Varicose
Yes, I've checked that of course. It doesn't have that style.Blockhead
After you apply the style to do what you need, are you removing the style and refreshing the window?Penelopepeneplain
No, I want to keep the style on the window. If I remove it the window works fine again, but that's not an option. I tried updating the window with InvalidateRect() and UpdateWindow() without success. RedrawWindow() doesn't help either.Blockhead
S
1

What's your render mode set to in the application descriptor file? I would imagine your approach wouldn't work unless you specifically set this to render via the CPU i.e. to make AIR use GDI functions to display the content. I think by default it's likely to be using GPU acceleration so setting the style via SetWindowLong may then interfere with this..

In case you're not sure how to change the render mode:

  • Find the application's installed folder (under "Program Files (x86)")
  • Enter the "META-INF\AIR" subfolder
  • Edit the "application.xml" file
  • Look for "renderMode" within the "initialWindow" section (or if it's not there, add it..) and set this to "cpu"
  • Save this and then restart the AIR application

See AIR Descriptor File information.

Stolen answered 30/4, 2019 at 15:9 Comment(3)
Thank you for your answer. Unfortunately, changing the renderMode doesn't make a difference. I also tried to set transparent to true, without success. Maybe this has nothing to do with Adobe AIR because someone mentioned he encountered the same problem here: #53710635Blockhead
@Johannes Stricker If not for Adobe Air, do you try to capture screenshots of other applications (except notepad) and set WS_EX_LAYERED?Blackmore
Yes, I do and that works fine. The Adobe Air application is the only one which didn't work for me so far.Blockhead

© 2022 - 2024 — McMap. All rights reserved.