Exemple #1
0
        /// <summary>
        /// Defines the mouse cursor
        /// </summary>
        /// <param name="bmp">Bitmap handle</param>
        /// <param name="hotspot">Cursor hotspot</param>
        static public void SetCursor(Bitmap bmp, Point hotspot)
        {
            User32.IconInfo tmp = new User32.IconInfo();
            User32.GetIconInfo(bmp.GetHicon(), ref tmp);
            tmp.xHotspot = hotspot.X;
            tmp.yHotspot = hotspot.Y;
            tmp.fIcon    = false;

            Cursor = new Cursor(User32.CreateIconIndirect(ref tmp));
        }
Exemple #2
0
        private static Cursor createCursor(Bitmap bmp, int xHotSpot, int yHotSpot)
        {
            User32.IconInfo iconInfo = new User32.IconInfo();
            User32.GetIconInfo(bmp.GetHicon(), ref iconInfo);
            iconInfo.xHotspot = xHotSpot;
            iconInfo.yHotspot = yHotSpot;
            iconInfo.fIcon    = false;
            SafeIconHandle cursorHandle = User32.CreateIconIndirect(ref iconInfo);

            return(CursorInteropHelper.Create(cursorHandle));
        }