public static GetWorkArea ( |
||
window | ||
screen | int | |
edge | DockEdge | |
windowWA | ||
appbarWA | ||
return | void |
private IntPtr AppBarHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == _callbackID) { switch (wParam.ToInt32()) { case APPBARNOTIFY.ABN_POSCHANGED: if (_cancelReposition != null) { _cancelReposition.Cancel(); } _cancelReposition = new CancellationTokenSource(); Task.Delay(TimeSpan.FromMilliseconds(100), _cancelReposition.Token).ContinueWith(_ => { if (_.IsCanceled) { return; } Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { int _screen; DockEdge _edge; WorkArea _windowWA; WorkArea _appbarWA; Monitor.GetWorkArea(this, out _screen, out _edge, out _windowWA, out _appbarWA); SetAppBar(_screen, _edge, _windowWA, _appbarWA, null); })); _cancelReposition = null; }); break; case APPBARNOTIFY.ABN_FULLSCREENAPP: if (lParam.ToInt32() == 1) { _wasTopMost = IsTopMost; if (IsTopMost) { SetBottom(false); } } else if (_wasTopMost) { SetTopMost(false); } break; } handled = true; } return(IntPtr.Zero); }
private async Task BindAppBar() { Monitor.GetWorkArea(this, out int screen, out DockEdge edge, out WorkArea initPos, out WorkArea windowWA, out WorkArea appbarWA); Move(initPos); APPBARDATA _data = NewData(); _callbackID = _data.uCallbackMessage = NativeMethods.RegisterWindowMessage("AppBarMessage"); NativeMethods.SHAppBarMessage(APPBARMSG.ABM_NEW, ref _data); Screen = screen; DockEdge = edge; _data.uEdge = (int)edge; _data.rc = new RECT() { Left = (int)Math.Round(appbarWA.Left), Top = (int)Math.Round(appbarWA.Top), Right = (int)Math.Round(appbarWA.Right), Bottom = (int)Math.Round(appbarWA.Bottom) }; NativeMethods.SHAppBarMessage(APPBARMSG.ABM_QUERYPOS, ref _data); NativeMethods.SHAppBarMessage(APPBARMSG.ABM_SETPOS, ref _data); IsAppBar = true; appbarWA.Left = _data.rc.Left; appbarWA.Top = _data.rc.Top; appbarWA.Right = _data.rc.Right; appbarWA.Bottom = _data.rc.Bottom; AppBarWidth = appbarWA.Width; await Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() => { Move(windowWA); })); await Task.Delay(500).ContinueWith(async(_) => { await Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() => { HwndSource.AddHook(AppBarHook); })); }); }
public virtual void AppBarShow() { if (Framework.Settings.Instance.UseAppBar) { int _screen; DockEdge _edge; WorkArea _windowWA; WorkArea _appbarWA; Monitor.GetWorkArea(this, out _screen, out _edge, out _windowWA, out _appbarWA); SetAppBar(_screen, _edge, _windowWA, _appbarWA, null); } Show(); }
public void AppBarShow() { if (Properties.Settings.Default.UseAppBar) { int _screen; DockEdge _edge; WorkArea _windowWA; WorkArea _appbarWA; Monitor.GetWorkArea(this, out _screen, out _edge, out _windowWA, out _appbarWA); SetAppBar(_screen, _edge, _windowWA, _appbarWA); } Show(); Activate(); }