I'm working with the OEMUI sample in the latest DDK. In the printer
properties page, I am trying to replace the third tab (options) with a custom
tab of my own. I created and initialized a new DLGPAGE and I replaced the
Sheet.pDlgPage field from CPSUI_PDLGPAGE_TREEVIEWONLY to my custom page, but
the new page will not display in the print dialog. Any hints? Code below
for reference:
HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM
lParam,
IPrintOemDriverUI* pOEMHelp)
{
LONG_PTR lResult;
...
// Do action.
switch(pPSUIInfo->Reason)
{
case PROPSHEETUI_REASON_INIT:
{
DWORD dwSheets = 0;
PCBUSERDATA pUserData = NULL;
POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM)
pPSUIInfo->lParamInit;
HANDLE hHeap = pOEMUIParam->hOEMHeap;
POEMDEV pOEMDev = (POEMDEV)
pOEMUIParam->pOEMDM;
COMPROPSHEETUI Sheet;
DLGPAGE customPage;
LPTSTR tabName = L"CustomPage";
//define custom page
customPage.cbSize = sizeof(DLGPAGE);
customPage.pTabName = tabName;
customPage.IconID = 0;
customPage.DlgProc = NULL;
customPage.DlgTemplateID = DP_STD_TREEVIEWPAGE;
// Init property page.
memset(&Sheet, 0, sizeof(COMPROPSHEETUI));
Sheet.cbSize = sizeof(COMPROPSHEETUI);
Sheet.Flags = CPSUIF_UPDATE_PERMISSION;
Sheet.hInstCaller = ghInstance;
Sheet.pCallerName = GetStringResource(hHeap,
ghInstance, IDS_NAME);
Sheet.pHelpFile = NULL;
Sheet.pfnCallBack = OEMDocUICallBack2;
Sheet.pDlgPage =
customPage //CPSUI_PDLGPAGE_TREEVIEWONLY;
Sheet.cOptItem = 1;
Sheet.IconID = IDI_CPSUI_PRINTER;
Sheet.pOptItemName = GetStringResource(hHeap,
ghInstance, IDS_SECTION);
Sheet.CallerVersion = 0x100;
Sheet.OptItemVersion = 0x100;
// Init user data.
pUserData = (PCBUSERDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY,
sizeof(CBUSERDATA));
pUserData->hComPropSheet = pPSUIInfo->hComPropSheet;
pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet;
pUserData->pOEMUIParam = pOEMUIParam;
Sheet.UserData = (ULONG_PTR) pUserData;
// Create OptItems for page.
Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem);
// Initialize OptItems
Sheet.pOptItem[0].Level = 1;
Sheet.pOptItem[0].Flags = OPTIF_COLLAPSE;
Sheet.pOptItem[0].pName = GetStringResource(hHeap,
ghInstance, IDS_SECTION);
Sheet.pOptItem[0].Sel = pOEMDev->dwDriverData;
Sheet.pOptItem[0].pOptType = CreateOptType(hHeap, 2);
Sheet.pOptItem[0].pOptType->Type =
TVOT_UDARROW;
Sheet.pOptItem[0].pOptType->pOptParam[1].IconID = 50;
Sheet.pOptItem[0].pOptType->pOptParam[1].lParam = 100;
// Add property sheets.
lResult =
pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet,
CPSFUNC_ADD_PCOMPROPSHEETUI,
(LPARAM)&Sheet,
(LPARAM)&dwSheets);
}
break;