Ejemplo n.º 1
0
 private static extern bool UpdateLayeredWindow(
     IntPtr hwnd,
     IntPtr hdcDst,
     ref BstCursor.Pointer.Win32Point pptDst,
     ref BstCursor.Pointer.Win32Size psize,
     IntPtr hdcSrc,
     ref BstCursor.Pointer.Win32Point pprSrc,
     int crKey,
     ref BstCursor.Pointer.BLENDFUNCTION pblend,
     int dwFlags);
Ejemplo n.º 2
0
            public void Update(int x, int y)
            {
                IntPtr dc           = BstCursor.Pointer.GetDC(IntPtr.Zero);
                IntPtr compatibleDc = BstCursor.Pointer.CreateCompatibleDC(dc);
                IntPtr hObject1     = IntPtr.Zero;
                IntPtr hObject2     = IntPtr.Zero;

                try
                {
                    hObject1 = this.mBitmap.GetHbitmap(Color.FromArgb(0));
                    hObject2 = BstCursor.Pointer.SelectObject(compatibleDc, hObject1);
                    BstCursor.Pointer.Win32Size     psize  = new BstCursor.Pointer.Win32Size(this.mBitmap.Width, this.mBitmap.Height);
                    BstCursor.Pointer.Win32Point    pprSrc = new BstCursor.Pointer.Win32Point(0, 0);
                    BstCursor.Pointer.Win32Point    pptDst = new BstCursor.Pointer.Win32Point(x, y);
                    BstCursor.Pointer.BLENDFUNCTION pblend = new BstCursor.Pointer.BLENDFUNCTION()
                    {
                        BlendOp             = 0,
                        BlendFlags          = 0,
                        SourceConstantAlpha = byte.MaxValue,
                        AlphaFormat         = 1
                    };
                    if (BstCursor.Pointer.UpdateLayeredWindow(this.Handle, dc, ref pptDst, ref psize, compatibleDc, ref pprSrc, 0, ref pblend, 2))
                    {
                        return;
                    }
                    CommonError.ThrowLastWin32Error("Cannot update layered window");
                }
                finally
                {
                    BstCursor.Pointer.ReleaseDC(IntPtr.Zero, dc);
                    if (hObject1 != IntPtr.Zero)
                    {
                        BstCursor.Pointer.SelectObject(compatibleDc, hObject2);
                        BstCursor.Pointer.DeleteObject(hObject1);
                    }
                    BstCursor.Pointer.DeleteDC(compatibleDc);
                }
            }