Esempio n. 1
0
        internal static IconHandle CreateIconCursor(byte[] colorArray, int width, int height, int xHotspot, int yHotspot, bool isIcon)
        {
            BitmapHandle colorBitmap = null;
            BitmapHandle maskBitmap  = null;

            try
            {
                var bi = new InteropValues.BITMAPINFO(width, -height, 32)
                {
                    biCompression = InteropValues.BI_RGB
                };

                var bits = IntPtr.Zero;
                colorBitmap = InteropMethods.CreateDIBSection(new HandleRef(null, IntPtr.Zero), ref bi, InteropValues.DIB_RGB_COLORS, ref bits, null, 0);

                if (colorBitmap.IsInvalid || bits == IntPtr.Zero)
                {
                    return(IconHandle.GetInvalidIcon());
                }

                Marshal.Copy(colorArray, 0, bits, colorArray.Length);
                var maskArray = GenerateMaskArray(width, height, colorArray);

                maskBitmap = InteropMethods.CreateBitmap(width, height, 1, 1, maskArray);
                if (maskBitmap.IsInvalid)
                {
                    return(IconHandle.GetInvalidIcon());
                }

                var iconInfo = new InteropValues.ICONINFO
                {
                    fIcon    = isIcon,
                    xHotspot = xHotspot,
                    yHotspot = yHotspot,
                    hbmMask  = maskBitmap,
                    hbmColor = colorBitmap
                };

                return(InteropMethods.CreateIconIndirect(iconInfo));
            }
            finally
            {
                colorBitmap?.Dispose();
                maskBitmap?.Dispose();
            }
        }
Esempio n. 2
0
 public static extern bool CreateCaret(
     WindowHandle hWnd,
     BitmapHandle hBitmap,
     int nWidth,
     int nHeight);
Esempio n. 3
0
 public static void CreateCaret(this WindowHandle window, BitmapHandle bitmap, int width, int height) =>
 ResourceMethods.CreateCaret(window, bitmap, width, height);
Esempio n. 4
0
 public static extern bool SetMenuItemBitmaps(
     MenuHandle hMenu,
     uint uPosition,
     MenuFlags uFlags,
     BitmapHandle hBitmapUnchecked,
     BitmapHandle hBitmapChecked);