Курсор изменения HotSpot в WinForms/.NET

Вы можете использовать вложенное выражение ifelse, чтобы поймать все 3 сценария (то же самое, от ng до ug и от ug до ng)

ifelse(df$Dimension == df$Unit, df$Target, 
       ifelse(df$Dimension != df$Unit & grepl('ug', df$Dimension), df$Target / 1000, 
                                                                        df$Target * 1000))

#[1] 0.012 1.000 0.001
8
задан smack0007 15 February 2009 в 14:06
поделиться

2 ответа

Вы верная банка. Вот мои служебные функции, редактирование, как Вы считаете целесообразным :)

    public struct IconInfo
    {
        public bool fIcon;
        public int xHotspot;
        public int yHotspot;
        public IntPtr hbmMask;
        public IntPtr hbmColor;
    }
    [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo);
    [DllImport("user32.dll")]
    public static extern IntPtr CreateIconIndirect(ref IconInfo icon);

    /// <summary>
    /// Create a cursor from a bitmap without resizing and with the specified
    /// hot spot
    /// </summary>
    public static Cursor CreateCursorNoResize(Bitmap bmp, int xHotSpot, int yHotSpot)
    {
        IntPtr ptr = bmp.GetHicon();
        IconInfo tmp = new IconInfo();
        GetIconInfo(ptr, ref tmp);
        tmp.xHotspot = xHotSpot;
        tmp.yHotspot = yHotSpot;
        tmp.fIcon = false;
        ptr = CreateIconIndirect(ref tmp);
        return new Cursor(ptr);
    }


    /// <summary>
    /// Create a 32x32 cursor from a bitmap, with the hot spot in the middle
    /// </summary>
    public static Cursor CreateCursor(Bitmap bmp)
    {
        int xHotSpot = 16;
        int yHotSpot = 16;

        IntPtr ptr = ((Bitmap)ResizeImage(bmp, 32, 32)).GetHicon();
        IconInfo tmp = new IconInfo();
        GetIconInfo(ptr, ref tmp);
        tmp.xHotspot = xHotSpot;
        tmp.yHotspot = yHotSpot;
        tmp.fIcon = false;
        ptr = CreateIconIndirect(ref tmp);
        return new Cursor(ptr);
    }
24
ответ дан 5 December 2019 в 06:39
поделиться

Смотрите на это сообщение на MSDN. Кажется, существует пара возможных решений (использующий P/Invoke), который необходимо смочь к вставке копии и использованию.

0
ответ дан 5 December 2019 в 06:39
поделиться
Другие вопросы по тегам:

Похожие вопросы: