Esempio n. 1
0
		public static extern Boolean AlphaBlend(
			IntPtr hdcDest,
			Int32 nXOriginDest,
			Int32 nYOriginDest,
			Int32 nWdithDest,
			Int32 nHeightDest,
			IntPtr hdcSrc,
			Int32 nXOriginSrc,
			Int32 nYOriginSrc,
			Int32 nWidthSrc,
			Int32 nHeightSrc,
			BLENDFUNCTION blendFunction
			);
Esempio n. 2
0
		public static extern bool AlphaBlend(
			IntPtr hdcDest,
			int nXOriginDest,
			int nYOriginDest,
			int nWdithDest,
			int nHeightDest,
			IntPtr hdcSrc,
			int nXOriginSrc,
			int nYOriginSrc,
			int nWidthSrc,
			int nHeightSrc,
			BLENDFUNCTION blendFunction
			);
Esempio n. 3
0
		public static extern Boolean UpdateLayeredWindow(
			IntPtr hWnd,
			IntPtr hdcDst,
			ref POINT pptDst,
			ref SIZE psize,
			IntPtr hdcSrc,
			ref POINT pptSrc,
			Int32 crKey,
			ref BLENDFUNCTION pblend,
			Int32 dwFlags
			);
		private new void Invalidate(Rectangle rect)
		{
			Bitmap memoryBitmap = new Bitmap(
				rect.Size.Width,
				rect.Size.Height,
				PixelFormat.Format32bppArgb
				);

			using (Graphics g = Graphics.FromImage(memoryBitmap))
			{
				Rectangle area = new Rectangle(0, 0, rect.Size.Width, rect.Size.Height);
				this.RaisePaintEvent(g, area);
				IntPtr hDC = User32.GetDC(IntPtr.Zero);
				IntPtr memoryDC = Gdi32.CreateCompatibleDC(hDC);
				IntPtr hBitmap = memoryBitmap.GetHbitmap(Color.FromArgb(0));
				IntPtr oldBitmap = Gdi32.SelectObject(memoryDC, hBitmap);

				SIZE size;
				size.cx = rect.Size.Width;
				size.cy = rect.Size.Height;

				POINT location;
				location.x = rect.Location.X;
				location.y = rect.Location.Y;

				POINT sourcePoint;
				sourcePoint.x = 0;
				sourcePoint.y = 0;

				BLENDFUNCTION blend = new BLENDFUNCTION();
				blend.AlphaFormat = (byte)WinGdi.AC_SRC_ALPHA;
				blend.BlendFlags = 0;
				blend.BlendOp = (byte)WinGdi.AC_SRC_OVER;
				blend.SourceConstantAlpha = (byte)(255 - ((this.Opacity * 255) / 100));

				User32.UpdateLayeredWindow(
					this.Handle,
					hDC,
					ref location,
					ref size,
					memoryDC,
					ref sourcePoint,
					0,
					ref blend,
					WinUser.ULW_ALPHA
					);

				Gdi32.SelectObject(memoryDC, oldBitmap);

				User32.ReleaseDC(IntPtr.Zero, hDC);
				Gdi32.DeleteObject(hBitmap);
				Gdi32.DeleteDC(memoryDC);
			}
		}