示例#1
0
        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);
        }
示例#2
0
 private void StartHwndSourceTracking()
 {
     this.StopHwndSourceTracking();
     if (this._hwndSource != null)
     {
         this._hwndSourceTracker = HwndSourceTracker.AddSource(this._hwndSource);
     }
 }
示例#3
0
 protected override void DisposeManagedResources()
 {
     HwndSourceTracker.RemoveSource(this.Source);
 }
示例#4
0
 // <HwndSource_MessageHook>b__1
 public bool u003cHwndSource_MessageHooku003eb__1(IntPtr currentValue)
 {
     return(!HwndSourceTracker.IsValidRestoreFocusWindowForSource(this.source, currentValue));
 }