/// <summary> /// Adds the pages. /// </summary> /// <param name="pfnAddPage">The PFN add page.</param> /// <param name="lParam">The l param.</param> /// <returns> /// If successful, returns a one-based index to specify the page that should be initially displayed. See Remarks for more information. /// </returns> int IShellPropSheetExt.AddPages(IntPtr pfnAddPage, IntPtr lParam) { // DebugLog the event. Log("Adding Pages..."); // If we are not showing the sheet, we can end now. if (CanShowSheet() == false) { return(0); } // Create the bridge. var bridge = new NativeBridge.NativeBridge(); // Initialise it. if (bridge.Initialise() == false) { Logging.Error("Failed to initialise the NativeBridge.", null); return(0); } // Go through each page - that has a property page. foreach (var page in propertySheetPages.Value.Where(p => p.Handle != IntPtr.Zero)) { // Create a property page proxy for this page. var proxy = new PropertyPageProxy(this, page); // Using the proxy, create the property page handle. proxy.CreatePropertyPageHandle(bridge); var propertyPageHandle = proxy.HostWindowHandle; // Name the page, to aid with debugging. User32.SetWindowText(propertyPageHandle, "SharpShell Host for " + page.GetType().Name); // DebugLog the event. Log("Created Page Proxy, handle is " + propertyPageHandle.ToString("x8")); // Now that we have the page handle, add the page via the callback. // Note that if the call fails, we *don't* have to destroy the property // page handle, the bridge actually takes care of that for us. bridge.CallAddPropSheetPage(pfnAddPage, propertyPageHandle, lParam); } // Release the bridge. //bridge.Deinitialise(); // DebugLog the event. Log("Adding Pages (Done)"); // We've succeeded. return(WinError.S_OK); }
/// <summary> /// Adds the pages. /// </summary> /// <param name="pfnAddPage">The PFN add page.</param> /// <param name="lParam">The l param.</param> /// <returns> /// If successful, returns a one-based index to specify the page that should be initially displayed. See Remarks for more information. /// </returns> int IShellPropSheetExt.AddPages(IntPtr pfnAddPage, IntPtr lParam) { // DebugLog the event. Log("Adding Pages..."); // If we are not showing the sheet, we can end now. if (CanShowSheet() == false) return 0; // Create the bridge. var bridge = new NativeBridge.NativeBridge(); // Initialise it. if(bridge.Initialise() == false) { Logging.Error("Failed to initialise the NativeBridge.", null); return 0; } // Go through each page - that has a property page. foreach (var page in propertySheetPages.Value.Where(p => p.Handle != IntPtr.Zero)) { // Create a property page proxy for this page. var proxy = new PropertyPageProxy(this, page); // Using the proxy, create the property page handle. proxy.CreatePropertyPageHandle(bridge); var propertyPageHandle = proxy.HostWindowHandle; // Name the page, to aid with debugging. User32.SetWindowText(propertyPageHandle, "SharpShell Host for " + page.GetType().Name); // DebugLog the event. Log("Created Page Proxy, handle is " + propertyPageHandle.ToString("x8")); // Now that we have the page handle, add the page via the callback. bridge.CallAddPropSheetPage(pfnAddPage, propertyPageHandle, lParam); } // Release the bridge. //bridge.Deinitialise(); // DebugLog the event. Log("Adding Pages (Done)"); // We've succeeded. return WinError.S_OK; }
/// <summary> /// Sets the page data changed. /// </summary> /// <param name="changed">if set to <c>true</c> the data has changed and the property sheet should enable the 'Apply' button.</param> protected void SetPageDataChanged(bool changed) { // Pass on to the proxy. PropertyPageProxy.SetDataChanged(changed); }