Example #1
0
        /// <summary>
        /// Gets or sets a value indicating whether the background image of the <see cref="ListView"/> should be tiled.
        /// </summary>
        /// <param name="listView"></param>
        /// <returns>true if the background image of the <see cref="ListView"/> should be tiled; otherwise, false.
        /// The default is false.</returns>
        public static bool GetBackgroundImageTiled(this ListView listView)
        {
            LVBKIMAGE lvBkImage = new LVBKIMAGE();

            //lvBkImage.ulFlags = LVBKIF.SOURCE_HBITMAP;

            NativeMethods.SendMessage(listView.Handle, LVM_GETBKIMAGE, 0, ref lvBkImage);

            if ((lvBkImage.ulFlags & LVBKIF.STYLE_TILE) == LVBKIF.STYLE_TILE)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// Gets or sets the background image displayed in the <see cref="ListView"/>.
        /// </summary>
        /// <param name="listView"></param>
        /// <returns></returns>
        public static Bitmap GetBackgroundImage(this ListView listView)
        {
            LVBKIMAGE lvBkImage = new LVBKIMAGE();

            //lvBkImage.ulFlags = LVBKIF.SOURCE_HBITMAP;

            NativeMethods.SendMessage(listView.Handle, LVM_GETBKIMAGE, 0, ref lvBkImage);

            if (lvBkImage.hbm == IntPtr.Zero)
            {
                return(null);
            }
            else
            {
                return(Bitmap.FromHbitmap(lvBkImage.hbm));
            }
        }
Example #3
0
        /// <summary>
        /// Sets the background image displayed in the <see cref="ListView"/>.
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="bitmap">A <see cref="Bitmap"/> that represents the image to display in the background of the control.</param>
        /// <param name="tileLayout">Sets a value indicating whether the background image of the <see cref="ListView"/> should be tiled.</param>
        public static void SetBackgroundImage(this ListView listView, Bitmap bitmap, bool tileLayout)
        {
            LVBKIMAGE lvBkImage = new LVBKIMAGE();

            if (bitmap == null)
            {
                lvBkImage.ulFlags = 0;
            }
            else
            {
                lvBkImage.ulFlags = LVBKIF.SOURCE_HBITMAP | (tileLayout ? LVBKIF.STYLE_TILE : 0);
                lvBkImage.hbm     = bitmap.GetHbitmap();
                //lvBkImage.xOffsetPercent = xOffsetPercent;
                //lvBkImage.yOffsetPercent = yOffsetPercent;
            }

            NativeMethods.SendMessage(listView.Handle, LVM_SETBKIMAGE, 0, ref lvBkImage);
        }
 internal static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, ref LVBKIMAGE lParam);