Пример #1
0
 Rectangle IDockDragSource.BeginDrag(Point ptMouse)
 {
     _mPreDragExStyle = NativeMethods.GetWindowLong(Handle, (int)Win32.GetWindowLongIndex.GWL_EXSTYLE);
     NativeMethods.SetWindowLong(Handle,
                                 (int)Win32.GetWindowLongIndex.GWL_EXSTYLE,
                                 _mPreDragExStyle | (int)(Win32.WindowExStyles.WS_EX_TRANSPARENT | Win32.WindowExStyles.WS_EX_LAYERED));
     return(Bounds);
 }
        public static void SetStyle(this Control ctrl, int style, bool on = true)
        {
            const int GWL_STYLE = -16;
            var       oldstyle  = NativeMethods.GetWindowLong(ctrl.Handle, GWL_STYLE).ToInt32();

            if ((oldstyle & style) != style && on)
            {
                NativeMethods.SetWindowLong(ctrl.Handle, GWL_STYLE, new IntPtr(oldstyle | style));
            }
            else if ((oldstyle & style) == style && !on)
            {
                NativeMethods.SetWindowLong(ctrl.Handle, GWL_STYLE, new IntPtr(oldstyle & ~style));
            }
            ctrl.Refresh();
        }
Пример #3
0
        public void CanPenetrate()
        {
            if (InvokeRequired)
            {
                Invoke(Ct);
            }
            else
            {
                TopMost = true;
                NativeMethods.GetWindowLong(Handle, GWL.GWL_EXSTYLE);
                NativeMethods.SetWindowLong(Handle, GWL.GWL_EXSTYLE, WS_EX.WS_EX_TRANSPARENT | WS_EX.WS_EX_LAYERED);
                //  NativeMethods.SetLayeredWindowAttributes(this.Handle, 0, 100, Win32.Consts.LWA.LWA_ALPHA);
            }
            // int intExTemp = NativeMethods.GetWindowLong(this.Handle, (int)Win32.Consts.GWL.GWL_EXSTYLE);

            // int oldGWLEx = NativeMethods.SetWindowLong(this.Handle, (int)Win32.Consts.GWL.GWL_EXSTYLE, (int)Win32.Consts.WS_EX.WS_EX_LAYERED | (int)Win32.Consts.WS_EX.WS_EX_TRANSPARENT);

            //实则是 封装 TransparencyKey
            // NativeMethods.SetLayeredWindowAttributes(this.Handle, 0x0000ffff, 255, Win32.Consts.LWA.LWA_COLORKEY);
        }
Пример #4
0
 private void CanPenetrate()
 {
     NativeMethods.GetWindowLong(Handle, -20);
     NativeMethods.SetWindowLong(Handle, -20, 0x80020);
 }