I have been implementing a printer interface DLL which uses normal Win32
dialog based property pagesinstead of CPSUI based property pages and noticed
following issues.
1. The PROPSHEETUI_REASON_SET_RESULT is never called in case of Win32
dialog based property pages. I am not sure whether there is any way to make
this get called.
2. If I open from control panel -> printer properties, the settings
changes are not saved in the DEVMODE due to problem 1. I have to explictly
save the settings using GetPrinter() functions. I believe this also is
related to (1)
What are the additional things to be done when non-CPSUI based printer
property pages are used?
Thanks.
> 1. The PROPSHEETUI_REASON_SET_RESULT is never called in case of Win32
>dialog based property pages. I am not sure whether there is any way to make
>this get called.
Your dialog proc should do this:
static PPSPINFO pPSPInfo;
switch (msg)
{
case WM_INITDIALOG:
pPSPInfo = PPSPINFO_FROM_WM_INITDIALOG_LPARAM(lParam);
return TRUE;
case WM_NOTIFY:
{
switch (pnmhdr->code)
{
case PSN_APPLY:
// OK or Apply button has been pressed
pPSPInfo->pfnComPropSheet(pPSPInfo->hComPropSheet,
CPSFUNC_SET_RESULT,
(LPARAM)hSheet,
CPSUI_OK);
return TRUE;
default:
break;
}
}
break;
Thanks for the reply. I already tried in this manner and it worked for
same cases while not for some other:
i. In the WM_INITDIALOG, the pfnComPropSheet pointer was NULL (am I doing
anything wrong here?!.) in the PPSPINFO structure. So, instead I cached the
one I got in DrvDocumentPropertySheets(). I am not sure how safe this is.
ii. When I used this pfnComPropSheet() function in the PSN_APPLY, I have
not used the hSheet for third param but instead used NULL since I was not
sure from where I can get the hSheet value.
The above two changes worked in following case:
If I try changing the settings from some applications, the changes I do
in property pages got reflected in the applications print dialog and vice
versa. This was fine
The above two changes were not working in following case:
In Control Panel, printer preferences, If I change any printer settings
like orientation, paper size etc and click apply button, the settings are not
getting saved. I have to resort to using SetPrinter() in
PROPSHEETUI_REASON_DESTROY to save the settings explicitly which will not be
desirable since this may unnecessarily save the settings when the property
pages are launched from any application.