User32SetLayeredWindowAttributes(IntPtr, UInt32, Int32, LayeredWindowAttributesFlags) Method

Sets the opacity and transparency color key of a layered window.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", SetLastError = true)]
public static bool SetLayeredWindowAttributes(
	IntPtr hWnd,
	uint crKey,
	int bAlpha,
	LayeredWindowAttributesFlags flags
)

Parameters

hWnd  IntPtr
A handle to the layered window.

A layered window is created by specifying Layered when creating the window with the CreateWindowEx function or by setting Layered via SetWindowLongPtr(IntPtr, WindowLongValues, IntPtr) function. after the window has been created.

crKey  UInt32
A COLORREF structure that specifies the transparency color key to be used when composing the layered window.

All pixels painted by the window in this color will be transparent. To generate a COLORREF, use the RGB macro.

bAlpha  Int32
Alpha value used to describe the opacity of the layered window.

When bAlpha is 0, the window is completely transparent.

When bAlpha is 255, the window is opaque.

flags  LayeredWindowAttributesFlags
An action to be taken.

Return Value

Boolean
If the function succeeds, the return value is .

If the function fails, the return value .

To get extended error information, call GetLastWin32Error.

Remarks

See Also