mirror of https://github.com/dahall/Vanara.git
Partial work on nullable for Gdi32
parent
fec486a4d0
commit
52ff2f5899
|
@ -27,7 +27,7 @@ namespace Vanara.InteropServices
|
||||||
/// <summary>Determines whether the specified <see cref="System.Object"/>, is equal to this instance.</summary>
|
/// <summary>Determines whether the specified <see cref="System.Object"/>, is equal to this instance.</summary>
|
||||||
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
|
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
|
||||||
/// <returns><see langword="true"/> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <see langword="false"/>.</returns>
|
/// <returns><see langword="true"/> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <see langword="false"/>.</returns>
|
||||||
public override bool Equals(object obj) => obj is ComReleaser<dynamic> o ? Equals(o) : base.Equals(obj);
|
public override bool Equals(object? obj) => obj is ComReleaser<dynamic> o ? Equals(o) : base.Equals(obj);
|
||||||
|
|
||||||
/// <summary>Returns a hash code for this instance.</summary>
|
/// <summary>Returns a hash code for this instance.</summary>
|
||||||
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
|
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Vanara.PInvoke;
|
||||||
[StructLayout(LayoutKind.Sequential), Serializable]
|
[StructLayout(LayoutKind.Sequential), Serializable]
|
||||||
[TypeConverter(typeof(time_tTypeConverter))]
|
[TypeConverter(typeof(time_tTypeConverter))]
|
||||||
#pragma warning disable IDE1006 // Naming Styles
|
#pragma warning disable IDE1006 // Naming Styles
|
||||||
public struct time_t : IEquatable<time_t>, IComparable<time_t>, IEquatable<DateTime>, IComparable<DateTime>, IConvertible, IComparable
|
public readonly struct time_t : IEquatable<time_t>, IComparable<time_t>, IEquatable<DateTime>, IComparable<DateTime>, IConvertible, IComparable
|
||||||
#pragma warning restore IDE1006 // Naming Styles
|
#pragma warning restore IDE1006 // Naming Styles
|
||||||
{
|
{
|
||||||
private static readonly DateTime epoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
|
private static readonly DateTime epoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Vanara.PInvoke;
|
||||||
public static partial class ComCtl32
|
public static partial class ComCtl32
|
||||||
{
|
{
|
||||||
/// <summary>Used in the <see cref="BUTTON_IMAGELIST"/> structure himl member to indicate that no glyph should be displayed.</summary>
|
/// <summary>Used in the <see cref="BUTTON_IMAGELIST"/> structure himl member to indicate that no glyph should be displayed.</summary>
|
||||||
public static IntPtr BCCL_NOGLYPH = new IntPtr(-1);
|
public static IntPtr BCCL_NOGLYPH = new(-1);
|
||||||
|
|
||||||
/// <summary>Used by the <see cref="BUTTON_IMAGELIST.uAlign"/> member to specify alignment.</summary>
|
/// <summary>Used by the <see cref="BUTTON_IMAGELIST.uAlign"/> member to specify alignment.</summary>
|
||||||
[PInvokeData("Commctrl.h", MSDNShortId = "bb775953")]
|
[PInvokeData("Commctrl.h", MSDNShortId = "bb775953")]
|
||||||
|
|
|
@ -2294,16 +2294,16 @@ public static partial class ComCtl32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a tree view item.</summary>
|
/// <summary>Provides a handle to a tree view item.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HTREEITEM
|
public readonly struct HTREEITEM
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HTREEITEM"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HTREEITEM"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HTREEITEM(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HTREEITEM(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HTREEITEM"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HTREEITEM"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HTREEITEM NULL => new HTREEITEM(IntPtr.Zero);
|
public static HTREEITEM NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -2316,7 +2316,7 @@ public static partial class ComCtl32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HTREEITEM"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HTREEITEM"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HTREEITEM(IntPtr h) => new HTREEITEM(h);
|
public static implicit operator HTREEITEM(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -2331,7 +2331,7 @@ public static partial class ComCtl32
|
||||||
public static bool operator ==(HTREEITEM h1, HTREEITEM h2) => h1.Equals(h2);
|
public static bool operator ==(HTREEITEM h1, HTREEITEM h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HTREEITEM h && handle == h.handle;
|
public override bool Equals(object? obj) => obj is HTREEITEM h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Runtime.InteropServices;
|
||||||
using Vanara.Extensions;
|
using Vanara.Extensions;
|
||||||
using Vanara.InteropServices;
|
using Vanara.InteropServices;
|
||||||
|
|
||||||
|
#pragma warning disable IDE1006 // Naming Styles
|
||||||
namespace Vanara.PInvoke;
|
namespace Vanara.PInvoke;
|
||||||
|
|
||||||
/// <summary>Functions and types from Gdi32.dll.</summary>
|
/// <summary>Functions and types from Gdi32.dll.</summary>
|
||||||
|
@ -248,10 +249,10 @@ public static partial class Gdi32
|
||||||
/// </item>
|
/// </item>
|
||||||
/// <item>
|
/// <item>
|
||||||
/// <description>
|
/// <description>
|
||||||
/// An array of 16-bit unsigned integers that specifies indexes into the currently realized logical palette. This use of
|
/// An array of 16-bit unsigned integers that specifies indexes into the currently realized logical palette. This use of bmiColors is
|
||||||
/// bmiColors is allowed for functions that use DIBs. When bmiColors elements contain indexes to a realized logical palette,
|
/// allowed for functions that use DIBs. When bmiColors elements contain indexes to a realized logical palette, they must also call
|
||||||
/// they must also call the following bitmap
|
/// the following bitmap functions: CreateDIBitmap, CreateDIBPatternBrush, CreateDIBSection (The iUsage parameter of CreateDIBSection
|
||||||
/// functions: CreateDIBitmap, CreateDIBPatternBrush, CreateDIBSection (The iUsage parameter of CreateDIBSection must be set to DIB_PAL_COLORS.)
|
/// must be set to DIB_PAL_COLORS.)
|
||||||
/// </description>
|
/// </description>
|
||||||
/// </item>
|
/// </item>
|
||||||
/// </list>
|
/// </list>
|
||||||
|
@ -271,6 +272,7 @@ public static partial class Gdi32
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
bmiHeader = new BITMAPINFOHEADER(width, height, bitCount);
|
bmiHeader = new BITMAPINFOHEADER(width, height, bitCount);
|
||||||
|
bmiColors = new RGBQUAD[bitCount];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Creates a <see cref="BITMAPINFO"/> structure from the information in a bitmap handle.</summary>
|
/// <summary>Creates a <see cref="BITMAPINFO"/> structure from the information in a bitmap handle.</summary>
|
||||||
|
@ -1218,10 +1220,7 @@ public static partial class Gdi32
|
||||||
/// has a value greater than 8. Each color mask indicates the bits that are used to encode one of the three color channels (red,
|
/// has a value greater than 8. Each color mask indicates the bits that are used to encode one of the three color channels (red,
|
||||||
/// green, and blue).
|
/// green, and blue).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#pragma warning disable IDE1006 // Naming Styles
|
|
||||||
|
|
||||||
public uint[] dsBitFields
|
public uint[] dsBitFields
|
||||||
#pragma warning restore IDE1006 // Naming Styles
|
|
||||||
{
|
{
|
||||||
get => new[] { dsBitField1, dsBitField2, dsBitField3 };
|
get => new[] { dsBitField1, dsBitField2, dsBitField3 };
|
||||||
set { dsBitField1 = value[0]; dsBitField2 = value[1]; dsBitField3 = value[2]; }
|
set { dsBitField1 = value[0]; dsBitField2 = value[1]; dsBitField3 = value[2]; }
|
||||||
|
@ -1235,22 +1234,16 @@ public static partial class Gdi32
|
||||||
public class SafeBITMAPINFO : SafeCoTaskMemStruct<BITMAPINFO>
|
public class SafeBITMAPINFO : SafeCoTaskMemStruct<BITMAPINFO>
|
||||||
{
|
{
|
||||||
private const int RGBQUADSZ = 4;
|
private const int RGBQUADSZ = 4;
|
||||||
|
private static readonly int hdrSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER));
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="SafeBITMAPINFO"/> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="SafeBITMAPINFO"/> class.</summary>
|
||||||
/// <param name="bmpInfo">The <see cref="BITMAPINFO"/> value.</param>
|
/// <param name="bmpInfo">The <see cref="BITMAPINFO"/> value.</param>
|
||||||
public SafeBITMAPINFO(in BITMAPINFO bmpInfo) : base(BaseStructSize + (bmpInfo.bmiColors?.Length ?? 0) * RGBQUADSZ)
|
public SafeBITMAPINFO(in BITMAPINFO bmpInfo) : this(bmpInfo.bmiHeader, bmpInfo.bmiColors.Length * RGBQUADSZ) => bmiColors = bmpInfo.bmiColors;
|
||||||
{
|
|
||||||
handle.Write(bmpInfo.bmiHeader, 0, Size);
|
|
||||||
bmiColors = bmpInfo.bmiColors;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="SafeBITMAPINFO"/> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="SafeBITMAPINFO"/> class.</summary>
|
||||||
/// <param name="hdr">The HDR.</param>
|
/// <param name="hdr">The <see cref="BITMAPINFOHEADER"/> to initialize.</param>
|
||||||
/// <param name="capacity">The capacity of the buffer, in bytes. If 0 or <see langword="default"/>, the capacity is calculated.</param>
|
/// <param name="capacity">The capacity of the buffer, in bytes.</param>
|
||||||
public SafeBITMAPINFO(in BITMAPINFOHEADER hdr, SizeT capacity = default) : base(Math.Max(capacity, BaseStructSize))
|
public SafeBITMAPINFO(in BITMAPINFOHEADER hdr, SizeT capacity = default) : base(hdrSize + capacity) => bmiHeader = hdr;
|
||||||
{
|
|
||||||
handle.Write(hdr, 0, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="SafeBITMAPINFO"/> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="SafeBITMAPINFO"/> class.</summary>
|
||||||
/// <param name="ptr">Existing handle.</param>
|
/// <param name="ptr">Existing handle.</param>
|
||||||
|
@ -1259,7 +1252,6 @@ public static partial class Gdi32
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE1006 // Naming Styles
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bmiColors member contains one of the following:
|
/// The bmiColors member contains one of the following:
|
||||||
/// <list type="bullet">
|
/// <list type="bullet">
|
||||||
|
@ -1280,17 +1272,15 @@ public static partial class Gdi32
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>The colors in the bmiColors table appear in order of importance. For more information, see the Remarks section.</para>
|
/// <para>The colors in the bmiColors table appear in order of importance. For more information, see the Remarks section.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte[] bmiColorBytes
|
public ushort[] bmiColorBytes
|
||||||
{
|
{
|
||||||
get => handle.ToByteArray((Size - BaseStructSize), BaseStructSize, Size);
|
get => handle.ToArray<ushort>((Size - hdrSize) / 2, hdrSize, Size) ?? new ushort[0];
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
var reqSize = BaseStructSize + (value?.Length ?? 0);
|
var reqSize = hdrSize + value.Length;
|
||||||
if (Size < reqSize)
|
if (Size < reqSize)
|
||||||
Size = reqSize;
|
Size = reqSize;
|
||||||
else
|
handle.Write(value, hdrSize, Size);
|
||||||
handle.Offset(BaseStructSize).FillMemory(0, Size - BaseStructSize);
|
|
||||||
handle.Write(value, BaseStructSize, Size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1316,15 +1306,13 @@ public static partial class Gdi32
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RGBQUAD[] bmiColors
|
public RGBQUAD[] bmiColors
|
||||||
{
|
{
|
||||||
get => handle.ToArray<RGBQUAD>((Size - BaseStructSize) / RGBQUADSZ, BaseStructSize, Size);
|
get => handle.ToArray<RGBQUAD>((Size - hdrSize) / RGBQUADSZ, hdrSize, Size) ?? new RGBQUAD[0];
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
var reqSize = BaseStructSize + (value?.Length ?? 0) * RGBQUADSZ;
|
var reqSize = hdrSize + value.Length * RGBQUADSZ;
|
||||||
if (Size < reqSize)
|
if (Size < reqSize)
|
||||||
Size = reqSize;
|
Size = reqSize;
|
||||||
else
|
handle.Write(value, hdrSize, Size);
|
||||||
handle.Offset(BaseStructSize).FillMemory(0, Size - BaseStructSize);
|
|
||||||
handle.Write(value, BaseStructSize, Size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,7 +1323,6 @@ public static partial class Gdi32
|
||||||
/// <summary>A reference to the BITMAPINFOHEADER structure.</summary>
|
/// <summary>A reference to the BITMAPINFOHEADER structure.</summary>
|
||||||
public ref BITMAPINFOHEADER bmiHeaderAsRef => ref AsRef().bmiHeader;
|
public ref BITMAPINFOHEADER bmiHeaderAsRef => ref AsRef().bmiHeader;
|
||||||
#endif
|
#endif
|
||||||
#pragma warning restore IDE1006 // Naming Styles
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the number of bytes required by the structure. This value does not include the size of the color table or the size
|
/// Specifies the number of bytes required by the structure. This value does not include the size of the color table or the size
|
||||||
|
@ -1357,6 +1344,6 @@ public static partial class Gdi32
|
||||||
public T GetHeader<T>() where T : struct => handle.ToStructure<T>(Size);
|
public T GetHeader<T>() where T : struct => handle.ToStructure<T>(Size);
|
||||||
|
|
||||||
/// <summary>Zero out all allocated memory.</summary>
|
/// <summary>Zero out all allocated memory.</summary>
|
||||||
public override void Zero() { base.Zero(); HeaderSize = BaseStructSize; }
|
public override void Zero() { base.Zero(); HeaderSize = hdrSize; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2609,16 +2609,16 @@ public static partial class Gdi32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a DIB section.</summary>
|
/// <summary>Provides a handle to a DIB section.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HSECTION : IHandle
|
public readonly struct HSECTION : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HSECTION"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HSECTION"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HSECTION(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HSECTION(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HSECTION"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HSECTION"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HSECTION NULL => new HSECTION(IntPtr.Zero);
|
public static HSECTION NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -2631,7 +2631,7 @@ public static partial class Gdi32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HSECTION"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HSECTION"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HSECTION(IntPtr h) => new HSECTION(h);
|
public static implicit operator HSECTION(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -2646,7 +2646,7 @@ public static partial class Gdi32
|
||||||
public static bool operator ==(HSECTION h1, HSECTION h2) => h1.Equals(h2);
|
public static bool operator ==(HSECTION h1, HSECTION h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HSECTION h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HSECTION h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -482,6 +482,64 @@ public static partial class Gdi32
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool SetBrushOrgEx(HDC hdc, int x, int y, in POINT lppt);
|
public static extern bool SetBrushOrgEx(HDC hdc, int x, int y, in POINT lppt);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>
|
||||||
|
/// The <c>SetBrushOrgEx</c> function sets the brush origin that GDI assigns to the next brush an application selects into the
|
||||||
|
/// specified device context.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hdc">
|
||||||
|
/// <para>A handle to the device context.</para>
|
||||||
|
/// </param>
|
||||||
|
/// <param name="x">
|
||||||
|
/// <para>
|
||||||
|
/// The x-coordinate, in device units, of the new brush origin. If this value is greater than the brush width, its value is reduced
|
||||||
|
/// using the modulus operator (nXOrg <c>mod</c> brush width).
|
||||||
|
/// </para>
|
||||||
|
/// </param>
|
||||||
|
/// <param name="y">
|
||||||
|
/// <para>
|
||||||
|
/// The y-coordinate, in device units, of the new brush origin. If this value is greater than the brush height, its value is reduced
|
||||||
|
/// using the modulus operator (nYOrg <c>mod</c> brush height).
|
||||||
|
/// </para>
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lppt">
|
||||||
|
/// <para>A pointer to a POINT structure that receives the previous brush origin.</para>
|
||||||
|
/// <para>This parameter can be <c>NULL</c> if the previous brush origin is not required.</para>
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// <para>If the function succeeds, the return value is nonzero.</para>
|
||||||
|
/// <para>If the function fails, the return value is zero.</para>
|
||||||
|
/// </returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>A brush is a bitmap that the system uses to paint the interiors of filled shapes.</para>
|
||||||
|
/// <para>
|
||||||
|
/// The brush origin is a pair of coordinates specifying the location of one pixel in the bitmap. The default brush origin
|
||||||
|
/// coordinates are (0,0). For horizontal coordinates, the value 0 corresponds to the leftmost column of pixels; the width
|
||||||
|
/// corresponds to the rightmost column. For vertical coordinates, the value 0 corresponds to the uppermost row of pixels; the height
|
||||||
|
/// corresponds to the lowermost row.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// The system automatically tracks the origin of all window-managed device contexts and adjusts their brushes as necessary to
|
||||||
|
/// maintain an alignment of patterns on the surface. The brush origin that is set with this call is relative to the upper-left
|
||||||
|
/// corner of the client area.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// An application should call <c>SetBrushOrgEx</c> after setting the bitmap stretching mode to HALFTONE by using SetStretchBltMode.
|
||||||
|
/// This must be done to avoid brush misalignment.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// The system automatically tracks the origin of all window-managed device contexts and adjusts their brushes as necessary to
|
||||||
|
/// maintain an alignment of patterns on the surface.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-setbrushorgex BOOL SetBrushOrgEx( HDC hdc, int x, int y,
|
||||||
|
// LPPOINT lppt );
|
||||||
|
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
||||||
|
[PInvokeData("wingdi.h", MSDNShortId = "dcc7575a-49fd-4306-8baa-57e9e0d5ed1f")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool SetBrushOrgEx(HDC hdc, int x, int y, [In, Optional] IntPtr lppt);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <c>SetDCBrushColor</c> function sets the current device context (DC) brush color to the specified color value. If the device
|
/// <c>SetDCBrushColor</c> function sets the current device context (DC) brush color to the specified color value. If the device
|
||||||
/// cannot represent the specified color value, the color is set to the nearest physical color.
|
/// cannot represent the specified color value, the color is set to the nearest physical color.
|
||||||
|
|
|
@ -171,7 +171,7 @@ public static partial class Gdi32
|
||||||
// mode );
|
// mode );
|
||||||
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "d222defe-2ef9-4622-b2e1-462a91cb1b0a")]
|
[PInvokeData("wingdi.h", MSDNShortId = "d222defe-2ef9-4622-b2e1-462a91cb1b0a")]
|
||||||
public static extern RegionFlags ExtSelectClipRgn(HDC hdc, HRGN hrgn, RegionOp mode);
|
public static extern RegionFlags ExtSelectClipRgn(HDC hdc, [In, Optional] HRGN hrgn, RegionOp mode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>GetClipBox</c> function retrieves the dimensions of the tightest bounding rectangle that can be drawn around the current
|
/// The <c>GetClipBox</c> function retrieves the dimensions of the tightest bounding rectangle that can be drawn around the current
|
||||||
|
@ -286,7 +286,7 @@ public static partial class Gdi32
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getrandomrgn int GetRandomRgn( HDC hdc, HRGN hrgn, INT i );
|
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getrandomrgn int GetRandomRgn( HDC hdc, HRGN hrgn, INT i );
|
||||||
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "a7527d7a-7b5e-4dd5-9270-94bc92b5a4a0")]
|
[PInvokeData("wingdi.h", MSDNShortId = "a7527d7a-7b5e-4dd5-9270-94bc92b5a4a0")]
|
||||||
public static extern int GetRandomRgn(HDC hdc, [In, Out] HRGN hrgn, int i = 4 /* SYSRGN */);
|
public static extern int GetRandomRgn(HDC hdc, [In, Out, Optional] HRGN hrgn, int i = 4 /* SYSRGN */);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>IntersectClipRect</c> function creates a new clipping region from the intersection of the current clipping region and the
|
/// The <c>IntersectClipRect</c> function creates a new clipping region from the intersection of the current clipping region and the
|
||||||
|
@ -503,7 +503,7 @@ public static partial class Gdi32
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-selectcliprgn int SelectClipRgn( HDC hdc, HRGN hrgn );
|
// https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-selectcliprgn int SelectClipRgn( HDC hdc, HRGN hrgn );
|
||||||
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "7a4f0b9c-8588-4da8-a030-ed9d8b4ee08d")]
|
[PInvokeData("wingdi.h", MSDNShortId = "7a4f0b9c-8588-4da8-a030-ed9d8b4ee08d")]
|
||||||
public static extern RegionFlags SelectClipRgn(HDC hdc, HRGN hrgn);
|
public static extern RegionFlags SelectClipRgn(HDC hdc, [In, Optional] HRGN hrgn);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>SetMetaRgn</c> function intersects the current clipping region for the specified device context with the current
|
/// The <c>SetMetaRgn</c> function intersects the current clipping region for the specified device context with the current
|
||||||
|
|
|
@ -513,7 +513,7 @@ public static partial class Gdi32
|
||||||
[DllImport(Lib.Gdi32, SetLastError = true, CharSet = CharSet.Auto)]
|
[DllImport(Lib.Gdi32, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "1e16771a-80c5-47bb-9c98-14169d4dd773")]
|
[PInvokeData("wingdi.h", MSDNShortId = "1e16771a-80c5-47bb-9c98-14169d4dd773")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool GetICMProfile(HDC hdc, ref uint pBufSize, StringBuilder pszFilename);
|
public static extern bool GetICMProfile(HDC hdc, ref uint pBufSize, StringBuilder? pszFilename);
|
||||||
|
|
||||||
/// <summary>The <c>GetLogColorSpace</c> function retrieves the color space definition identified by a specified handle.</summary>
|
/// <summary>The <c>GetLogColorSpace</c> function retrieves the color space definition identified by a specified handle.</summary>
|
||||||
/// <param name="hColorSpace">Specifies the handle to a color space.</param>
|
/// <param name="hColorSpace">Specifies the handle to a color space.</param>
|
||||||
|
@ -603,7 +603,7 @@ public static partial class Gdi32
|
||||||
// UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries );
|
// UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries );
|
||||||
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "5e72e881-32e1-458e-a09e-91fa13abe178")]
|
[PInvokeData("wingdi.h", MSDNShortId = "5e72e881-32e1-458e-a09e-91fa13abe178")]
|
||||||
public static extern uint GetPaletteEntries(HPALETTE hpal, uint iStart, uint cEntries, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] PALETTEENTRY[] pPalEntries);
|
public static extern uint GetPaletteEntries([Optional] HPALETTE hpal, uint iStart, uint cEntries, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] PALETTEENTRY[] pPalEntries);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>GetSystemPaletteEntries</c> function retrieves a range of palette entries from the system palette that is associated with
|
/// The <c>GetSystemPaletteEntries</c> function retrieves a range of palette entries from the system palette that is associated with
|
||||||
|
@ -629,7 +629,7 @@ public static partial class Gdi32
|
||||||
// hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries );
|
// hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries );
|
||||||
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "67bb0adf-ae7f-48d5-bc62-82ece45aeee6")]
|
[PInvokeData("wingdi.h", MSDNShortId = "67bb0adf-ae7f-48d5-bc62-82ece45aeee6")]
|
||||||
public static extern uint GetSystemPaletteEntries(HDC hdc, uint iStart, uint cEntries, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] PALETTEENTRY[] pPalEntries);
|
public static extern uint GetSystemPaletteEntries(HDC hdc, uint iStart, uint cEntries, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] PALETTEENTRY[]? pPalEntries);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>GetSystemPaletteUse</c> function retrieves the current state of the system (physical) palette for the specified device
|
/// The <c>GetSystemPaletteUse</c> function retrieves the current state of the system (physical) palette for the specified device
|
||||||
|
@ -1447,7 +1447,7 @@ public static partial class Gdi32
|
||||||
public string lcsFilename;
|
public string lcsFilename;
|
||||||
|
|
||||||
/// <summary>The default structure with size and default fields preset.</summary>
|
/// <summary>The default structure with size and default fields preset.</summary>
|
||||||
public static readonly LOGCOLORSPACE Default = new LOGCOLORSPACE { lcsSignature = LCS_SIGNATURE, lcsVersion = 0x400, lcsSize = (uint)Marshal.SizeOf(typeof(LOGCOLORSPACE)) };
|
public static readonly LOGCOLORSPACE Default = new() { lcsSignature = LCS_SIGNATURE, lcsVersion = 0x400, lcsSize = (uint)Marshal.SizeOf(typeof(LOGCOLORSPACE)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -386,6 +386,46 @@ public static partial class Gdi32
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool LPtoDP(HDC hdc, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] POINT[] lppt, int c);
|
public static extern bool LPtoDP(HDC hdc, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] POINT[] lppt, int c);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>
|
||||||
|
/// The <c>LPtoDP</c> function converts logical coordinates into device coordinates. The conversion depends on the mapping mode of
|
||||||
|
/// the device context, the settings of the origins and extents for the window and viewport, and the world transformation.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hdc">
|
||||||
|
/// <para>A handle to the device context.</para>
|
||||||
|
/// </param>
|
||||||
|
/// <param name="lppt">
|
||||||
|
/// <para>
|
||||||
|
/// A pointer to an array of POINT structures. The x-coordinates and y-coordinates contained in each of the <c>POINT</c> structures
|
||||||
|
/// will be transformed.
|
||||||
|
/// </para>
|
||||||
|
/// </param>
|
||||||
|
/// <param name="c">
|
||||||
|
/// <para>The number of points in the array.</para>
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// <para>If the function succeeds, the return value is nonzero.</para>
|
||||||
|
/// <para>If the function fails, the return value is zero.</para>
|
||||||
|
/// </returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// The <c>LPtoDP</c> function fails if the logical coordinates exceed 32 bits, or if the converted device coordinates exceed 27
|
||||||
|
/// bits. In the case of such an overflow, the results for all the points are undefined.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// <c>LPtoDP</c> calculates complex floating-point arithmetic, and it has a caching system for efficiency. Therefore, the conversion
|
||||||
|
/// result of an initial call to <c>LPtoDP</c> might not exactly match the conversion result of a later call to <c>LPtoDP</c>. We
|
||||||
|
/// recommend not to write code that relies on the exact match of the conversion results from multiple calls to <c>LPtoDP</c> even if
|
||||||
|
/// the parameters that are passed to each call are identical.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-lptodp BOOL LPtoDP( HDC hdc, LPPOINT lppt, int c );
|
||||||
|
[DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)]
|
||||||
|
[PInvokeData("wingdi.h", MSDNShortId = "670a16fb-842e-4250-9ad7-dc08e849c2ba")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool LPtoDP(HDC hdc, ref POINT lppt, int c = 1);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>ModifyWorldTransform</c> function changes the world transformation for a device context using the specified mode.
|
/// The <c>ModifyWorldTransform</c> function changes the world transformation for a device context using the specified mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -2007,7 +2007,7 @@ public static partial class Gdi32
|
||||||
[Optional] int cWeight, [Optional, MarshalAs(UnmanagedType.Bool)] bool bItalic, [Optional, MarshalAs(UnmanagedType.Bool)] bool bUnderline,
|
[Optional] int cWeight, [Optional, MarshalAs(UnmanagedType.Bool)] bool bItalic, [Optional, MarshalAs(UnmanagedType.Bool)] bool bUnderline,
|
||||||
[Optional, MarshalAs(UnmanagedType.Bool)] bool bStrikeOut, CharacterSet iCharSet = CharacterSet.DEFAULT_CHARSET,
|
[Optional, MarshalAs(UnmanagedType.Bool)] bool bStrikeOut, CharacterSet iCharSet = CharacterSet.DEFAULT_CHARSET,
|
||||||
OutputPrecision iOutPrecision = OutputPrecision.OUT_DEFAULT_PRECIS, ClippingPrecision iClipPrecision = ClippingPrecision.CLIP_DEFAULT_PRECIS,
|
OutputPrecision iOutPrecision = OutputPrecision.OUT_DEFAULT_PRECIS, ClippingPrecision iClipPrecision = ClippingPrecision.CLIP_DEFAULT_PRECIS,
|
||||||
OutputQuality iQuality = OutputQuality.DEFAULT_QUALITY, PitchAndFamily iPitchAndFamily = PitchAndFamily.FF_DONTCARE, string pszFaceName = null);
|
OutputQuality iQuality = OutputQuality.DEFAULT_QUALITY, PitchAndFamily iPitchAndFamily = PitchAndFamily.FF_DONTCARE, string? pszFaceName = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>CreateFontIndirect</c> function creates a logical font that has the specified characteristics. The font can subsequently
|
/// The <c>CreateFontIndirect</c> function creates a logical font that has the specified characteristics. The font can subsequently
|
||||||
|
@ -4569,7 +4569,7 @@ public static partial class Gdi32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="System.Decimal"/> to <see cref="Vanara.PInvoke.Gdi32.FIXED"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="System.Decimal"/> to <see cref="Vanara.PInvoke.Gdi32.FIXED"/>.</summary>
|
||||||
/// <param name="d">The decimal value.</param>
|
/// <param name="d">The decimal value.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator FIXED(decimal d) => new FIXED { value = (short)Math.Truncate(d), fract = ushort.Parse(d.ToString(NumberFormatInfo.InvariantInfo).Split(new[] { NumberFormatInfo.InvariantInfo.NumberDecimalSeparator }, StringSplitOptions.None)[1], NumberFormatInfo.InvariantInfo) };
|
public static implicit operator FIXED(decimal d) => new() { value = (short)Math.Truncate(d), fract = ushort.Parse(d.ToString(NumberFormatInfo.InvariantInfo).Split(new[] { NumberFormatInfo.InvariantInfo.NumberDecimalSeparator }, StringSplitOptions.None)[1], NumberFormatInfo.InvariantInfo) };
|
||||||
|
|
||||||
/// <summary>Converts to string.</summary>
|
/// <summary>Converts to string.</summary>
|
||||||
/// <returns>A <see cref="string"/> that represents this instance.</returns>
|
/// <returns>A <see cref="string"/> that represents this instance.</returns>
|
||||||
|
@ -4838,7 +4838,7 @@ public static partial class Gdi32
|
||||||
public int nMaxFit;
|
public int nMaxFit;
|
||||||
|
|
||||||
/// <summary>The default instance of this structure with the structure size value set.</summary>
|
/// <summary>The default instance of this structure with the structure size value set.</summary>
|
||||||
public static GCP_RESULTS Default = new GCP_RESULTS { lStructSize = (uint)Marshal.SizeOf(typeof(GCP_RESULTS)) };
|
public static GCP_RESULTS Default = new() { lStructSize = (uint)Marshal.SizeOf(typeof(GCP_RESULTS)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -4950,7 +4950,7 @@ public static partial class Gdi32
|
||||||
public FIXED eM22;
|
public FIXED eM22;
|
||||||
|
|
||||||
/// <summary>The identity matrix value.</summary>
|
/// <summary>The identity matrix value.</summary>
|
||||||
public static readonly MAT2 IdentityMatrix = new MAT2 { eM11 = new FIXED { fract = 1 }, eM22 = new FIXED { fract = 1 } };
|
public static readonly MAT2 IdentityMatrix = new() { eM11 = new FIXED { fract = 1 }, eM22 = new FIXED { fract = 1 } };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The <c>NEWTEXTMETRIC</c> structure contains data that describes a physical font.</summary>
|
/// <summary>The <c>NEWTEXTMETRIC</c> structure contains data that describes a physical font.</summary>
|
||||||
|
|
|
@ -1654,7 +1654,7 @@ public static partial class Gdi32
|
||||||
public SIZE szlMicrometers;
|
public SIZE szlMicrometers;
|
||||||
|
|
||||||
/// <summary>A default instance of the structure with the size field preset.</summary>
|
/// <summary>A default instance of the structure with the size field preset.</summary>
|
||||||
public static readonly ENHMETAHEADER Default = new ENHMETAHEADER { nSize = (uint)Marshal.SizeOf(typeof(ENHMETAHEADER)) };
|
public static readonly ENHMETAHEADER Default = new() { nSize = (uint)Marshal.SizeOf(typeof(ENHMETAHEADER)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1742,7 +1742,7 @@ public static partial class Gdi32
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>An array of parameters passed to the GDI function identified by the record.</summary>
|
/// <summary>An array of parameters passed to the GDI function identified by the record.</summary>
|
||||||
public uint[] dParm => base.Elements;
|
public uint[] dParm => base.Elements ?? new uint[0];
|
||||||
|
|
||||||
/// <summary>The record type.</summary>
|
/// <summary>The record type.</summary>
|
||||||
public RecordType iType => handle.ToStructure<RecordType>();
|
public RecordType iType => handle.ToStructure<RecordType>();
|
||||||
|
@ -1753,7 +1753,7 @@ public static partial class Gdi32
|
||||||
/// <summary>Performs an explicit conversion from <see cref="IntPtr"/> to <see cref="ENHMETARECORD"/>.</summary>
|
/// <summary>Performs an explicit conversion from <see cref="IntPtr"/> to <see cref="ENHMETARECORD"/>.</summary>
|
||||||
/// <param name="ptr">The pointer to an instance.</param>
|
/// <param name="ptr">The pointer to an instance.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static explicit operator ENHMETARECORD(IntPtr ptr) => new ENHMETARECORD(ptr);
|
public static explicit operator ENHMETARECORD(IntPtr ptr) => new(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The <c>METARECORD</c> structure contains a Windows-format metafile record.</summary>
|
/// <summary>The <c>METARECORD</c> structure contains a Windows-format metafile record.</summary>
|
||||||
|
@ -1782,7 +1782,7 @@ public static partial class Gdi32
|
||||||
public ushort rdFunction => handle.ToStructure<ushort>(Size, 4);
|
public ushort rdFunction => handle.ToStructure<ushort>(Size, 4);
|
||||||
|
|
||||||
/// <summary>An array of words containing the function parameters, in reverse of the order they are passed to the function.</summary>
|
/// <summary>An array of words containing the function parameters, in reverse of the order they are passed to the function.</summary>
|
||||||
public ushort[] rdParm => base.Elements;
|
public ushort[] rdParm => base.Elements ?? new ushort[0];
|
||||||
|
|
||||||
/// <summary>The size, in words, of the record.</summary>
|
/// <summary>The size, in words, of the record.</summary>
|
||||||
public uint rdSize => Size / 2U;
|
public uint rdSize => Size / 2U;
|
||||||
|
@ -1790,7 +1790,7 @@ public static partial class Gdi32
|
||||||
/// <summary>Performs an explicit conversion from <see cref="IntPtr"/> to <see cref="METARECORD"/>.</summary>
|
/// <summary>Performs an explicit conversion from <see cref="IntPtr"/> to <see cref="METARECORD"/>.</summary>
|
||||||
/// <param name="ptr">The pointer to an instance.</param>
|
/// <param name="ptr">The pointer to an instance.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static explicit operator METARECORD(IntPtr ptr) => new METARECORD(ptr);
|
public static explicit operator METARECORD(IntPtr ptr) => new(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Provides a <see cref="SafeHandle"/> for <see cref="HENHMETAFILE"/> that is disposed using <see cref="DeleteEnhMetaFile"/>.</summary>
|
/// <summary>Provides a <see cref="SafeHandle"/> for <see cref="HENHMETAFILE"/> that is disposed using <see cref="DeleteEnhMetaFile"/>.</summary>
|
||||||
|
|
|
@ -690,7 +690,7 @@ public static partial class Gdi32
|
||||||
/// <summary>Specifies an arbitrary-size buffer that contains the RECT structures that make up the region.</summary>
|
/// <summary>Specifies an arbitrary-size buffer that contains the RECT structures that make up the region.</summary>
|
||||||
public RECT[] Buffer
|
public RECT[] Buffer
|
||||||
{
|
{
|
||||||
get => _Buffer.ToArray<RECT>((int)rdh.nCount);
|
get => _Buffer.ToArray<RECT>((int)rdh.nCount) ?? new RECT[0];
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
((IDisposable)this).Dispose();
|
((IDisposable)this).Dispose();
|
||||||
|
|
|
@ -139,7 +139,7 @@ public static partial class Gdi32
|
||||||
/// <summary>Creates a context into which a graphics object is selected.</summary>
|
/// <summary>Creates a context into which a graphics object is selected.</summary>
|
||||||
/// <param name="hObject">The graphics object to select.</param>
|
/// <param name="hObject">The graphics object to select.</param>
|
||||||
/// <returns>A selection context for the graphics object.</returns>
|
/// <returns>A selection context for the graphics object.</returns>
|
||||||
public GdiObjectContext SelectObject(HGDIOBJ hObject) => new GdiObjectContext(handle, hObject);
|
public GdiObjectContext SelectObject(HGDIOBJ hObject) => new(handle, hObject);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override bool InternalReleaseHandle()
|
protected override bool InternalReleaseHandle()
|
||||||
|
|
|
@ -318,7 +318,7 @@ public static partial class Gdi32
|
||||||
[DllImport(Lib.Gdi32, SetLastError = true, ExactSpelling = true)]
|
[DllImport(Lib.Gdi32, SetLastError = true, ExactSpelling = true)]
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "0e6e81f1-ec7b-42ba-8706-a352349fa6ab")]
|
[PInvokeData("wingdi.h", MSDNShortId = "0e6e81f1-ec7b-42ba-8706-a352349fa6ab")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool TranslateCharsetInfo(ref uint lpSrc, out CHARSETINFO lpCs, TCI dwFlags);
|
public static extern bool TranslateCharsetInfo([In, MarshalAs(UnmanagedType.LPArray, SizeConst = 2)] uint[] lpSrc, out CHARSETINFO lpCs, TCI dwFlags);
|
||||||
|
|
||||||
/// <summary>Translates character set information and sets all members of a destination structure to appropriate values.</summary>
|
/// <summary>Translates character set information and sets all members of a destination structure to appropriate values.</summary>
|
||||||
/// <param name="lpSrc">
|
/// <param name="lpSrc">
|
||||||
|
@ -377,9 +377,9 @@ public static partial class Gdi32
|
||||||
public struct CHARSETINFO
|
public struct CHARSETINFO
|
||||||
{
|
{
|
||||||
/// <summary>Character set value.</summary>
|
/// <summary>Character set value.</summary>
|
||||||
public uint ciCharset;
|
public CharacterSetUint ciCharset;
|
||||||
|
|
||||||
/// <summary>Windows ANSI code page identifier. For a list of identifiers, see Code Page Identifiers.</summary>
|
/// <summary>Windows ANSI code page identifier. For a list of identifiers, see Code Page Identifiers constants in <c>Vanara.PInvoke.Kernel32</c>.</summary>
|
||||||
public uint ciACP;
|
public uint ciACP;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -473,6 +473,6 @@ public static partial class Gdi32
|
||||||
public string DeviceKey;
|
public string DeviceKey;
|
||||||
|
|
||||||
/// <summary>Gets an empty structure with the <see cref="cb"/> set to the size of the structure.</summary>
|
/// <summary>Gets an empty structure with the <see cref="cb"/> set to the size of the structure.</summary>
|
||||||
public static readonly DISPLAY_DEVICE Default = new DISPLAY_DEVICE { cb = (uint)Marshal.SizeOf(typeof(DISPLAY_DEVICE)) };
|
public static readonly DISPLAY_DEVICE Default = new() { cb = (uint)Marshal.SizeOf(typeof(DISPLAY_DEVICE)) };
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -419,16 +419,16 @@ public static partial class Gdi32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a spool file.</summary>
|
/// <summary>Provides a handle to a spool file.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HSPOOLFILE : IHandle
|
public readonly struct HSPOOLFILE : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HSPOOLFILE"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HSPOOLFILE"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HSPOOLFILE(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HSPOOLFILE(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HSPOOLFILE"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HSPOOLFILE"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HSPOOLFILE NULL => new HSPOOLFILE(IntPtr.Zero);
|
public static HSPOOLFILE NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -441,7 +441,7 @@ public static partial class Gdi32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HSPOOLFILE"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HSPOOLFILE"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HSPOOLFILE(IntPtr h) => new HSPOOLFILE(h);
|
public static implicit operator HSPOOLFILE(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -456,7 +456,7 @@ public static partial class Gdi32
|
||||||
public static bool operator ==(HSPOOLFILE h1, HSPOOLFILE h2) => h1.Equals(h2);
|
public static bool operator ==(HSPOOLFILE h1, HSPOOLFILE h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HSPOOLFILE h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HSPOOLFILE h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -2522,7 +2522,7 @@ lpImeMenu is null ? 0 : Marshal.SizeOf(typeof(IMEMENUITEMINFO)) * lpImeMenu.Leng
|
||||||
|
|
||||||
/// <summary>Provides a handle to an input context.</summary>
|
/// <summary>Provides a handle to an input context.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HIMC : IHandle
|
public readonly struct HIMC : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2574,7 +2574,7 @@ lpImeMenu is null ? 0 : Marshal.SizeOf(typeof(IMEMENUITEMINFO)) * lpImeMenu.Leng
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return (obj is IHandle h && handle == h.DangerousGetHandle()) || (obj is IntPtr p && handle == p);
|
return (obj is IHandle h && handle == h.DangerousGetHandle()) || (obj is IntPtr p && handle == p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5985,7 +5985,7 @@ public static partial class AdvApi32
|
||||||
/// <param name="providerName">Name of the provider.</param>
|
/// <param name="providerName">Name of the provider.</param>
|
||||||
/// <returns>An initialized instance of <see cref="EVENT_TRACE_PROPERTIES"/>.</returns>
|
/// <returns>An initialized instance of <see cref="EVENT_TRACE_PROPERTIES"/>.</returns>
|
||||||
public static EVENT_TRACE_PROPERTIES Create(string? logFileName = null, string? providerName = null) =>
|
public static EVENT_TRACE_PROPERTIES Create(string? logFileName = null, string? providerName = null) =>
|
||||||
new EVENT_TRACE_PROPERTIES
|
new()
|
||||||
{
|
{
|
||||||
Wnode = new WNODE_HEADER
|
Wnode = new WNODE_HEADER
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Vanara.PInvoke;
|
||||||
|
|
||||||
/// <summary>Provides a handle to an accelerator table.</summary>
|
/// <summary>Provides a handle to an accelerator table.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HACCEL : IUserHandle
|
public readonly struct HACCEL : IUserHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public struct HACCEL : IUserHandle
|
||||||
|
|
||||||
/// <summary>Provides a generic handle.</summary>
|
/// <summary>Provides a generic handle.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HANDLE : IHandle
|
public readonly struct HANDLE : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ public struct HANDLE : IHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a bitmap.</summary>
|
/// <summary>Provides a handle to a bitmap.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HBITMAP : IGraphicsObjectHandle
|
public readonly struct HBITMAP : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public struct HBITMAP : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to drawing brush.</summary>
|
/// <summary>Provides a handle to drawing brush.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HBRUSH : IGraphicsObjectHandle
|
public readonly struct HBRUSH : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ public struct HBRUSH : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a color space.</summary>
|
/// <summary>Provides a handle to a color space.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HCOLORSPACE : IGraphicsObjectHandle
|
public readonly struct HCOLORSPACE : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ public struct HCOLORSPACE : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to cursor.</summary>
|
/// <summary>Provides a handle to cursor.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HCURSOR : IGraphicsObjectHandle
|
public readonly struct HCURSOR : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ public struct HCURSOR : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a graphic device context.</summary>
|
/// <summary>Provides a handle to a graphic device context.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HDC : IHandle
|
public readonly struct HDC : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ public struct HDC : IHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a desktop.</summary>
|
/// <summary>Provides a handle to a desktop.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HDESK : IKernelHandle
|
public readonly struct HDESK : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ public struct HDESK : IKernelHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a DPA.</summary>
|
/// <summary>Provides a handle to a DPA.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HDPA : IKernelHandle
|
public readonly struct HDPA : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ public struct HDPA : IKernelHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a Windows drop operation.</summary>
|
/// <summary>Provides a handle to a Windows drop operation.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HDROP : IShellHandle
|
public readonly struct HDROP : IShellHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -567,7 +567,7 @@ public struct HDROP : IShellHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a DSA.</summary>
|
/// <summary>Provides a handle to a DSA.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HDSA : IKernelHandle
|
public readonly struct HDSA : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ public struct HDSA : IKernelHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a deferred windows position.</summary>
|
/// <summary>Provides a handle to a deferred windows position.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HDWP : IUserHandle
|
public readonly struct HDWP : IUserHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ public struct HDWP : IUserHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to an enhanced metafile.</summary>
|
/// <summary>Provides a handle to an enhanced metafile.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HENHMETAFILE : IHandle
|
public readonly struct HENHMETAFILE : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ public struct HENHMETAFILE : IHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a sync event.</summary>
|
/// <summary>Provides a handle to a sync event.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HEVENT : ISyncHandle
|
public readonly struct HEVENT : ISyncHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ public struct HEVENT : ISyncHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a file.</summary>
|
/// <summary>Provides a handle to a file.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HFILE : ISyncHandle
|
public readonly struct HFILE : ISyncHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -843,7 +843,7 @@ public struct HFILE : ISyncHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a font.</summary>
|
/// <summary>Provides a handle to a font.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HFONT : IGraphicsObjectHandle
|
public readonly struct HFONT : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -901,7 +901,7 @@ public struct HFONT : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a graphic device object.</summary>
|
/// <summary>Provides a handle to a graphic device object.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HGDIOBJ : IGraphicsObjectHandle
|
public readonly struct HGDIOBJ : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -994,7 +994,7 @@ public struct HGDIOBJ : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to an icon.</summary>
|
/// <summary>Provides a handle to an icon.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HICON : IUserHandle
|
public readonly struct HICON : IUserHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1047,7 +1047,7 @@ public struct HICON : IUserHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a Windows image list.</summary>
|
/// <summary>Provides a handle to a Windows image list.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HIMAGELIST : IShellHandle
|
public readonly struct HIMAGELIST : IShellHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ public struct HIMAGELIST : IShellHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a module or library instance.</summary>
|
/// <summary>Provides a handle to a module or library instance.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HINSTANCE : IKernelHandle
|
public readonly struct HINSTANCE : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1153,7 +1153,7 @@ public struct HINSTANCE : IKernelHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a Windows registry key.</summary>
|
/// <summary>Provides a handle to a Windows registry key.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HKEY : IKernelHandle
|
public readonly struct HKEY : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1258,7 +1258,7 @@ public struct HKEY : IKernelHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a menu.</summary>
|
/// <summary>Provides a handle to a menu.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HMENU : IUserHandle
|
public readonly struct HMENU : IUserHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1311,7 +1311,7 @@ public struct HMENU : IUserHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a metafile.</summary>
|
/// <summary>Provides a handle to a metafile.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HMETAFILE : IHandle
|
public readonly struct HMETAFILE : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1364,7 +1364,7 @@ public struct HMETAFILE : IHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a monitor.</summary>
|
/// <summary>Provides a handle to a monitor.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HMONITOR : IKernelHandle
|
public readonly struct HMONITOR : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1417,7 +1417,7 @@ public struct HMONITOR : IKernelHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a palette.</summary>
|
/// <summary>Provides a handle to a palette.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HPALETTE : IGraphicsObjectHandle
|
public readonly struct HPALETTE : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1475,7 +1475,7 @@ public struct HPALETTE : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a drawing pen.</summary>
|
/// <summary>Provides a handle to a drawing pen.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HPEN : IGraphicsObjectHandle
|
public readonly struct HPEN : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1533,7 +1533,7 @@ public struct HPEN : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a process.</summary>
|
/// <summary>Provides a handle to a process.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HPROCESS : ISyncHandle
|
public readonly struct HPROCESS : ISyncHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1591,7 +1591,7 @@ public struct HPROCESS : ISyncHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a Windows property sheet.</summary>
|
/// <summary>Provides a handle to a Windows property sheet.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HPROPSHEET : IUserHandle
|
public readonly struct HPROPSHEET : IUserHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1644,7 +1644,7 @@ public struct HPROPSHEET : IUserHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a property sheet page.</summary>
|
/// <summary>Provides a handle to a property sheet page.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HPROPSHEETPAGE : IUserHandle
|
public readonly struct HPROPSHEETPAGE : IUserHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1697,7 +1697,7 @@ public struct HPROPSHEETPAGE : IUserHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a drawing region.</summary>
|
/// <summary>Provides a handle to a drawing region.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HRGN : IGraphicsObjectHandle
|
public readonly struct HRGN : IGraphicsObjectHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1755,7 +1755,7 @@ public struct HRGN : IGraphicsObjectHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a file mapping object.</summary>
|
/// <summary>Provides a handle to a file mapping object.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HSECTION : IHandle
|
public readonly struct HSECTION : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1808,7 +1808,7 @@ public struct HSECTION : IHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a blocking task.</summary>
|
/// <summary>Provides a handle to a blocking task.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HTASK : IHandle
|
public readonly struct HTASK : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1861,7 +1861,7 @@ public struct HTASK : IHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a Windows theme.</summary>
|
/// <summary>Provides a handle to a Windows theme.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HTHEME : IHandle
|
public readonly struct HTHEME : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1914,7 +1914,7 @@ public struct HTHEME : IHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a thread.</summary>
|
/// <summary>Provides a handle to a thread.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HTHREAD : ISyncHandle
|
public readonly struct HTHREAD : ISyncHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -1967,7 +1967,7 @@ public struct HTHREAD : ISyncHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a Windows thumbnail.</summary>
|
/// <summary>Provides a handle to a Windows thumbnail.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HTHUMBNAIL : IShellHandle
|
public readonly struct HTHUMBNAIL : IShellHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2020,7 +2020,7 @@ public struct HTHUMBNAIL : IShellHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to an access token.</summary>
|
/// <summary>Provides a handle to an access token.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HTOKEN : IKernelHandle
|
public readonly struct HTOKEN : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2073,7 +2073,7 @@ public struct HTOKEN : IKernelHandle
|
||||||
|
|
||||||
/// <summary>Provides a handle to a windows station.</summary>
|
/// <summary>Provides a handle to a windows station.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct HWINSTA : IKernelHandle
|
public readonly struct HWINSTA : IKernelHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2206,7 +2206,7 @@ public struct HWND : IUserHandle
|
||||||
|
|
||||||
/// <summary>Provides a pointer to an access control entry.</summary>
|
/// <summary>Provides a pointer to an access control entry.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct PACE : ISecurityObject
|
public readonly struct PACE : ISecurityObject
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2259,7 +2259,7 @@ public struct PACE : ISecurityObject
|
||||||
|
|
||||||
/// <summary>Provides a handle to an access control list.</summary>
|
/// <summary>Provides a handle to an access control list.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct PACL : ISecurityObject
|
public readonly struct PACL : ISecurityObject
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2312,7 +2312,7 @@ public struct PACL : ISecurityObject
|
||||||
|
|
||||||
/// <summary>Provides a handle to a security descriptor.</summary>
|
/// <summary>Provides a handle to a security descriptor.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct PSECURITY_DESCRIPTOR : ISecurityObject
|
public readonly struct PSECURITY_DESCRIPTOR : ISecurityObject
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2365,7 +2365,7 @@ public struct PSECURITY_DESCRIPTOR : ISecurityObject
|
||||||
|
|
||||||
/// <summary>Provides a handle to a security identifier.</summary>
|
/// <summary>Provides a handle to a security identifier.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
[StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")]
|
||||||
public struct PSID : ISecurityObject
|
public readonly struct PSID : ISecurityObject
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,13 @@ public struct RGBQUAD : IEquatable<RGBQUAD>
|
||||||
rgbReserved = 0;
|
rgbReserved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the <see cref="RGBQUAD"/> struct from a DWORD (<see cref="uint"/>) value.</summary>
|
||||||
|
/// <param name="dword">The 32-bit value with R, G and B values packed in the first 3 bytes.</param>
|
||||||
|
public RGBQUAD(uint dword)
|
||||||
|
{
|
||||||
|
unsafe { this = *(RGBQUAD*)&dword; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether any transparency is defined.</summary>
|
/// <summary>Gets a value indicating whether any transparency is defined.</summary>
|
||||||
/// <value><see langword="true"/> if this value is transparent; otherwise, <see langword="false"/>.</value>
|
/// <value><see langword="true"/> if this value is transparent; otherwise, <see langword="false"/>.</value>
|
||||||
public bool IsTransparent => rgbReserved == 0;
|
public bool IsTransparent => rgbReserved == 0;
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Vanara.PInvoke;
|
||||||
/// <seealso cref="System.IEquatable{CLIPFORMAT}"/>
|
/// <seealso cref="System.IEquatable{CLIPFORMAT}"/>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
[PInvokeData("wtypes.h", MSDNShortId = "fe42baec-6b00-4816-b379-7f335da8a197")]
|
[PInvokeData("wtypes.h", MSDNShortId = "fe42baec-6b00-4816-b379-7f335da8a197")]
|
||||||
public partial struct CLIPFORMAT : IComparable, IComparable<CLIPFORMAT>, IEquatable<CLIPFORMAT>
|
public readonly partial struct CLIPFORMAT : IComparable, IComparable<CLIPFORMAT>, IEquatable<CLIPFORMAT>
|
||||||
{
|
{
|
||||||
internal readonly ushort _value;
|
internal readonly ushort _value;
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,13 @@ public delegate bool BasicMessageWindowFilter(HWND hwnd, uint msg, IntPtr wParam
|
||||||
public class BasicMessageWindow : MarshalByRefObject, IDisposable, IHandle
|
public class BasicMessageWindow : MarshalByRefObject, IDisposable, IHandle
|
||||||
{
|
{
|
||||||
private readonly WeakReference weakSelfRef;
|
private readonly WeakReference weakSelfRef;
|
||||||
private SafeHWND hwnd;
|
private SafeHWND? hwnd;
|
||||||
private bool isDisposed;
|
private bool isDisposed;
|
||||||
private WindowClass wCls;
|
private WindowClass? wCls;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="BasicMessageWindow"/> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="BasicMessageWindow"/> class.</summary>
|
||||||
/// <param name="callback">Specifies the callback method to use to process messages.</param>
|
/// <param name="callback">Specifies the callback method to use to process messages.</param>
|
||||||
public BasicMessageWindow(BasicMessageWindowFilter callback = null)
|
public BasicMessageWindow(BasicMessageWindowFilter? callback = null)
|
||||||
{
|
{
|
||||||
MessageFilter = callback;
|
MessageFilter = callback;
|
||||||
weakSelfRef = new WeakReference(this);
|
weakSelfRef = new WeakReference(this);
|
||||||
|
@ -48,11 +48,11 @@ public class BasicMessageWindow : MarshalByRefObject, IDisposable, IHandle
|
||||||
|
|
||||||
/// <summary>Gets or sets the callback method used to filter window messages.</summary>
|
/// <summary>Gets or sets the callback method used to filter window messages.</summary>
|
||||||
/// <value>The callback method.</value>
|
/// <value>The callback method.</value>
|
||||||
public BasicMessageWindowFilter MessageFilter { get; set; }
|
public BasicMessageWindowFilter? MessageFilter { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets the name of the class.</summary>
|
/// <summary>Gets the name of the class.</summary>
|
||||||
/// <value>The name of the class.</value>
|
/// <value>The name of the class.</value>
|
||||||
public string ClassName => wCls?.ClassName;
|
public string? ClassName => wCls?.ClassName;
|
||||||
|
|
||||||
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -22,7 +22,7 @@ public interface IMessagePump
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// The result of <see cref="PeekMessage(out MSG, HWND, uint, uint, PM)"/> or <see cref="GetMessage(out MSG, HWND, uint, uint)"/>.
|
/// The result of <see cref="PeekMessage(out MSG, HWND, uint, uint, PM)"/> or <see cref="GetMessage(out MSG, HWND, uint, uint)"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
int Run(IWindowInstance mainWindow = null);
|
int Run(IWindowInstance? mainWindow = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>An interface that represents a Win32 window with created and destroyed events.</summary>
|
/// <summary>An interface that represents a Win32 window with created and destroyed events.</summary>
|
||||||
|
@ -48,7 +48,7 @@ public class MessagePump : IMessagePump
|
||||||
protected const ushort quitMsg = (ushort)WindowMessage.WM_QUIT;
|
protected const ushort quitMsg = (ushort)WindowMessage.WM_QUIT;
|
||||||
|
|
||||||
/// <inhertdoc/>
|
/// <inhertdoc/>
|
||||||
public int Run(IWindowInstance mainWindow = null)
|
public int Run(IWindowInstance? mainWindow = null)
|
||||||
{
|
{
|
||||||
if (mainWindow is not null and not WindowBase)
|
if (mainWindow is not null and not WindowBase)
|
||||||
mainWindow.Destroyed += onDestroy;
|
mainWindow.Destroyed += onDestroy;
|
||||||
|
@ -88,15 +88,15 @@ public class MessagePump : IMessagePump
|
||||||
public class ExaminedMessagePump : MessagePump
|
public class ExaminedMessagePump : MessagePump
|
||||||
{
|
{
|
||||||
/// <summary>Occurs after <see cref="DispatchMessage(in MSG)"/>.</summary>
|
/// <summary>Occurs after <see cref="DispatchMessage(in MSG)"/>.</summary>
|
||||||
public event MsgPumpDelegate PostProcess;
|
public event MsgPumpDelegate? PostProcess;
|
||||||
|
|
||||||
/// <summary>Occurs after <see cref="TranslateMessage(in MSG)"/> and determines if message should be dispatched.</summary>
|
/// <summary>Occurs after <see cref="TranslateMessage(in MSG)"/> and determines if message should be dispatched.</summary>
|
||||||
public event MsgPumpPredicateDelegate PostTranslate;
|
public event MsgPumpPredicateDelegate? PostTranslate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs after <see cref="PeekMessage(out MSG, HWND, uint, uint, PM)"/> and determines if message should be translated or dispatched.
|
/// Occurs after <see cref="PeekMessage(out MSG, HWND, uint, uint, PM)"/> and determines if message should be translated or dispatched.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event MsgPumpPredicateDelegate PreProcess;
|
public event MsgPumpPredicateDelegate? PreProcess;
|
||||||
|
|
||||||
/// <inhertdoc/>
|
/// <inhertdoc/>
|
||||||
protected override int RunLoop()
|
protected override int RunLoop()
|
||||||
|
|
|
@ -23,12 +23,12 @@ namespace Vanara.PInvoke;
|
||||||
/// <seealso cref="System.IDisposable"/>
|
/// <seealso cref="System.IDisposable"/>
|
||||||
public abstract class SystemEventHandler : IDisposable
|
public abstract class SystemEventHandler : IDisposable
|
||||||
{
|
{
|
||||||
private static ManualResetEvent eventWindowReady;
|
private static ManualResetEvent? eventWindowReady;
|
||||||
private static Thread windowThread;
|
private static Thread? windowThread;
|
||||||
private readonly Dictionary<Guid, Delegate> eventHandles = new Dictionary<Guid, Delegate>();
|
private readonly Dictionary<Guid, Delegate> eventHandles = new();
|
||||||
private readonly object lockObj = new object();
|
private readonly object lockObj = new();
|
||||||
private bool disposedValue;
|
private bool disposedValue;
|
||||||
private BasicMessageWindow msgWindow;
|
private BasicMessageWindow? msgWindow;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="SystemEventHandler"/> class.</summary>
|
/// <summary>Initializes a new instance of the <see cref="SystemEventHandler"/> class.</summary>
|
||||||
/// <param name="forceThread">
|
/// <param name="forceThread">
|
||||||
|
@ -61,7 +61,7 @@ public abstract class SystemEventHandler : IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Occurs when the message window handle has been created.</summary>
|
/// <summary>Occurs when the message window handle has been created.</summary>
|
||||||
public event EventHandler MessageWindowHandleCreated;
|
public event EventHandler? MessageWindowHandleCreated;
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is running in a thread.</summary>
|
/// <summary>Gets a value indicating whether this instance is running in a thread.</summary>
|
||||||
/// <value><see langword="true"/> if this instance is running in a thread; otherwise, <see langword="false"/>.</value>
|
/// <value><see langword="true"/> if this instance is running in a thread; otherwise, <see langword="false"/>.</value>
|
||||||
|
@ -71,7 +71,7 @@ public abstract class SystemEventHandler : IDisposable
|
||||||
/// <value>The message window handle.</value>
|
/// <value>The message window handle.</value>
|
||||||
public HWND MessageWindowHandle => msgWindow?.Handle ?? HWND.NULL;
|
public HWND MessageWindowHandle => msgWindow?.Handle ?? HWND.NULL;
|
||||||
|
|
||||||
private ManualResetEvent ThreadRunning { get; set; }
|
private ManualResetEvent? ThreadRunning { get; set; }
|
||||||
|
|
||||||
/// <summary>Adds a delegate and its associated key to the handler list.</summary>
|
/// <summary>Adds a delegate and its associated key to the handler list.</summary>
|
||||||
/// <param name="key">The key.</param>
|
/// <param name="key">The key.</param>
|
||||||
|
@ -80,7 +80,7 @@ public abstract class SystemEventHandler : IDisposable
|
||||||
{
|
{
|
||||||
lock (lockObj)
|
lock (lockObj)
|
||||||
{
|
{
|
||||||
if (!eventHandles.TryGetValue(key, out Delegate h))
|
if (!eventHandles.TryGetValue(key, out Delegate? h))
|
||||||
{
|
{
|
||||||
eventHandles.Add(key, value);
|
eventHandles.Add(key, value);
|
||||||
OnEventAdd(key);
|
OnEventAdd(key);
|
||||||
|
@ -99,7 +99,7 @@ public abstract class SystemEventHandler : IDisposable
|
||||||
{
|
{
|
||||||
lock (lockObj)
|
lock (lockObj)
|
||||||
{
|
{
|
||||||
if (eventHandles.TryGetValue(key, out Delegate h))
|
if (eventHandles.TryGetValue(key, out Delegate? h))
|
||||||
{
|
{
|
||||||
h = Delegate.Remove(h, value);
|
h = Delegate.Remove(h, value);
|
||||||
if (h is null || h.GetInvocationList().Length == 0)
|
if (h is null || h.GetInvocationList().Length == 0)
|
||||||
|
@ -144,7 +144,7 @@ public abstract class SystemEventHandler : IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msgWindow.Dispose();
|
msgWindow?.Dispose();
|
||||||
|
|
||||||
disposedValue = true;
|
disposedValue = true;
|
||||||
}
|
}
|
||||||
|
@ -202,24 +202,25 @@ public abstract class SystemEventHandler : IDisposable
|
||||||
/// <param name="args">The arguments.</param>
|
/// <param name="args">The arguments.</param>
|
||||||
/// <returns>The value returned by the call to the delegate list.</returns>
|
/// <returns>The value returned by the call to the delegate list.</returns>
|
||||||
/// <exception cref="InvalidOperationException">Event for {key} is not registered.</exception>
|
/// <exception cref="InvalidOperationException">Event for {key} is not registered.</exception>
|
||||||
protected object RaiseEvent(Guid key, params object[] args)
|
protected object? RaiseEvent(Guid key, params object?[] args)
|
||||||
{
|
{
|
||||||
Delegate h;
|
Delegate? h;
|
||||||
lock (lockObj)
|
lock (lockObj)
|
||||||
{
|
{
|
||||||
if (!eventHandles.TryGetValue(key, out h))
|
if (!eventHandles.TryGetValue(key, out h))
|
||||||
throw new InvalidOperationException($"Event for {key} is not registered.");
|
throw new InvalidOperationException($"Event for {key} is not registered.");
|
||||||
}
|
}
|
||||||
return h.DynamicInvoke(args);
|
return h?.DynamicInvoke(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MTAThreadProc(object param)
|
private static void MTAThreadProc(object? param)
|
||||||
{
|
{
|
||||||
var handler = (SystemEventHandler)param;
|
if (param is not SystemEventHandler handler)
|
||||||
|
throw new InvalidOperationException("Invalid parameter type.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
handler.Init();
|
handler.Init();
|
||||||
eventWindowReady.Set();
|
eventWindowReady?.Set();
|
||||||
if (!handler.MessageWindowHandle.IsNull)
|
if (!handler.MessageWindowHandle.IsNull)
|
||||||
{
|
{
|
||||||
var keepRunning = true;
|
var keepRunning = true;
|
||||||
|
@ -251,12 +252,12 @@ public abstract class SystemEventHandler : IDisposable
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
eventWindowReady.Set();
|
eventWindowReady?.Set();
|
||||||
if (e is not (ThreadInterruptedException or ThreadAbortException))
|
if (e is not (ThreadInterruptedException or ThreadAbortException))
|
||||||
System.Diagnostics.Debug.Fail("Unexpected thread exception in SystemEventHandler thread.", e.ToString());
|
System.Diagnostics.Debug.Fail("Unexpected thread exception in SystemEventHandler thread.", e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.ThreadRunning.Set();
|
handler.ThreadRunning?.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
|
|
|
@ -25,7 +25,7 @@ public static partial class User32
|
||||||
/// <summary>Creates a <see cref="NMHDR"/> structure from an LPARAM value.</summary>
|
/// <summary>Creates a <see cref="NMHDR"/> structure from an LPARAM value.</summary>
|
||||||
/// <param name="lParam">The LPARAM value.</param>
|
/// <param name="lParam">The LPARAM value.</param>
|
||||||
/// <returns>A <see cref="NMHDR"/> structure.</returns>
|
/// <returns>A <see cref="NMHDR"/> structure.</returns>
|
||||||
public static NMHDR FromLParam(IntPtr lParam) => (NMHDR)Marshal.PtrToStructure(lParam, typeof(NMHDR));
|
public static NMHDR FromLParam(IntPtr lParam) => lParam.ToStructure<NMHDR>();
|
||||||
|
|
||||||
#if ALLOWSPAN
|
#if ALLOWSPAN
|
||||||
/// <summary>Creates a reference to an <see cref="NMHDR"/> structure from an LPARAM value.</summary>
|
/// <summary>Creates a reference to an <see cref="NMHDR"/> structure from an LPARAM value.</summary>
|
||||||
|
|
|
@ -720,16 +720,16 @@ public static partial class User32
|
||||||
/// <summary>Provides a handle to a device notification.</summary>
|
/// <summary>Provides a handle to a device notification.</summary>
|
||||||
[PInvokeData("dbt.h")]
|
[PInvokeData("dbt.h")]
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HDEVNOTIFY : IHandle
|
public readonly struct HDEVNOTIFY : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HDEVNOTIFY"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HDEVNOTIFY"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HDEVNOTIFY(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HDEVNOTIFY(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HDEVNOTIFY"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HDEVNOTIFY"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HDEVNOTIFY NULL => new HDEVNOTIFY(IntPtr.Zero);
|
public static HDEVNOTIFY NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -742,7 +742,7 @@ public static partial class User32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HDEVNOTIFY"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HDEVNOTIFY"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HDEVNOTIFY(IntPtr h) => new HDEVNOTIFY(h);
|
public static implicit operator HDEVNOTIFY(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -757,7 +757,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HDEVNOTIFY h1, HDEVNOTIFY h2) => h1.Equals(h2);
|
public static bool operator ==(HDEVNOTIFY h1, HDEVNOTIFY h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HDEVNOTIFY h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HDEVNOTIFY h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -695,16 +695,16 @@ public static partial class User32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a DPI awareness context.</summary>
|
/// <summary>Provides a handle to a DPI awareness context.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct DPI_AWARENESS_CONTEXT : IHandle
|
public readonly struct DPI_AWARENESS_CONTEXT : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="DPI_AWARENESS_CONTEXT"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="DPI_AWARENESS_CONTEXT"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public DPI_AWARENESS_CONTEXT(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public DPI_AWARENESS_CONTEXT(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="DPI_AWARENESS_CONTEXT"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="DPI_AWARENESS_CONTEXT"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static DPI_AWARENESS_CONTEXT NULL => new DPI_AWARENESS_CONTEXT(IntPtr.Zero);
|
public static DPI_AWARENESS_CONTEXT NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -717,7 +717,7 @@ public static partial class User32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="DPI_AWARENESS_CONTEXT"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="DPI_AWARENESS_CONTEXT"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator DPI_AWARENESS_CONTEXT(IntPtr h) => new DPI_AWARENESS_CONTEXT(h);
|
public static implicit operator DPI_AWARENESS_CONTEXT(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -732,7 +732,7 @@ public static partial class User32
|
||||||
public static bool operator ==(DPI_AWARENESS_CONTEXT h1, DPI_AWARENESS_CONTEXT h2) => h1.Equals(h2);
|
public static bool operator ==(DPI_AWARENESS_CONTEXT h1, DPI_AWARENESS_CONTEXT h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is DPI_AWARENESS_CONTEXT h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is DPI_AWARENESS_CONTEXT h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -1135,16 +1135,16 @@ public static partial class User32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a hook.</summary>
|
/// <summary>Provides a handle to a hook.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HHOOK : IUserHandle
|
public readonly struct HHOOK : IUserHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HHOOK"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HHOOK"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HHOOK(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HHOOK(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HHOOK"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HHOOK"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HHOOK NULL => new HHOOK(IntPtr.Zero);
|
public static HHOOK NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -1157,7 +1157,7 @@ public static partial class User32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HHOOK"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HHOOK"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HHOOK(IntPtr h) => new HHOOK(h);
|
public static implicit operator HHOOK(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -1172,7 +1172,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HHOOK h1, HHOOK h2) => h1.Equals(h2);
|
public static bool operator ==(HHOOK h1, HHOOK h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HHOOK h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HHOOK h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
@ -1183,16 +1183,16 @@ public static partial class User32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a Windows Event Hook.</summary>
|
/// <summary>Provides a handle to a Windows Event Hook.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HWINEVENTHOOK : IHandle
|
public readonly struct HWINEVENTHOOK : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HWINEVENTHOOK"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HWINEVENTHOOK"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HWINEVENTHOOK(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HWINEVENTHOOK(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HWINEVENTHOOK"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HWINEVENTHOOK"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HWINEVENTHOOK NULL => new HWINEVENTHOOK(IntPtr.Zero);
|
public static HWINEVENTHOOK NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -1205,7 +1205,7 @@ public static partial class User32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HWINEVENTHOOK"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HWINEVENTHOOK"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HWINEVENTHOOK(IntPtr h) => new HWINEVENTHOOK(h);
|
public static implicit operator HWINEVENTHOOK(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -1220,7 +1220,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HWINEVENTHOOK h1, HWINEVENTHOOK h2) => h1.Equals(h2);
|
public static bool operator ==(HWINEVENTHOOK h1, HWINEVENTHOOK h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HWINEVENTHOOK h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HWINEVENTHOOK h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -690,7 +690,7 @@ public static partial class User32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a RAWINPUT structure.</summary>
|
/// <summary>Provides a handle to a RAWINPUT structure.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HRAWINPUT : IHandle
|
public readonly struct HRAWINPUT : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HRAWINPUT h1, HRAWINPUT h2) => h1.Equals(h2);
|
public static bool operator ==(HRAWINPUT h1, HRAWINPUT h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HRAWINPUT h && handle == h.handle;
|
public override bool Equals(object? obj) => obj is HRAWINPUT h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -2841,7 +2841,7 @@ public static partial class User32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a .</summary>
|
/// <summary>Provides a handle to a .</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HKL : IHandle
|
public readonly struct HKL : IHandle
|
||||||
{
|
{
|
||||||
private readonly IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
|
@ -2878,7 +2878,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HKL h1, HKL h2) => h1.Equals(h2);
|
public static bool operator ==(HKL h1, HKL h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HKL h && handle == h.handle;
|
public override bool Equals(object? obj) => obj is HKL h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -1248,7 +1248,7 @@ public static partial class User32
|
||||||
// DWORD nCount, const HANDLE *pHandles, BOOL fWaitAll, DWORD dwMilliseconds, DWORD dwWakeMask );
|
// DWORD nCount, const HANDLE *pHandles, BOOL fWaitAll, DWORD dwMilliseconds, DWORD dwWakeMask );
|
||||||
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
|
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
|
||||||
[PInvokeData("winuser.h", MSDNShortId = "0629f1b3-6805-43a7-9aeb-4f80939ec62c")]
|
[PInvokeData("winuser.h", MSDNShortId = "0629f1b3-6805-43a7-9aeb-4f80939ec62c")]
|
||||||
public static extern uint MsgWaitForMultipleObjects(uint nCount, HANDLE[] pHandles, [MarshalAs(UnmanagedType.Bool)] bool fWaitAll, uint dwMilliseconds,
|
public static extern uint MsgWaitForMultipleObjects(uint nCount, HANDLE[]? pHandles, [MarshalAs(UnmanagedType.Bool)] bool fWaitAll, uint dwMilliseconds,
|
||||||
QS dwWakeMask);
|
QS dwWakeMask);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1511,7 +1511,7 @@ public static partial class User32
|
||||||
// MsgWaitForMultipleObjectsEx( DWORD nCount, const HANDLE *pHandles, DWORD dwMilliseconds, DWORD dwWakeMask, DWORD dwFlags );
|
// MsgWaitForMultipleObjectsEx( DWORD nCount, const HANDLE *pHandles, DWORD dwMilliseconds, DWORD dwWakeMask, DWORD dwFlags );
|
||||||
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
|
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
|
||||||
[PInvokeData("winuser.h", MSDNShortId = "1774b721-3ad4-492e-96af-b71de9066f0c")]
|
[PInvokeData("winuser.h", MSDNShortId = "1774b721-3ad4-492e-96af-b71de9066f0c")]
|
||||||
public static extern uint MsgWaitForMultipleObjectsEx(uint nCount, HANDLE[] pHandles, uint dwMilliseconds, QS dwWakeMask, MWMO dwFlags);
|
public static extern uint MsgWaitForMultipleObjectsEx(uint nCount, HANDLE[]? pHandles, uint dwMilliseconds, QS dwWakeMask, MWMO dwFlags);
|
||||||
|
|
||||||
/// <summary>Packs a Dynamic Data Exchange (DDE) lParam value into an internal structure used for sharing DDE data between processes.</summary>
|
/// <summary>Packs a Dynamic Data Exchange (DDE) lParam value into an internal structure used for sharing DDE data between processes.</summary>
|
||||||
/// <param name="msg">
|
/// <param name="msg">
|
||||||
|
|
|
@ -1478,7 +1478,7 @@ public static partial class User32
|
||||||
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("winuser.h", MSDNShortId = "5a823d36-d08b-41c9-8857-540576f54b55")]
|
[PInvokeData("winuser.h", MSDNShortId = "5a823d36-d08b-41c9-8857-540576f54b55")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool InvalidateRect(HWND hWnd, [In] PRECT lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase);
|
public static extern bool InvalidateRect(HWND hWnd, [In, Optional] PRECT? lpRect, [MarshalAs(UnmanagedType.Bool)] bool bErase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>InvalidateRgn</c> function invalidates the client area within the specified region by adding it to the current update
|
/// The <c>InvalidateRgn</c> function invalidates the client area within the specified region by adding it to the current update
|
||||||
|
@ -1516,7 +1516,7 @@ public static partial class User32
|
||||||
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("winuser.h", MSDNShortId = "b5b44efe-8045-4e54-89f9-1766689a053d")]
|
[PInvokeData("winuser.h", MSDNShortId = "b5b44efe-8045-4e54-89f9-1766689a053d")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool InvalidateRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bErase);
|
public static extern bool InvalidateRgn(HWND hWnd, [In, Optional] HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bErase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>LockWindowUpdate</c> function disables or enables drawing in the specified window. Only one window can be locked at a time.
|
/// The <c>LockWindowUpdate</c> function disables or enables drawing in the specified window. Only one window can be locked at a time.
|
||||||
|
@ -1747,7 +1747,7 @@ public static partial class User32
|
||||||
// bRedraw );
|
// bRedraw );
|
||||||
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("winuser.h", MSDNShortId = "06209d0c-14f9-45ec-ae2c-9cc596b5bbaa")]
|
[PInvokeData("winuser.h", MSDNShortId = "06209d0c-14f9-45ec-ae2c-9cc596b5bbaa")]
|
||||||
public static extern int SetWindowRgn(HWND hWnd, HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
|
public static extern int SetWindowRgn(HWND hWnd, [In, Optional] HRGN hRgn, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>UpdateWindow</c> function updates the client area of the specified window by sending a WM_PAINT message to the window if
|
/// The <c>UpdateWindow</c> function updates the client area of the specified window by sending a WM_PAINT message to the window if
|
||||||
|
@ -1793,7 +1793,7 @@ public static partial class User32
|
||||||
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("winuser.h", MSDNShortId = "961dd768-1849-44df-bc7f-480881ed6477")]
|
[PInvokeData("winuser.h", MSDNShortId = "961dd768-1849-44df-bc7f-480881ed6477")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool ValidateRect(HWND hWnd, [In] PRECT lpRect);
|
public static extern bool ValidateRect(HWND hWnd, [In, Optional] PRECT? lpRect);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <c>ValidateRgn</c> function validates the client area within a region by removing the region from the current update region
|
/// The <c>ValidateRgn</c> function validates the client area within a region by removing the region from the current update region
|
||||||
|
@ -1819,7 +1819,7 @@ public static partial class User32
|
||||||
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
|
||||||
[PInvokeData("winuser.h", MSDNShortId = "80fb1d4a-d9b1-4e67-b585-eee81893ed34")]
|
[PInvokeData("winuser.h", MSDNShortId = "80fb1d4a-d9b1-4e67-b585-eee81893ed34")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool ValidateRgn(HWND hWnd, HRGN hRgn);
|
public static extern bool ValidateRgn(HWND hWnd, [In, Optional] HRGN hRgn);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>
|
/// <para>
|
||||||
|
|
|
@ -1748,16 +1748,16 @@ public static partial class User32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a synthetic pointer device.</summary>
|
/// <summary>Provides a handle to a synthetic pointer device.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HSYNTHETICPOINTERDEVICE : IHandle
|
public readonly struct HSYNTHETICPOINTERDEVICE : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HSYNTHETICPOINTERDEVICE"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HSYNTHETICPOINTERDEVICE"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HSYNTHETICPOINTERDEVICE(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HSYNTHETICPOINTERDEVICE(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HSYNTHETICPOINTERDEVICE"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HSYNTHETICPOINTERDEVICE"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HSYNTHETICPOINTERDEVICE NULL => new HSYNTHETICPOINTERDEVICE(IntPtr.Zero);
|
public static HSYNTHETICPOINTERDEVICE NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -1770,7 +1770,7 @@ public static partial class User32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HSYNTHETICPOINTERDEVICE"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HSYNTHETICPOINTERDEVICE"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HSYNTHETICPOINTERDEVICE(IntPtr h) => new HSYNTHETICPOINTERDEVICE(h);
|
public static implicit operator HSYNTHETICPOINTERDEVICE(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -1785,7 +1785,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HSYNTHETICPOINTERDEVICE h1, HSYNTHETICPOINTERDEVICE h2) => h1.Equals(h2);
|
public static bool operator ==(HSYNTHETICPOINTERDEVICE h1, HSYNTHETICPOINTERDEVICE h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HSYNTHETICPOINTERDEVICE h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HSYNTHETICPOINTERDEVICE h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -225,7 +225,7 @@ public static partial class User32
|
||||||
/// NULL.To get extended error information, call GetLastError.
|
/// NULL.To get extended error information, call GetLastError.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static SafeHBITMAP LoadImage_Bitmap(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
public static SafeHBITMAP LoadImage_Bitmap(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
||||||
new SafeHBITMAP(LoadImage(hinst, lpszName, LoadImageType.IMAGE_BITMAP, cxDesired, cyDesired, fuLoad), true);
|
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_BITMAP, cxDesired, cyDesired, fuLoad), true);
|
||||||
|
|
||||||
/// <summary>Loads a cursor or animated cursor.</summary>
|
/// <summary>Loads a cursor or animated cursor.</summary>
|
||||||
/// <param name="hinst">
|
/// <param name="hinst">
|
||||||
|
@ -270,7 +270,7 @@ public static partial class User32
|
||||||
/// NULL.To get extended error information, call GetLastError.
|
/// NULL.To get extended error information, call GetLastError.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static SafeHCURSOR LoadImage_Cursor(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
public static SafeHCURSOR LoadImage_Cursor(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
||||||
new SafeHCURSOR(LoadImage(hinst, lpszName, LoadImageType.IMAGE_CURSOR, cxDesired, cyDesired, fuLoad), true);
|
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_CURSOR, cxDesired, cyDesired, fuLoad), true);
|
||||||
|
|
||||||
/// <summary>Loads an enhanced metafile.</summary>
|
/// <summary>Loads an enhanced metafile.</summary>
|
||||||
/// <param name="hinst">
|
/// <param name="hinst">
|
||||||
|
@ -315,7 +315,7 @@ public static partial class User32
|
||||||
/// NULL.To get extended error information, call GetLastError.
|
/// NULL.To get extended error information, call GetLastError.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static SafeHENHMETAFILE LoadImage_EnhMetaFile(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
public static SafeHENHMETAFILE LoadImage_EnhMetaFile(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
||||||
new SafeHENHMETAFILE(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ENHMETAFILE, cxDesired, cyDesired, fuLoad), true);
|
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ENHMETAFILE, cxDesired, cyDesired, fuLoad), true);
|
||||||
|
|
||||||
/// <summary>Loads an icon.</summary>
|
/// <summary>Loads an icon.</summary>
|
||||||
/// <param name="hinst">
|
/// <param name="hinst">
|
||||||
|
@ -360,7 +360,7 @@ public static partial class User32
|
||||||
/// NULL.To get extended error information, call GetLastError.
|
/// NULL.To get extended error information, call GetLastError.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static SafeHICON LoadImage_Icon(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
public static SafeHICON LoadImage_Icon(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
|
||||||
new SafeHICON(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ICON, cxDesired, cyDesired, fuLoad), true);
|
new(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ICON, cxDesired, cyDesired, fuLoad), true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads a string resource from the executable file associated with a specified module, copies the string into a buffer, and appends
|
/// Loads a string resource from the executable file associated with a specified module, copies the string into a buffer, and appends
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ public static partial class User32
|
||||||
public uint cbExtraArgs;
|
public uint cbExtraArgs;
|
||||||
|
|
||||||
/// <summary>A default value for <see cref="GESTUREINFO"/> with the <see cref="cbSize"/> field value set correctly.</summary>
|
/// <summary>A default value for <see cref="GESTUREINFO"/> with the <see cref="cbSize"/> field value set correctly.</summary>
|
||||||
public static readonly GESTUREINFO Default = new GESTUREINFO { cbSize = (uint)Marshal.SizeOf(typeof(GESTUREINFO)) };
|
public static readonly GESTUREINFO Default = new() { cbSize = (uint)Marshal.SizeOf(typeof(GESTUREINFO)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>When transmitted with WM_GESTURENOTIFY messages, passes information about a gesture.</summary>
|
/// <summary>When transmitted with WM_GESTURENOTIFY messages, passes information about a gesture.</summary>
|
||||||
|
@ -1324,21 +1324,21 @@ public static partial class User32
|
||||||
public uint dwInstanceID;
|
public uint dwInstanceID;
|
||||||
|
|
||||||
/// <summary>A default value for <see cref="GESTURENOTIFYSTRUCT"/> with the <see cref="cbSize"/> field value set correctly.</summary>
|
/// <summary>A default value for <see cref="GESTURENOTIFYSTRUCT"/> with the <see cref="cbSize"/> field value set correctly.</summary>
|
||||||
public static readonly GESTURENOTIFYSTRUCT Default = new GESTURENOTIFYSTRUCT { cbSize = (uint)Marshal.SizeOf(typeof(GESTURENOTIFYSTRUCT)) };
|
public static readonly GESTURENOTIFYSTRUCT Default = new() { cbSize = (uint)Marshal.SizeOf(typeof(GESTURENOTIFYSTRUCT)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Provides a handle to a gesture info.</summary>
|
/// <summary>Provides a handle to a gesture info.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HGESTUREINFO : IHandle
|
public readonly struct HGESTUREINFO : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HGESTUREINFO"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HGESTUREINFO"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HGESTUREINFO(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HGESTUREINFO(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HGESTUREINFO"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HGESTUREINFO"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HGESTUREINFO NULL => new HGESTUREINFO(IntPtr.Zero);
|
public static HGESTUREINFO NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -1351,7 +1351,7 @@ public static partial class User32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HGESTUREINFO"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HGESTUREINFO"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HGESTUREINFO(IntPtr h) => new HGESTUREINFO(h);
|
public static implicit operator HGESTUREINFO(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -1366,7 +1366,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HGESTUREINFO h1, HGESTUREINFO h2) => h1.Equals(h2);
|
public static bool operator ==(HGESTUREINFO h1, HGESTUREINFO h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HGESTUREINFO h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HGESTUREINFO h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
@ -1377,16 +1377,16 @@ public static partial class User32
|
||||||
|
|
||||||
/// <summary>Provides a handle to a touch input.</summary>
|
/// <summary>Provides a handle to a touch input.</summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct HTOUCHINPUT : IHandle
|
public readonly struct HTOUCHINPUT : IHandle
|
||||||
{
|
{
|
||||||
private IntPtr handle;
|
private readonly IntPtr handle;
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the <see cref="HTOUCHINPUT"/> struct.</summary>
|
/// <summary>Initializes a new instance of the <see cref="HTOUCHINPUT"/> struct.</summary>
|
||||||
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
|
||||||
public HTOUCHINPUT(IntPtr preexistingHandle) => handle = preexistingHandle;
|
public HTOUCHINPUT(IntPtr preexistingHandle) => handle = preexistingHandle;
|
||||||
|
|
||||||
/// <summary>Returns an invalid handle by instantiating a <see cref="HTOUCHINPUT"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
/// <summary>Returns an invalid handle by instantiating a <see cref="HTOUCHINPUT"/> object with <see cref="IntPtr.Zero"/>.</summary>
|
||||||
public static HTOUCHINPUT NULL => new HTOUCHINPUT(IntPtr.Zero);
|
public static HTOUCHINPUT NULL => new(IntPtr.Zero);
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
/// <summary>Gets a value indicating whether this instance is a null handle.</summary>
|
||||||
public bool IsNull => handle == IntPtr.Zero;
|
public bool IsNull => handle == IntPtr.Zero;
|
||||||
|
@ -1399,7 +1399,7 @@ public static partial class User32
|
||||||
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HTOUCHINPUT"/>.</summary>
|
/// <summary>Performs an implicit conversion from <see cref="IntPtr"/> to <see cref="HTOUCHINPUT"/>.</summary>
|
||||||
/// <param name="h">The pointer to a handle.</param>
|
/// <param name="h">The pointer to a handle.</param>
|
||||||
/// <returns>The result of the conversion.</returns>
|
/// <returns>The result of the conversion.</returns>
|
||||||
public static implicit operator HTOUCHINPUT(IntPtr h) => new HTOUCHINPUT(h);
|
public static implicit operator HTOUCHINPUT(IntPtr h) => new(h);
|
||||||
|
|
||||||
/// <summary>Implements the operator !=.</summary>
|
/// <summary>Implements the operator !=.</summary>
|
||||||
/// <param name="h1">The first handle.</param>
|
/// <param name="h1">The first handle.</param>
|
||||||
|
@ -1414,7 +1414,7 @@ public static partial class User32
|
||||||
public static bool operator ==(HTOUCHINPUT h1, HTOUCHINPUT h2) => h1.Equals(h2);
|
public static bool operator ==(HTOUCHINPUT h1, HTOUCHINPUT h2) => h1.Equals(h2);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool Equals(object obj) => obj is HTOUCHINPUT h ? handle == h.handle : false;
|
public override bool Equals(object? obj) => obj is HTOUCHINPUT h && handle == h.handle;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override int GetHashCode() => handle.GetHashCode();
|
public override int GetHashCode() => handle.GetHashCode();
|
||||||
|
|
|
@ -8710,7 +8710,7 @@ public static partial class User32
|
||||||
public MessageFilterInformation ExtStatus;
|
public MessageFilterInformation ExtStatus;
|
||||||
|
|
||||||
/// <summary>The default value for this structure with the size field set appropriately.</summary>
|
/// <summary>The default value for this structure with the size field set appropriately.</summary>
|
||||||
public static CHANGEFILTERSTRUCT Default = new CHANGEFILTERSTRUCT() { cbSize = (uint)Marshal.SizeOf(typeof(CHANGEFILTERSTRUCT)) };
|
public static CHANGEFILTERSTRUCT Default = new() { cbSize = (uint)Marshal.SizeOf(typeof(CHANGEFILTERSTRUCT)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -9767,7 +9767,7 @@ public static partial class User32
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.LPTStr)]
|
[MarshalAs(UnmanagedType.LPTStr)]
|
||||||
public string lpszMenuName;
|
public string? lpszMenuName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Type: <c>LPCTSTR</c></para>
|
/// <para>Type: <c>LPCTSTR</c></para>
|
||||||
|
|
|
@ -341,7 +341,7 @@ public static partial class Usp10
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true"/> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <see langword="false"/>.
|
/// <see langword="true"/> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <see langword="false"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public override bool Equals(object obj) => obj is OPENTYPE_TAG tAG && Equals(tAG);
|
public override bool Equals(object? obj) => obj is OPENTYPE_TAG tAG && Equals(tAG);
|
||||||
|
|
||||||
/// <summary>Determines whether the specified <see cref="OPENTYPE_TAG"/>, is equal to this instance.</summary>
|
/// <summary>Determines whether the specified <see cref="OPENTYPE_TAG"/>, is equal to this instance.</summary>
|
||||||
/// <param name="other">The <see cref="OPENTYPE_TAG"/> to compare with this instance.</param>
|
/// <param name="other">The <see cref="OPENTYPE_TAG"/> to compare with this instance.</param>
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Vanara.PInvoke;
|
||||||
|
|
||||||
public class GenericComTester<TInt> where TInt : class
|
public class GenericComTester<TInt> where TInt : class
|
||||||
{
|
{
|
||||||
protected Stack<object> objects = new Stack<object>();
|
protected Stack<object> objects = new();
|
||||||
|
|
||||||
public virtual TInt Instance => (TInt)objects.Peek();
|
public virtual TInt Instance => (TInt)objects.Peek();
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ namespace Vanara.PInvoke.Tests;
|
||||||
|
|
||||||
public abstract class ResultIs // : NUnit.Framework.Is
|
public abstract class ResultIs // : NUnit.Framework.Is
|
||||||
{
|
{
|
||||||
public static FailureConstraint Failure => new FailureConstraint();
|
public static FailureConstraint Failure => new();
|
||||||
public static MyConstraintExpression Not => MyConstraintExpression.Not;
|
public static MyConstraintExpression Not => MyConstraintExpression.Not;
|
||||||
public static SuccessfulConstraint Successful => new SuccessfulConstraint();
|
public static SuccessfulConstraint Successful => new();
|
||||||
public static ValidHandleConstraint ValidHandle => new ValidHandleConstraint();
|
public static ValidHandleConstraint ValidHandle => new();
|
||||||
|
|
||||||
public static FailureConstraint FailureCode(object expectedError) => new FailureConstraint(expectedError);
|
public static FailureConstraint FailureCode(object expectedError) => new(expectedError);
|
||||||
public static ValueConstraint Value(object value) => new ValueConstraint(value);
|
public static ValueConstraint Value(object value) => new(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MyConstraintExpression
|
public class MyConstraintExpression
|
||||||
|
@ -20,11 +20,11 @@ public class MyConstraintExpression
|
||||||
|
|
||||||
private MyConstraintExpression(OpConstraint.Op _op) => op = _op;
|
private MyConstraintExpression(OpConstraint.Op _op) => op = _op;
|
||||||
|
|
||||||
public static MyConstraintExpression Not => new MyConstraintExpression(OpConstraint.Op.Not);
|
public static MyConstraintExpression Not => new(OpConstraint.Op.Not);
|
||||||
|
|
||||||
public ValidHandleConstraint ValidHandle => new ValidHandleConstraint(op);
|
public ValidHandleConstraint ValidHandle => new(op);
|
||||||
|
|
||||||
public ValueConstraint Value(object value) => new ValueConstraint(value, op);
|
public ValueConstraint Value(object value) => new(value, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FailureConstraint : Constraint
|
public class FailureConstraint : Constraint
|
||||||
|
|
|
@ -192,7 +192,7 @@ public static class TestCaseSources
|
||||||
|
|
||||||
public DEnum(StrArrDict parent) => p = parent;
|
public DEnum(StrArrDict parent) => p = parent;
|
||||||
|
|
||||||
public KeyValuePair<string, string> Current => new KeyValuePair<string, string>(p.keys[c], p.values[c]);
|
public KeyValuePair<string, string> Current => new(p.keys[c], p.values[c]);
|
||||||
|
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current => Current;
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class BitmapTests
|
||||||
ajBits[0] = 0xff; ajBits[2] = 0xc; ajBits[3] = 0xf0; ajBits[4] = 0x0f;
|
ajBits[0] = 0xff; ajBits[2] = 0xc; ajBits[3] = 0xf0; ajBits[4] = 0x0f;
|
||||||
|
|
||||||
var bisize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)) + 256 * Marshal.SizeOf(typeof(uint));
|
var bisize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)) + 256 * Marshal.SizeOf(typeof(uint));
|
||||||
using SafeBITMAPINFO pbi = new SafeBITMAPINFO(default, bisize);
|
using SafeBITMAPINFO pbi = new(default, bisize);
|
||||||
|
|
||||||
using var hdcScreen = GetDC();
|
using var hdcScreen = GetDC();
|
||||||
Assert.That(hdcScreen, ResultIs.ValidHandle);
|
Assert.That(hdcScreen, ResultIs.ValidHandle);
|
||||||
|
|
|
@ -143,6 +143,35 @@ public class Gdi32Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetTextCharsetInfoTest()
|
||||||
|
{
|
||||||
|
using var hdc = SafeHDC.ScreenCompatibleDCHandle;
|
||||||
|
var cs = GetTextCharsetInfo(hdc, out var fs);
|
||||||
|
Assert.AreNotEqual(cs, CharacterSetUint.DEFAULT_CHARSET);
|
||||||
|
fs.WriteValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateCharsetInfoTest()
|
||||||
|
{
|
||||||
|
var acp = Kernel32.GetACP();
|
||||||
|
Assert.That(TranslateCharsetInfo((IntPtr)acp, out var csi, TCI.TCI_SRCCODEPAGE), ResultIs.Successful);
|
||||||
|
csi.WriteValues();
|
||||||
|
|
||||||
|
Assert.That(TranslateCharsetInfo((IntPtr)csi.ciCharset, out csi, TCI.TCI_SRCCHARSET), ResultIs.Successful);
|
||||||
|
csi.WriteValues();
|
||||||
|
|
||||||
|
Assert.That(TranslateCharsetInfo((IntPtr)(int)(uint)Kernel32.GetThreadLocale(), out csi, TCI.TCI_SRCLOCALE), ResultIs.Successful);
|
||||||
|
csi.WriteValues();
|
||||||
|
|
||||||
|
FONTSIGNATURE fs = default;
|
||||||
|
using (var hdc = SafeHDC.ScreenCompatibleDCHandle)
|
||||||
|
GetTextCharsetInfo(hdc, out fs);
|
||||||
|
Assert.That(TranslateCharsetInfo(fs.fsCsb, out csi, TCI.TCI_SRCFONTSIG), ResultIs.Successful);
|
||||||
|
csi.WriteValues();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: [Test]
|
// TODO: [Test]
|
||||||
public void SelectObjectTest()
|
public void SelectObjectTest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,12 +102,12 @@ public static class GdiObjExtensions2
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BrushStyle.BS_HATCHED:
|
case BrushStyle.BS_HATCHED:
|
||||||
HatchBrush hbr = new HatchBrush((System.Drawing.Drawing2D.HatchStyle)lpen.elpHatch.ToInt32(), lpen.elpColor);
|
HatchBrush hbr = new((System.Drawing.Drawing2D.HatchStyle)lpen.elpHatch.ToInt32(), lpen.elpColor);
|
||||||
pen = new Pen(hbr);
|
pen = new Pen(hbr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BrushStyle.BS_PATTERN:
|
case BrushStyle.BS_PATTERN:
|
||||||
TextureBrush pbr = new TextureBrush(Image.FromHbitmap(lpen.elpHatch));
|
TextureBrush pbr = new(Image.FromHbitmap(lpen.elpHatch));
|
||||||
pen = new Pen(pbr);
|
pen = new Pen(pbr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ public static partial class GdiExtension
|
||||||
throw new ArgumentException("Bitmaps must be of the same size and their pixel format must be Format32bppArgb.");
|
throw new ArgumentException("Bitmaps must be of the same size and their pixel format must be Format32bppArgb.");
|
||||||
|
|
||||||
var bmp = new Bitmap(whiteBmp.Width, whiteBmp.Height, whiteBmp.PixelFormat);
|
var bmp = new Bitmap(whiteBmp.Width, whiteBmp.Height, whiteBmp.PixelFormat);
|
||||||
using (SmartBitmapLock oVals = new SmartBitmapLock(bmp), wVals = new SmartBitmapLock(whiteBmp), bVals = new SmartBitmapLock(blackBmp))
|
using (SmartBitmapLock oVals = new(bmp), wVals = new(whiteBmp), bVals = new(blackBmp))
|
||||||
{
|
{
|
||||||
for (var i = 0; i < oVals.Length; i++)
|
for (var i = 0; i < oVals.Length; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue