/// <summary> /// The CallbackProc. Called by the shell to inform of key property page events. /// </summary> /// <param name="hWnd">The h WND.</param> /// <param name="uMsg">The u MSG.</param> /// <param name="ppsp">The PPSP.</param> /// <returns></returns> private uint CallbackProc(IntPtr hWnd, PSPCB uMsg, ref PROPSHEETPAGE ppsp) { switch (uMsg) { case PSPCB.PSPCB_ADDREF: // Increment the reference count. referenceCount++; break; case PSPCB.PSPCB_RELEASE: // Decrement the reference count. referenceCount--; // If we're down to zero references, cleanup. if (referenceCount == 0) Cleanup(); break; case PSPCB.PSPCB_CREATE: // Allow the sheet to be created. return 1; } return 0; }
/// <summary> /// The CallbackProc. Called by the shell to inform of key property page events. /// </summary> /// <param name="hWnd">The h WND.</param> /// <param name="uMsg">The u MSG.</param> /// <param name="ppsp">The PPSP.</param> /// <returns></returns> private uint CallbackProc(IntPtr hWnd, PSPCB uMsg, ref PROPSHEETPAGE ppsp) { switch (uMsg) { case PSPCB.PSPCB_ADDREF: break; case PSPCB.PSPCB_RELEASE: break; case PSPCB.PSPCB_CREATE: // Allow the sheet to be created. return 1; } return 0; }
/// <summary> /// Creates the property page handle. /// </summary> public void CreatePropertyPageHandle(NativeBridge.NativeBridge nativeBridge) { Logging.DebugLog("Creating property page handle via bridge."); // Create a prop sheet page structure. var psp = new PROPSHEETPAGE(); // Set the key properties. psp.dwSize = (uint)Marshal.SizeOf(psp); psp.hInstance = nativeBridge.GetInstanceHandle(); psp.dwFlags = PSP.PSP_DEFAULT | PSP.PSP_USETITLE | PSP.PSP_USECALLBACK; psp.pTemplate = nativeBridge.GetProxyHostTemplate(); psp.pfnDlgProc = dialogProc; psp.pcRefParent = 0; psp.pfnCallback = callbackProc; psp.lParam = IntPtr.Zero; // If we have a title, set it. if (!string.IsNullOrEmpty(Target.PageTitle)) { psp.dwFlags |= PSP.PSP_USETITLE; psp.pszTitle = Target.PageTitle; } // If we have an icon, set it. if (Target.PageIcon != null && Target.PageIcon.Handle != IntPtr.Zero) { psp.dwFlags |= PSP.PSP_USEHICON; psp.hIcon = Target.PageIcon.Handle; } // Create a the property sheet page. HostWindowHandle = Comctl32.CreatePropertySheetPage(ref psp); }
public static extern IntPtr CreatePropertySheetPage(ref PROPSHEETPAGE psp);