private static IntPtr HwndSource_MessageHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case 7: { HwndSource hwndSource = HwndSource.FromHwnd(hwnd); FocusHelper.ClearRestoreFocusWindowIf(hwndSource, (IntPtr currentValue) => !HwndSourceTracker.IsValidRestoreFocusWindowForSource(hwndSource, currentValue)); break; } case 8: { if (!HwndSourceTracker.IsNonChildDescendant(wParam, hwnd)) { break; } Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback((object oFocusedKeyboardElement) => { FocusHelper.SetRestoreFocusFields(HwndSource.FromHwnd(hwnd), oFocusedKeyboardElement, IntPtr.Zero); return(null); }), Keyboard.FocusedElement); break; } } return(IntPtr.Zero); }
private void StartHwndSourceTracking() { this.StopHwndSourceTracking(); if (this._hwndSource != null) { this._hwndSourceTracker = HwndSourceTracker.AddSource(this._hwndSource); } }
protected override void DisposeManagedResources() { HwndSourceTracker.RemoveSource(this.Source); }
// <HwndSource_MessageHook>b__1 public bool u003cHwndSource_MessageHooku003eb__1(IntPtr currentValue) { return(!HwndSourceTracker.IsValidRestoreFocusWindowForSource(this.source, currentValue)); }