Пример #1
0
        private void DrawInternal(IntPtr hdc, int index, int overlayIndex, ImageListDrawOptions options, ImageListDrawStates state, int alpha, Point location, int newSize)
        {
            var param = new IMAGELISTDRAWPARAMS();

            param.cbSize = Marshal.SizeOf(param);
            param.himl   = this.Handle;
            param.hdcDst = hdc;
            param.rgbBk  = -1;
            param.i      = index;
            param.x      = location.X;
            param.y      = location.Y;
            param.cx     = param.cy = newSize == -1 ? 0 : newSize;
            param.fStyle = ((int)options | (overlayIndex << 8) | (newSize == -1 ? 0 : (int)ImageListDrawOptions.Scale));
            param.fState = state;
            param.Frame  = alpha;

            var hresult = this._ImageList.Draw(ref param);

            Marshal.ThrowExceptionForHR(hresult);
        }
Пример #2
0
		/*
[Obsolete("Not Used, Try to Delete!!!", true)]
public void Draw(IntPtr hdc, int index, int overlayIndex, ImageListDrawOptions options, Point location, int newSize = -1) {
	this.DrawInternal(hdc, index, overlayIndex, options, ImageListDrawStates.Normal, 0, location, newSize);
}
*/

		/// <summary>
		/// Draws the icon
		/// </summary>
		/// <param name="hdc">A handle to the destination device context.</param>
		/// <param name="index">The zero-based index of the image to be drawn.</param>
		/// <param name="overlayIndex">The index of the overlay</param>
		/// <param name="options"></param>
		/// <param name="state">A flag that specifies the drawing state. This member can contain one or more image list state flags. You must use comctl32.dll version 6 to use this member. See the Remarks.</param>
		/// <param name="alpha">Used with the alpha blending effect.</param>
		/// <param name="location">The x and y coordinates that specifies where the image is drawn.</param>
		/// <param name="newSize">The new size of the image (Double Check)</param>
		private void DrawInternal(IntPtr hdc, int index, int overlayIndex, ImageListDrawOptions options, ImageListDrawStates state, int alpha, Point location, int newSize) {
			var param = new IMAGELISTDRAWPARAMS() {
				//himl = this.Handle;
				himl = this.Handle,
				hdcDst = hdc,
				rgbBk = -1,
				i = index,
				x = location.X,
				y = location.Y,
				fStyle = ((int)options | (overlayIndex << 8) | (newSize == -1 ? 0 : (int)ImageListDrawOptions.Scale)),
				fState = state,
				Frame = alpha
			};

			param.cx = param.cy = newSize == -1 ? 0 : newSize;
			param.cbSize = Marshal.SizeOf(param);

			var hresult = this._ImageList.Draw(ref param);
			Marshal.ThrowExceptionForHR(hresult);
		}