0

I have a window and then I create a child window using the following code:

HWND childHwnd = CreateWindowExA(WS_EX_LAYERED, "Test", "Test", WS_CHILD, 0, 0, 500, 500, mainHwnd, NULL, instance, NULL);

After it has been created I can control the opacity using:

static COLORREF color = RGB(255, 0, 0);
SetLayeredWindowAttributes(childHwnd, color, 127, LWA_ALPHA);

It works fine but I also have to support Windows 7 and MSDN says the following:

Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.

I have installed Windows 7 in a VM and sadly it doesn't works. What could be the workaround to achieve the same opacity control over a child window in Windows 7?

I also tried to make it a standalone window and just follow the position of the parent window but the user experience is not that good when the window gets moved fast.

2
  • 3
    There's no "workaround", it's simply not supported. If you want a transparent effect from a child window on Windows 7 you'll need to render it that way yourself. Commented Dec 5, 2022 at 7:12
  • 1
    Little point trying to support an ancient OS like win 7. I mean, it's time to drop support for win 8.1 so win 7 should be long gone. Commented Dec 6, 2022 at 20:38

1 Answer 1

0

According to the documentation:

Using Layered Windows

In order to use layered child windows, the application has to declare itself Windows 8-aware in the manifest.

I suggest you refer to this answer:

https://stackoverflow.com/a/42570249/11872808

In Windows 7, you could try to use the SetWindowRgn() function.

I suggest you refer to this question:

Creating a Transparent Child window on top of non-transparent Parent Window (win32)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.