mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 20:35:29 +00:00
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace PckStudio.Core.Extensions
|
|
{
|
|
public static class CursorExtensions
|
|
{
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
struct PointStruct
|
|
{
|
|
public Int32 x;
|
|
public Int32 y;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
struct CursorInfoStruct
|
|
{
|
|
/// <summary> The structure size in bytes that must be set via calling Marshal.SizeOf(typeof(CursorInfoStruct)).</summary>
|
|
public Int32 cbSize;
|
|
/// <summary> The cursor state: 0 == hidden, 1 == showing, 2 == suppressed (is supposed to be when finger touch is used, but in practice finger touch results in 0, not 2)</summary>
|
|
public Int32 flags;
|
|
/// <summary> A handle to the cursor. </summary>
|
|
public IntPtr hCursor;
|
|
/// <summary> The cursor screen coordinates.</summary>
|
|
public PointStruct pt;
|
|
}
|
|
|
|
/// <summary> Must initialize cbSize</summary>
|
|
[DllImport("user32.dll")]
|
|
static extern bool GetCursorInfo(ref CursorInfoStruct pci);
|
|
|
|
public static bool IsVisible(this Cursor _)
|
|
{
|
|
CursorInfoStruct pci = new CursorInfoStruct();
|
|
pci.cbSize = Marshal.SizeOf(typeof(CursorInfoStruct));
|
|
GetCursorInfo(ref pci);
|
|
// const Int32 hidden = 0x00;
|
|
const Int32 showing = 0x01;
|
|
// const Int32 suppressed = 0x02;
|
|
bool isVisible = ((pci.flags & showing) != 0);
|
|
return isVisible;
|
|
}
|
|
|
|
}
|
|
}
|