2007-08-28 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Tue, 28 Aug 2007 20:58:47 +0000 (20:58 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Tue, 28 Aug 2007 20:58:47 +0000 (20:58 -0000)
* Cursor.cs: Add HotSpot, hook into XPlatUI.GetCursorInfo.
* XPlatUIWin32.cs: Implement hotspot lookup in GetCursorInfo.

svn path=/trunk/mcs/; revision=84982

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Cursor.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs

index 57049315b5573c1621a0910778a003a348fdfab0..affbc40944fefb71751cb294ec7538e9f742b471 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-28  Jonathan Pobst  <monkey@jpobst.com>
+
+       * Cursor.cs: Add HotSpot, hook into XPlatUI.GetCursorInfo.
+       * XPlatUIWin32.cs: Implement hotspot lookup in GetCursorInfo.
+
 2007-08-28  Jonathan Pobst  <monkey@jpobst.com>
 
        * RadioButton.cs: Use 2.0 rendering.  Use base implementation of TextAlign.
index 159941142ee113370b1f51bc88326182d81c067c..a56d5672bd992d90abaa853ed5c639080b7bba0e 100644 (file)
@@ -240,6 +240,17 @@ namespace System.Windows.Forms {
                        }
                }
 
+#if NET_2_0
+               [MonoTODO ("Implemented for Win32, X11 always returns 0,0")]
+               public Point HotSpot {
+                       get {
+                               int cursor_w, cursor_h, hot_x, hot_y;
+                               XplatUI.GetCursorInfo (Handle, out cursor_w, out cursor_h, out hot_x, out hot_y);
+
+                               return new Point (hot_x, hot_y);
+                       }
+               }
+#endif
                public Size Size {
                        get {
                                return size;
index 78153ae79b6e34069fe4f99ec9ed7c295ebc2744..0d187fe844178b62d93b4c6f11d8dd8960731608 100644 (file)
@@ -275,6 +275,15 @@ namespace System.Windows.Forms {
                        internal short wParamH;
                }
 
+               [StructLayout (LayoutKind.Sequential)]
+               internal struct ICONINFO {
+                       internal bool fIcon;
+                       internal Int32 xHotspot;
+                       internal Int32 yHotspot;
+                       internal IntPtr hbmMask;
+                       internal IntPtr hbmColor;
+               }    
+               
                [StructLayout(LayoutKind.Explicit)]
                internal struct INPUT {
                        [FieldOffset(0)]
@@ -2360,10 +2369,15 @@ namespace System.Windows.Forms {
 
                [MonoTODO]
                internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y) {
+                       ICONINFO ii = new ICONINFO ();
+                       
+                       if (!Win32GetIconInfo (cursor, out ii))
+                               throw new Win32Exception ();
+                               
                        width = 20;
                        height = 20;
-                       hotspot_x = 0;
-                       hotspot_y = 0;
+                       hotspot_x = ii.xHotspot;
+                       hotspot_y = ii.yHotspot;
                }
 
                internal override void SetCursorPos(IntPtr handle, int x, int y) {
@@ -3561,6 +3575,9 @@ namespace System.Windows.Forms {
 
                [DllImport ("kernel32.dll", EntryPoint = "GetSystemPowerStatus", CallingConvention = CallingConvention.StdCall)]
                internal static extern Boolean Win32GetSystemPowerStatus (SYSTEMPOWERSTATUS sps);
+
+               [DllImport ("user32.dll", EntryPoint = "GetIconInfo", CallingConvention = CallingConvention.StdCall)]
+               internal static extern bool Win32GetIconInfo (IntPtr hIcon, out ICONINFO piconinfo);
                #endregion
        }
 }