AdvancedLauncher.Tools.Interop.RedirectedHwndSourceHost.BuildWindowCore C# (CSharp) Method

BuildWindowCore() protected final method

protected final BuildWindowCore ( HWND hwndParent ) : HWND
hwndParent AdvancedLauncher.Tools.Win32.User32.HWND
return AdvancedLauncher.Tools.Win32.User32.HWND
        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);
        }