Ejemplo n.º 1
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            this.hwndSource = (HwndSource)PresentationSource.FromVisual(this);
            if (this.hwndSource == null)
            {
                return;
            }
            WS   windowLong   = this.hwndSource.Handle.GetWindowLong();
            WSEX windowLongEx = this.hwndSource.Handle.GetWindowLongEx();

            windowLongEx ^= WSEX.APPWINDOW;
            windowLongEx |= WSEX.NOACTIVATE;
            if (base.Owner.ResizeMode == System.Windows.ResizeMode.NoResize || base.Owner.ResizeMode == System.Windows.ResizeMode.CanMinimize)
            {
                windowLongEx |= WSEX.TRANSPARENT;
            }
            this.hwndSource.Handle.SetWindowLong(windowLong);
            this.hwndSource.Handle.SetWindowLongEx(windowLongEx);
            this.hwndSource.AddHook(new HwndSourceHook(this.WndProc));
            this.handle      = this.hwndSource.Handle;
            this.ownerHandle = (new WindowInteropHelper(base.Owner)).Handle;
            this.resizeModeChangeNotifier = new PropertyChangeNotifier(base.Owner, Window.ResizeModeProperty);
            this.resizeModeChangeNotifier.ValueChanged += new EventHandler(this.ResizeModeChanged);
        }
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            HwndSource source = (HwndSource)PresentationSource.FromVisual(this);
            WS         ws     = source.Handle.GetWindowLong();
            WSEX       wsex   = source.Handle.GetWindowLongEx();

            ws   |= WS.POPUP;
            wsex |= WSEX.NOACTIVATE;

            source.Handle.SetWindowLong(ws);
            source.Handle.SetWindowLongEx(wsex);
            source.AddHook(WndProc);
        }
Ejemplo n.º 3
0
        private bool windowFound(IntPtr hwnd, int lParam)
        {
            StringBuilder sb = new StringBuilder(100);

            User32.GetWindowText(hwnd, sb, sb.Capacity);
            string title = sb.ToString();

            // don't consider our own windows
            if (title == "ThumbWindows")
            {
                return(true);
            }

            WS   winStyle   = (WS)User32.GetWindowLongA(hwnd, User32.GWL_STYLE);
            WSEX winStyleEx = (WSEX)User32.GetWindowLongA(hwnd, User32.GWL_EXSTYLE);

            RECT sourceRect = new RECT();


            User32.GetWindowRect(hwnd, ref sourceRect);

            WinSbS win = new WinSbS(hwnd);

            win.SourceRect = sourceRect;
            win.Title      = title;
            win.WinStyle   = winStyle;
            win.WinStyleEx = winStyleEx;

            int cloaked = 0;

            DwmApi.DwmGetWindowAttribute(hwnd, DwmApi.DwmWindowAttribute.DWMWA_CLOAKED, out cloaked, sizeof(int));

            if (cloaked == 0 &&
                !sourceRect.IsEmpty() &&
                (winStyle & WS.WS_VISIBLE) == WS.WS_VISIBLE &&
                (winStyle & WS.WS_ICONIC) == 0 &&
                (winStyle & WS.WS_DISABLED) == 0)
            {
                this.windowsToDisplay.Add(win);
            }
            else
            {
                this.windowsRejected.Add(win);
            }

            return(true); //continue enumeration
        }
Ejemplo n.º 4
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            //HwndSource.FromHwnd((new WindowInteropHelper(this)).Handle).AddHook(new HwndSourceHook(WndProc));

            HwndSource source = (HwndSource)PresentationSource.FromVisual(this);
            WS         ws     = source.Handle.GetWindowLong();
            WSEX       wsex   = source.Handle.GetWindowLongEx();

            ws |= WS.POPUP;
            //wsex ^= WSEX.APPWINDOW;
            wsex |= WSEX.NOACTIVATE;

            source.Handle.SetWindowLong(ws);
            source.Handle.SetWindowLongEx(wsex);
            source.AddHook(WndProc);
        }
Ejemplo n.º 5
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            var  source = (HwndSource)PresentationSource.FromVisual(this);
            WS   ws     = source.Handle.GetWindowLong();
            WSEX wsex   = source.Handle.GetWindowLongEx();

            //ws |= WS.POPUP;
            wsex ^= WSEX.APPWINDOW;
            wsex |= WSEX.NOACTIVATE;
            wsex |= WSEX.TRANSPARENT;

            source.Handle.SetWindowLong(ws);
            source.Handle.SetWindowLongEx(wsex);
            source.AddHook(WndProc);

            handle = source.Handle;
        }
Ejemplo n.º 6
0
        private void ResizeModeChanged(object sender, EventArgs e)
        {
            WSEX wSEX;
            WSEX windowLongEx = this.hwndSource.Handle.GetWindowLongEx();

            if (base.Owner.ResizeMode != System.Windows.ResizeMode.NoResize)
            {
                if (base.Owner.ResizeMode == System.Windows.ResizeMode.CanMinimize)
                {
                    windowLongEx |= WSEX.TRANSPARENT;
                    wSEX          = this.hwndSource.Handle.SetWindowLongEx(windowLongEx);
                    return;
                }
                windowLongEx ^= WSEX.TRANSPARENT;
                wSEX          = this.hwndSource.Handle.SetWindowLongEx(windowLongEx);
                return;
            }
            windowLongEx |= WSEX.TRANSPARENT;
            wSEX          = this.hwndSource.Handle.SetWindowLongEx(windowLongEx);
        }
Ejemplo n.º 7
0
 public static WSEX SetWindowLongEx(this IntPtr hWnd, WSEX dwNewLong)
 {
     return((WSEX)SetWindowLong(hWnd, (int)GWL.EXSTYLE, (int)dwNewLong));
 }
Ejemplo n.º 8
0
 public static WSEX SetWindowLongEx(this IntPtr hWnd, WSEX dwNewLong)
 {
     return (WSEX) SetWindowLong(hWnd, (int) GWL.EXSTYLE, (int) dwNewLong);
 }
Ejemplo n.º 9
0
 public static WSEX SetWindowLongEx(this IntPtr hWnd, WSEX dwNewLong)
 {
     return((WSEX)MahApps.Metro.Models.Win32.NativeMethods.SetWindowLong(hWnd, -20, (int)dwNewLong));
 }