internal virtual void afterAppBarPos(bool isSameCoords, NativeMethods.Rect rect) { // apparently the taskbars like to pop up when app bars change if (Settings.Instance.EnableTaskbar && !Startup.IsShuttingDown) { AppBarHelper.SetWinTaskbarState(AppBarHelper.WinTaskbarState.AutoHide); AppBarHelper.SetWinTaskbarVisibility((int)NativeMethods.SetWindowPosFlags.SWP_HIDEWINDOW); } if (!isSameCoords) { var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) }; timer.Start(); timer.Tick += (sender1, args) => { // set position again, since WPF may have overridden the original change from AppBarHelper setAppBarPosition(rect); if (Screen.Primary && WindowManager.Instance.DesktopWindow != null) { WindowManager.Instance.DesktopWindow.ResetPosition(); } timer.Stop(); }; } }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == appbarMessageId && appbarMessageId != -1) { switch ((NativeMethods.AppBarNotifications)wParam.ToInt32()) { case NativeMethods.AppBarNotifications.PosChanged: AppBarHelper.ABSetPos(this, ActualWidth * dpiScale, desiredHeight * dpiScale, appBarEdge); break; case NativeMethods.AppBarNotifications.WindowArrange: if ((int)lParam != 0) // before { Visibility = Visibility.Collapsed; } else // after { Visibility = Visibility.Visible; } break; case NativeMethods.AppBarNotifications.FullScreenApp: AppBarHelper.SetWinTaskbarVisibility((int)NativeMethods.SetWindowPosFlags.SWP_HIDEWINDOW); break; } handled = true; } else if (msg == (int)NativeMethods.WM.ACTIVATE && enableAppBar && !Shell.IsCairoRunningAsShell && !Startup.IsShuttingDown) { AppBarHelper.AppBarActivate(hwnd); } else if (msg == (int)NativeMethods.WM.WINDOWPOSCHANGING) { // Extract the WINDOWPOS structure corresponding to this message NativeMethods.WINDOWPOS wndPos = NativeMethods.WINDOWPOS.FromMessage(lParam); // Determine if the z-order is changing (absence of SWP_NOZORDER flag) // If we are intentionally trying to become topmost, make it so if (isRaising && (wndPos.flags & NativeMethods.SetWindowPosFlags.SWP_NOZORDER) == 0) { // Sometimes Windows thinks we shouldn't go topmost, so poke here to make it happen. wndPos.hwndInsertAfter = (IntPtr)NativeMethods.WindowZOrder.HWND_TOPMOST; wndPos.UpdateMessage(lParam); } } else if (msg == (int)NativeMethods.WM.WINDOWPOSCHANGED && enableAppBar && !Shell.IsCairoRunningAsShell && !Startup.IsShuttingDown) { AppBarHelper.AppBarWindowPosChanged(hwnd); } else if (msg == (int)NativeMethods.WM.DPICHANGED) { if (Screen.Primary) { Shell.DpiScale = (wParam.ToInt32() & 0xFFFF) / 96d; } dpiScale = (wParam.ToInt32() & 0xFFFF) / 96d; setScreenProperties(ScreenSetupReason.DpiChange); } else if (msg == (int)NativeMethods.WM.DISPLAYCHANGE) { setScreenProperties(ScreenSetupReason.DisplayChange); handled = true; } else if (msg == (int)NativeMethods.WM.DEVICECHANGE && (int)wParam == 0x0007) { setScreenProperties(ScreenSetupReason.DeviceChange); handled = true; } // call custom implementations' window procedure return(customWndProc(hwnd, msg, wParam, lParam, ref handled)); }