Example #1
0
            private static void WindowShown(IntPtr hwnd)
            {
                if (!HwndHelper.HasStyleFlag(hwnd, NativeHelper.WS_VISIBLE))
                {
                    return;
                }

                var oldTcs = nextWindowShown;

                nextWindowShown = new TaskCompletionSource <int>();
                oldTcs.SetResult(0);
            }
Example #2
0
        protected static HwndSource GetSafeHwndSource(Object owner)
        {
            HwndSource source = null;

            if (owner is DependencyObject)
            {
                source = HwndSource.FromDependencyObject(owner as DependencyObject) as HwndSource;
            }
            else if (owner is Visual)
            {
                source = HwndSource.FromVisual(owner as Visual) as HwndSource;
            }
            else if (owner is IntPtr)
            {
                source = HwndSource.FromHwnd((IntPtr)owner) as HwndSource;
            }

            if (source != null)
            {
                return(source);
            }

            return(HwndSource.FromHwnd(HwndHelper.GetForegroundWindow()) as HwndSource);
        }