Esempio n. 1
0
        static void InternalSetStyleFlag(Window window, Win32.WindowStyles button, bool value)
        {
            var  hwnd  = new WindowInteropHelper(window).Handle;
            uint style = Win32.GetWindowLong(hwnd, Win32.GWL_STYLE);

            if (value)
            {
                style |= (uint)button;
            }
            else
            {
                style &= ~(uint)button;
            }

            Win32.SetWindowLong(hwnd, Win32.GWL_STYLE, style);
        }
Esempio n. 2
0
        static void HasTitleBarButtonChangedCallback(DependencyObject obj,
                                                     DependencyPropertyChangedEventArgs e, Win32.WindowStyles button)
        {
            var window = obj as Window;

            if (window == null)
            {
                return;
            }

            if (!window.IsLoaded)
            {
                window.Loaded += s_loadedHandler;
            }
            else
            {
                InternalSetStyleFlag(window, button, (bool)e.NewValue);
            }
        }
Esempio n. 3
0
        private bool EnumWindowsCallback(IntPtr hwnd, int lParam)
        {
            string title = Win32.GetWindowText(hwnd);

            if (Win32.IsWindowVisible(hwnd) == false)
            {
                return(true);
            }

            IntPtr parentHwnd = Win32.GetAncestor(hwnd, Win32.GA.ROOTOWNER);

            if (hwnd != parentHwnd)
            {
                return(true);
            }

            IntPtr stylePtr = Win32.GetWindowLongPtr(hwnd, Win32.GWL.STYLE);

            Win32.WindowStyles style = (Win32.WindowStyles)(stylePtr.ToInt64() & 0xFFFFFFFF);

            IntPtr exStylePtr = Win32.GetWindowLongPtr(hwnd, Win32.GWL.EXSTYLE);

            Win32.WindowExStyles exStyle = (Win32.WindowExStyles)(exStylePtr.ToInt64() & 0xFFFFFFFF);

            if ((exStyle & Win32.WindowExStyles.WS_EX_TOOLWINDOW) != 0)
            {
                return(true);
            }
            if ((exStyle & Win32.WindowExStyles.WS_EX_APPWINDOW) == 0)
            {
                int test = ((int)style & 0xFFFF);
                if (test > 0)
                {
                    // Have no idea what these first 16 bits of the style flag are. They've not
                    // documented, but Reaper and Spy++ use them and they stay visible in the
                    // taskbar, so if these are set I'll assume we show the app.
                }
                else if ((style & Win32.WindowStyles.WS_MINIMIZE) != 0)
                {
                    //return true;
                }
            }

            uint pid;

            Win32.GetWindowThreadProcessId(hwnd, out pid);
            if (pid == _currentPID)
            {
                return(true);
            }

            if (_oldWindows.Contains(hwnd))
            {
                _oldWindows.Remove(hwnd);

                var window = _windows.Find(w => w.Hwnd == hwnd);
                if (window != null)
                {
                    int index = _windows.IndexOf(window);
                    if (index == _position)
                    {
                        _position++;
                    }
                    else if (index > _position)
                    {
                        _windows.RemoveAt(index);
                        _windows.Insert(_position, window);
                        _position++;
                    }
                }
            }
            else
            {
                _windows.Add(new Window(hwnd));
            }
            return(true);
        }