示例#1
0
        private IntPtr InitializePresenterCoreWindowMode(HandleRef hwndParent)
        {
            CoreWindow coreWindow = CoreWindowInterop.CreateCoreWindow("XAMLONWIN32", 0, 0, 0, 0);

            ICoreApplicationPrivate2 coreApp = new ICoreApplicationPrivate2();

            coreApp.CreateNonImmersiveView();

            XamlPresenterStatics3 xamlPresenterStatics = new XamlPresenterStatics3();
            XamlPresenter         presenter            = xamlPresenterStatics.CreateFromCoreWindow(coreWindow);

            ICoreWindowInterop interop      = new ICoreWindowInterop(coreWindow);
            IntPtr             windowHandle = interop.GetWindowHandle();

            int style = Win32Interop.GetWindowStyle(windowHandle);

            style = style & (~WindowStyles.WS_POPUP);
            style = style | WindowStyles.WS_CHILD;
            Win32Interop.SetWindowStyle(windowHandle, style);
            Win32Interop.SetParent(windowHandle, hwndParent.Handle);

            presenter.InitializePresenter();

            return(windowHandle);
        }
示例#2
0
        private IntPtr InitializePresenterHwndMode(HandleRef hwndParent)
        {
            Win32Interop.RegisterWindowClass(WINDOW_CLASS_NAME, WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW);

            IntPtr windowHandle = Win32Interop.CreateWindow(
                WINDOW_CLASS_NAME,
                WindowStyles.WS_CHILD | WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPCHILDREN,
                0,
                0,
                0,
                0,
                hwndParent.Handle);

            XamlPresenterStatics xamlPresenterStatics = new XamlPresenterStatics();
            XamlPresenter        presenter            = xamlPresenterStatics.CreateFromHwnd((int)windowHandle);

            presenter.InitializePresenter();

            return(windowHandle);
        }