protected override sealed void DestroyWindowOverride(HWND hwnd)
        {
            Debug.Assert(hwnd.DangerousGetHandle() == _hwndSource.Handle);

            _hwndSource.Dispose();
            _hwndSource = null;
        }
        protected override sealed HWND BuildWindowCore(HWND hwndParent)
        {
            HwndSourceParameters hwndSourceParameters = new HwndSourceParameters();
            hwndSourceParameters.WindowStyle = (int)(WS.VISIBLE | WS.CHILD | WS.CLIPSIBLINGS | WS.CLIPCHILDREN);
            //hwndSourceParameters.ExtendedWindowStyle = (int)(WS_EX.NOACTIVATE);
            hwndSourceParameters.ParentWindow = hwndParent.DangerousGetHandle();

            _hwndSource = new HwndSource(hwndSourceParameters);
            _hwndSource.SizeToContent = SizeToContent.Manual;

            // TODO: make this an option
            // On Vista, or when Win7 uses vista-blit, DX content is not
            // available via BitBlit or PrintWindow?  If WPF is using hardware
            // acceleration, anything it renders won't be available either.
            // One workaround is to force WPF to use software rendering.  Of
            // course, this is only a partial workaround since other content
            // like XNA or D2D won't work either.
            //_hwndSource.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;

            // Set the root visual of the HwndSource to an instance of
            // HwndSourceHostRoot.  Hook it up as a logical child if
            // we are on the same thread.
            HwndSourceHostRoot root = new HwndSourceHostRoot();
            _hwndSource.RootVisual = root;

            root.OnMeasure += OnRootMeasured;
            AddLogicalChild(_hwndSource.RootVisual);

            SetRootVisual(Child);

            return new HWND(_hwndSource.Handle);
        }
        protected override sealed HWND BuildWindowOverride(HWND hwndParent)
        {
            HwndSourceParameters hwndSourceParameters = new HwndSourceParameters();
            hwndSourceParameters.WindowStyle = (int)(WS.VISIBLE | WS.CHILD | WS.CLIPSIBLINGS | WS.CLIPCHILDREN);
            hwndSourceParameters.ParentWindow = hwndParent.DangerousGetHandle();

            _hwndSource = new HwndSource(hwndSourceParameters);
            _hwndSource.SizeToContent = SizeToContent.Manual;

            // Set the root visual of the HwndSource to an instance of
            // HwndSourceHostRoot.  Hook it up as a logical child if
            // we are on the same thread.
            HwndSourceHostRoot root = new HwndSourceHostRoot();
            _hwndSource.RootVisual = root;

            root.OnMeasure += OnRootMeasured;
            AddLogicalChild(_hwndSource.RootVisual);

            SetRootVisual(Child);

            return new HWND(_hwndSource.Handle);
        }
예제 #4
0
        protected override sealed HandleRef BuildWindowCore(HandleRef hwndParent)
        {
            HWND hwndParent2 = new HWND(hwndParent.Handle);
            _hwndChild = BuildWindowOverride(hwndParent2);

            // Ideally, the window would have been created with the expected
            // parent.  But just in case, we set it explicitly.
            NativeMethods.SetParent(_hwndChild, hwndParent2);

            return new HandleRef(this, _hwndChild.DangerousGetHandle());
        }