Property Sheet Handler Interfaces

Property sheet handlers are initialized through the IShellExtInit interface and use the IShellPropSheetExt interface. In addition to the IUnknown functions, the IShellPropSheetExt interface includes the AddPages and ReplacePage member functions.

AddPages

This member function adds pages to a property sheet. It is passed a pointer to a function that will add the property page and the lParam parameter that will be passed to the function. lParam is useful for passing application-specific data to the handler. The property sheet handler creates each added page by using the CreatePropSheetPage function and uses the handle that function returns in a call to lpfnAddPage. The following code adds a single property sheet page and provides a dialog procedure for the page:

STDMETHODIMP CPropExt::XPropExt::AddPages (
LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
{
METHOD_PROLOGUE (CPropExt, PropExt);
TRACE ("CPropExt::XPropExt::AddPages\n");

PROPSHEETPAGE psp;

psp.dwSize = sizeof (psp); // no extra data
psp.dwFlags = PSP_USEREFPARENT;
psp.hInstance = AfxGetResourceHandle ();
psp.pszTemplate = MAKEINTRESOURCE (IDD_TESTPAGE);
psp.pfnDlgProc = (DLGPROC) pThis->PropExtDlgProc;
psp.pcRefParent = (UINT *)& (pThis->m_cRefThisDll);

pThis->m_hPage = ::CreatePropertySheetPage (&psp);
if (pThis->m_hPage)
{
if (! lpfnAddPage (pThis->m_hPage, lParam))
::DestroyPropertySheetPage (pThis->m_hPage);
}
return NOERROR;
}

BOOL APIENTRY CPropExt::PropExtDlgProc (
HWND hDlg, UINT message, UINT wParam, LONG lParam)
{

switch (message)
{
case WM_NOTIFY:
switch (((NMHDR FAR *)lParam)->code)
{
case PSN_APPLY:
SetWindowLong (hDlg, DWL_MSGRESULT, TRUE);
break;

case PSN_KILLACTIVE:
SetWindowLong (hDlg, DWL_MSGRESULT, FALSE);
return 1;
break;

case PSN_RESET:
SetWindowLong (hDlg, DWL_MSGRESULT, FALSE);
break;
}
}
return FALSE;
}

ReplacePage

ReplacePage is called for Control Panel applications, allowing them to replace an existing property sheet page with their own page. Standard property sheet extensions do not need to implement this function and can simply return E_NOTIMPL.