Пример #1
0
		private void UpdateLayeredWindow(Point point, Size size, byte alpha)
		{
			Bitmap bitmap1 = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb);
			using (Graphics graphics1 = Graphics.FromImage(bitmap1))
			{
				Rectangle rectangle1;
				SIZE size1;
				POINT point1;
				POINT point2;
				BLENDFUNCTION blendfunction1;
				rectangle1 = new Rectangle(0, 0, size.Width, size.Height);
				this.OnPaint(new PaintEventArgs(graphics1, rectangle1));
				IntPtr ptr1 = User32.GetDC(IntPtr.Zero);
				IntPtr ptr2 = Gdi32.CreateCompatibleDC(ptr1);
				IntPtr ptr3 = bitmap1.GetHbitmap(Color.FromArgb(0));
				IntPtr ptr4 = Gdi32.SelectObject(ptr2, ptr3);
				size1.cx = size.Width;
				size1.cy = size.Height;
				point1.x = point.X;
				point1.y = point.Y;
				point2.x = 0;
				point2.y = 0;
				blendfunction1 = new BLENDFUNCTION();
				blendfunction1.BlendOp = 0;
				blendfunction1.BlendFlags = 0;
				blendfunction1.SourceConstantAlpha = alpha;
				blendfunction1.AlphaFormat = 1;
				User32.UpdateLayeredWindow(base.Handle, ptr1, ref point1, ref size1, ptr2, ref point2, 0, ref blendfunction1, 2);
				Gdi32.SelectObject(ptr2, ptr4);
				User32.ReleaseDC(IntPtr.Zero, ptr1);
				Gdi32.DeleteObject(ptr3);
				Gdi32.DeleteDC(ptr2);
			}
		}
Пример #2
0
		internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);