Reputation: 343
How can I get the same effect as SetLayeredWindowAttributes for windows created with WS_CHILD style? Is there any workaround? From MSDN:
To create a layered window, specify the WS_EX_LAYERED extended window style when calling the CreateWindowEx function, or call the SetWindowLong function to set WS_EX_LAYERED after the window has been created. After the CreateWindowEx call, the layered window will not become visible until the SetLayeredWindowAttributes or UpdateLayeredWindow function has been called for this window. Note that WS_EX_LAYERED cannot be used for child windows.
Upvotes: 0
Views: 2907
Reputation: 23
you can add a .manifest file to your Visual Studio Solution, but this only support Win8.1 and later version.
You can save following content into WindowLayer.manifest, and include in your project, build again, CreateWindowEx with WS_EX_LAYERED with WS_CHILD will be work, i tested this, it worked on my win10 computer.
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Developer Preview -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Upvotes: 0
Reputation: 31
Before you set transparent of child do it:
First set for the MDI Main window of it (SetWindowLong
& SetLayeredWindowAttributes
),
then it will work for the child directly .
Upvotes: 3
Reputation: 61
The child window cannot be layered - this style has effect for the windows with WS_POPUP style only. One possible way (not so elegeant) to resolve this problem is create a window with WS_POPUP style and syncronize its position when the "parent" window is being moved.
Upvotes: 2