using System; using System.ComponentModel; using System.Linq; using System.Runtime.InteropServices; using SharpShell.Interop; using SharpShell.SharpPropertySheet; namespace SharpShell.Diagnostics { public static class SharpPropertyPageTester { public static void Test(SharpPropertySheet.SharpPropertySheet sheet) { // Create the bridge. var bridge = new NativeBridge.NativeBridge(); bridge.Initialise(); // Create a property page proxy for this page. var proxy = new PropertyPageProxy(sheet, sheet.Pages.First()); // Using the proxy, create the property page handle. proxy.CreatePropertyPageHandle(bridge); var propertyPageHandle = proxy.HostWindowHandle; var psh = new PROPSHEETHEADER(); psh.dwSize = Marshal.SizeOf(psh); psh.dwSize = 96;// (uint)Marshal.SizeOf(psh); //psh.dwFlags psh.hwndParent = IntPtr.Zero; psh.hInstance = bridge.GetInstanceHandle(); psh.hIcon = IntPtr.Zero; psh.pszCaption = "Property Sheet"; psh.nPages = 1; var pages = new []{ propertyPageHandle}; int nParts = pages.Length; IntPtr pointer = Marshal.AllocHGlobal(nParts * Marshal.SizeOf(typeof(IntPtr))); for (int i = 0; i < nParts; i++) { Marshal.WriteIntPtr(pointer, i * Marshal.SizeOf(typeof(IntPtr)), pages[i]); } psh.phpage = pointer; psh.nStartPage = (IntPtr)0; try { var result = Comctl32.PropertySheet(ref psh); } catch (Exception) { var excep = new Win32Exception(Marshal.GetLastWin32Error()); throw; } // Release the bridge. bridge.Deinitialise(); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)