KeyPressEventArgs key_press = new KeyPressEventArgs((char)0);
MouseCursor cursor = MouseCursor.Default;
+ IntPtr curson_handle = IntPtr.Zero;
int cursor_visible_count = 0;
static readonly object SyncRoot = new object();
mouse_last_timestamp = timestamp;
}
+ if (cursor != MouseCursor.Default)
+ {
+ Functions.SetCursor(curson_handle);
+ }
+
if (mouse_outside_window)
{
// Once we receive a mouse move event, it means that the mouse has
}
set
{
- Debug.Print("[Warning] WinGLNative.Cursor property not implemented");
+ if (value != cursor)
+ {
+ var stride = value.Width *
+ (Bitmap.GetPixelFormatSize(System.Drawing.Imaging.PixelFormat.Format32bppArgb) / 8);
+
+ Bitmap bmp;
+ unsafe
+ {
+ fixed (byte* pixels = value.Rgba)
+ {
+ bmp = new Bitmap(value.Width, value.Height, stride,
+ System.Drawing.Imaging.PixelFormat.Format32bppArgb,
+ new IntPtr(pixels));
+ }
+ }
+
+ var iconInfo = new IconInfo();
+ var bmpIcon = bmp.GetHicon();
+ var success = Functions.GetIconInfo(bmpIcon, out iconInfo);
+
+ if (success)
+ {
+ iconInfo.xHotspot = value.X;
+ iconInfo.yHotspot = value.Y;
+ iconInfo.fIcon = false;
+
+ var icon = Functions.CreateIconIndirect(ref iconInfo);
+
+ if (icon != IntPtr.Zero)
+ {
+ // Currently using a custom cursor so destroy it
+ // once replaced
+ bool destoryOld = cursor != MouseCursor.Default;
+
+ cursor = value;
+ curson_handle = icon;
+ var oldCursor = Functions.SetCursor(icon);
+
+ if (destoryOld)
+ {
+ Functions.DestroyIcon(oldCursor);
+ }
+ }
+ }
+ }
}
}