mirror of https://github.com/dahall/Vanara.git
More nullability work on DwmApi
parent
da884b1557
commit
009afeee89
|
@ -599,7 +599,7 @@ public static partial class DwmApi
|
||||||
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
||||||
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.DwmApi, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("dwmapi.h")]
|
[PInvokeData("dwmapi.h")]
|
||||||
public static extern HRESULT DwmGetCompositionTimingInfo(HWND hwnd, ref DWM_TIMING_INFO dwAttribute);
|
public static extern HRESULT DwmGetCompositionTimingInfo([Optional] HWND hwnd, ref DWM_TIMING_INFO dwAttribute);
|
||||||
|
|
||||||
/// <summary>Retrieves transport attributes.</summary>
|
/// <summary>Retrieves transport attributes.</summary>
|
||||||
/// <param name="pfIsRemoting">
|
/// <param name="pfIsRemoting">
|
||||||
|
@ -827,12 +827,12 @@ public static partial class DwmApi
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
||||||
[PInvokeData("dwmapi.h")]
|
[PInvokeData("dwmapi.h")]
|
||||||
public static HRESULT DwmSetWindowAttribute<T>(HWND hwnd, DWMWINDOWATTRIBUTE dwAttribute, [In] T pvAttribute)
|
public static HRESULT DwmSetWindowAttribute<T>(HWND hwnd, DWMWINDOWATTRIBUTE dwAttribute, [In] T? pvAttribute)
|
||||||
{
|
{
|
||||||
if (pvAttribute == null || !CorrespondingTypeAttribute.CanSet(dwAttribute, typeof(T))) throw new ArgumentException();
|
if (pvAttribute == null || !CorrespondingTypeAttribute.CanSet(dwAttribute, typeof(T))) throw new ArgumentException();
|
||||||
var attr = pvAttribute is bool ? Convert.ToUInt32(pvAttribute) : (pvAttribute.GetType().IsEnum ? Convert.ChangeType(pvAttribute, Enum.GetUnderlyingType(pvAttribute.GetType())) : pvAttribute);
|
var attr = pvAttribute is bool ? Convert.ToUInt32(pvAttribute) : (pvAttribute.GetType().IsEnum ? Convert.ChangeType(pvAttribute, Enum.GetUnderlyingType(pvAttribute.GetType())) : pvAttribute);
|
||||||
using (var p = new PinnedObject(attr))
|
using var p = new PinnedObject(attr);
|
||||||
return DwmSetWindowAttribute(hwnd, dwAttribute, p, Marshal.SizeOf(attr));
|
return DwmSetWindowAttribute(hwnd, dwAttribute, p, Marshal.SizeOf(attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1236,7 +1236,7 @@ public static partial class DwmApi
|
||||||
{
|
{
|
||||||
int RotateLeft(int value, int nBits)
|
int RotateLeft(int value, int nBits)
|
||||||
{
|
{
|
||||||
nBits = nBits % 0x20;
|
nBits %= 0x20;
|
||||||
return (value << nBits) | (value >> (0x20 - nBits));
|
return (value << nBits) | (value >> (0x20 - nBits));
|
||||||
}
|
}
|
||||||
return cxLeftWidth ^ RotateLeft(cyTopHeight, 8) ^ RotateLeft(cxRightWidth, 0x10) ^ RotateLeft(cyBottomHeight, 0x18);
|
return cxLeftWidth ^ RotateLeft(cyTopHeight, 8) ^ RotateLeft(cxRightWidth, 0x10) ^ RotateLeft(cyBottomHeight, 0x18);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AssemblyName>UnitTest.PInvoke.DwmApi</AssemblyName>
|
<AssemblyName>UnitTest.PInvoke.DwmApi</AssemblyName>
|
||||||
|
<TargetFramework>$(TargetFramework)-windows</TargetFramework>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Windows.Forms;
|
||||||
using static Vanara.PInvoke.DwmApi;
|
using static Vanara.PInvoke.DwmApi;
|
||||||
|
|
||||||
namespace Vanara.PInvoke.Tests;
|
namespace Vanara.PInvoke.Tests;
|
||||||
|
|
Loading…
Reference in New Issue