Exemplo n.º 1
0
        public static CoreWindow CreateCoreWindow(String windowTitle, int x, int y, int width, int height)
        {
            IntPtr pvObject;
            Guid   iid = Marshal.GenerateGuidForType(typeof(ICoreWindow));

            UInt32 hr = WindowsUI.CreateCoreWindow(
                6, /* NOT_IMMERSIVE */
                windowTitle,
                x, y, width, height,
                0,
                IntPtr.Zero,
                ref iid,
                out pvObject);

            if (0 != hr)
            {
                throw new Exception(String.Format("CreateCoreWindow failed with 0x{0:X}", hr));
            }

            IInspectable inspectable = new IInspectable(pvObject);

            CoreWindow coreWindow = (CoreWindow)Marshal.GetObjectForIUnknown(pvObject);

            inspectable.Dispose();

            return(coreWindow);
        }
Exemplo n.º 2
0
        private static IntPtr GetPtrFromCoreWindow(CoreWindow coreWindow)
        {
            IInspectable inspectable = new IInspectable(Marshal.GetIUnknownForObject(coreWindow));

            IntPtr ptr = inspectable.QueryInterface(new Guid("45D64A29-A63E-4CB6-B498-5781D298CB4F"));

            inspectable.Dispose();

            return(ptr);
        }
Exemplo n.º 3
0
        public XamlPresenter CreateFromCoreWindow(CoreWindow coreWindow)
        {
            IInspectable pCoreWindow = new IInspectable(Marshal.GetComInterfaceForObject <CoreWindow, ICoreWindow>(coreWindow));

            IntPtr xamlPresenter;
            UInt32 hr = XamlPresenterStatics3_CreateFromCoreWindow(_ptr, pCoreWindow.Value, out xamlPresenter);

            pCoreWindow.Dispose();

            if (0 != hr)
            {
                throw new Exception(String.Format("XamlPresenterStatics3::CreateFromCoreWindow({0x{0:X}}) failed with 0x{1:X}", pCoreWindow, hr));
            }

            return(new XamlPresenter(xamlPresenter));
        }
Exemplo n.º 4
0
        public CoreApplicationView CreateNonImmersiveView()
        {
            IntPtr view;
            UInt32 hr = ICoreApplicationPrivate2_CreateNonImmersiveView(_ptr, out view);

            if (0 != hr)
            {
                throw new Exception(String.Format("ICoreApplicationPrivate2::CreateNonImmersiveView() failed with 0x{0:X}", hr));
            }

            IInspectable inspectable = new IInspectable(view);

            CoreApplicationView coreApplicationView = (CoreApplicationView)Marshal.GetObjectForIUnknown(view);

            inspectable.Dispose();

            return(coreApplicationView);
        }