static extern void DwmSetWindowAttribute (IntPtr hwnd, DwmWindowAttribute attr, ref int attrValue, int attrSize);
public static int DwmGetWindowAttribute <T>(IntPtr hwnd, DwmWindowAttribute dwAttribute, out T pvAttribute) { int result = 0; pvAttribute = default(T); int size = Marshal.SizeOf(pvAttribute); var ptr = Marshal.AllocHGlobal(size); try { Marshal.StructureToPtr(pvAttribute, ptr, false); result = DwmGetWindowAttribute(hwnd, dwAttribute, ptr, size); pvAttribute = (T)Marshal.PtrToStructure(ptr, pvAttribute.GetType()); } finally { Marshal.FreeHGlobal(ptr); } return(result); }
// Safe method of calling dwmapi.dll, for versions of Windows lower than Vista internal static int DwmGetWindowAttribute(IntPtr hWnd, DwmWindowAttribute dwAttribute, ref WindowsRect pvAttribute, int cbAttribute) { IntPtr dwmDll = LoadLibrary("dwmapi.dll"); if (dwmDll == IntPtr.Zero) { return(Marshal.GetLastWin32Error()); } IntPtr dwmFunction = GetProcAddress(dwmDll, "DwmGetWindowAttribute"); if (dwmFunction == IntPtr.Zero) { return(Marshal.GetLastWin32Error()); } var call = (DwmGetWindowAttributeDelegate) Marshal.GetDelegateForFunctionPointer(dwmFunction, typeof( DwmGetWindowAttributeDelegate )); int result = call(hWnd, dwAttribute, ref pvAttribute, cbAttribute); FreeLibrary(dwmDll); return(result); }
/// <summary> /// Sets the value of non-client rendering attributes for a window. /// </summary> /// <param name="hwnd">The handle to the window that will receive the attributes.</param> /// <param name="attribute">A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter points to the value of that attribute.</param> /// <param name="attributeValue">The value of the attribute specified in the attribute parameter. Different DWMWINDOWATTRIBUTE flags require different value types.</param> /// <param name="attributeSize">The size, in bytes, of the value type pointed to by the pvAttribute parameter.</param> /// <returns></returns> public static bool SetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attribute, int attributeValue, uint attributeSize) { if (IsPlatformSupported) { return(NativeMethods.DwmSetWindowAttribute(hwnd, attribute, ref attributeValue, attributeSize).Succeeded); } return(false); }
static extern void DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attr, ref int attrValue, int attrSize);
protected static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attr, IntPtr attrValue, int attrSize);
public static extern HRESULT DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, ref int attribute, uint cbAttribute);
public static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out RECT pvAttribute, int cbAttribute);
public static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, ref int pvAttribute, int cbAttribute);
private static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwmAttribute, IntPtr pvAttribute, uint cbAttribute);
// Safe method of calling dwmapi.dll, for versions of Windows lower than Vista internal static int DwmGetWindowAttribute(IntPtr hWnd, DwmWindowAttribute dwAttribute, ref WindowsRect pvAttribute, int cbAttribute) { IntPtr dwmDll = LoadLibrary("dwmapi.dll"); if (dwmDll == IntPtr.Zero) return Marshal.GetLastWin32Error(); IntPtr dwmFunction = GetProcAddress(dwmDll, "DwmGetWindowAttribute"); if (dwmFunction == IntPtr.Zero) return Marshal.GetLastWin32Error(); var call = (DwmGetWindowAttributeDelegate)Marshal.GetDelegateForFunctionPointer(dwmFunction, typeof(DwmGetWindowAttributeDelegate)); int result = call(hWnd, dwAttribute, ref pvAttribute, cbAttribute); FreeLibrary(dwmDll); return result; }
public static extern int DwmSetWindowAttribute( [In] IntPtr hwnd, [In] DwmWindowAttribute dwAttribute, [In][Out] ref IntPtr pvAttribute, [In] int cbAttribute);
public static extern int DwmGetWindowAttribute( [In] IntPtr hwnd, [In] DwmWindowAttribute dwAttribute, [Out] out RECT pvAttribute, [In] int cbAttribute);
public static IntPtr DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, void *pvAttribute, int cbAttribute);
internal static extern void DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out Rectangle pvAttribute, int cbAttribute);
internal static extern int DwmSetWindowAttribute(IntPtr window, DwmWindowAttribute attribute, IntPtr valuePointer, int valuePointerSize);
unsafe public static extern HRESULT DwmGetWindowAttribute(HWND hwnd, DwmWindowAttribute dwAttribute, void* pvAttribute, DWORD cbAttribute);
private static int DwmSetIntAttribute(IntPtr hwnd, DwmWindowAttribute att, int v) { return(DwmSetWindowAttribute(hwnd, att, ref v, Marshal.SizeOf(typeof(int)))); }
private static int DwmSetBoolAttribute(IntPtr hwnd, DwmWindowAttribute att, bool v) { int iV = v ? 1 : 0; return(DwmSetWindowAttribute(hwnd, att, ref iV, Marshal.SizeOf(typeof(int)))); }
internal static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwmAttribute, ref int pvAttribute, uint cbAttribute);
public static IntPtr DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, void* pvAttribute, int cbAttribute);
internal static extern int DwmGetWindowAttribute(IntPtr hWnd, DwmWindowAttribute dwAttribute, ref WindowsRect pvAttribute, int cbAttribute);
public static extern int DwmGetWindowAttribute(IntPtr windowHandle, DwmWindowAttribute attribute, out Rect pvAttribute, int cbAttribute);
/// <summary> /// Sets the value of non-client rendering attributes for a window. /// </summary> /// <param name="hwnd">The handle to the window that will receive the attributes.</param> /// <param name="attribute">A single DWMWINDOWATTRIBUTE flag to apply to the window. This parameter specifies the attribute and the pvAttribute parameter points to the value of that attribute.</param> /// <param name="attributeValue">The value of the attribute specified in the attribute parameter. Different DWMWINDOWATTRIBUTE flags require different value types.</param> /// <param name="attributeSize">The size, in bytes, of the value type pointed to by the pvAttribute parameter.</param> /// <returns></returns> public static bool SetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attribute, int attributeValue, uint attributeSize) { if (IsPlatformSupported) { return NativeMethods.DwmSetWindowAttribute(hwnd, attribute, ref attributeValue, attributeSize).Succeeded; } return false; }
public static extern void DwmSetWindowAttribute(IntPtr windowHandle, DwmWindowAttribute atrribute, ref int attributeValue, int attributeSize);
static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attribute, out Win32Rect value, int valueSize);
public static extern int DwmSetWindowAttribute(Hwnd hwnd, DwmWindowAttribute attr, ref int attrValue, int attrSize);
internal static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out bool pvAttribute, int cbAttribute);
public static extern void DwmSetWindowAttribute( IntPtr windowHandle, DwmWindowAttribute atrribute, ref int attributeValue, int attributeSize );
public static extern int DwmGetWindowAttribute(IntPtr windowHandle, DwmWindowAttribute dwAttribute, out Rectangle lpRect, int cbAttribute);
static extern int DwmGetWindowAttribute (IntPtr hwnd, DwmWindowAttribute attribute, out Win32Rect value, int valueSize);
internal static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attr, ref int attrValue, uint attrSize);
public static int SetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attribute, int parameter) => DwmSetWindowAttribute(hwnd, attribute, ref parameter, Marshal.SizeOf <int>());