I have a problem with a property page in the printer preferences.
I am setting a handle to my current printer in the creation of the property
page.
Page.lParam = (long)((OEMUIPSPARAM*)(pPSUIInfo->lParamInit))->hPrinter;

When I open this page I save this printer handle in
case WM_INITDIALOG:
// OpenPrinter
hPrinter = (HANDLE)((PROPSHEETPAGE *)lParam)->lParam;
VERBOSE(PRNTEXT("Printer handle [%x]\n"), hPrinter);
UserData.hPrinter = hPrinter;
PUserData1 = &UserData;
SetLastError(0);
if ((PUserData =
(CBMYUSERDATA*)SetWindowLong(hDlg,GWL_USERDATA,(DWORD)PUserData1)) == 0)
{
dwError = GetLastError();
}

Now when I get into the case case WM_NOTIFY:
it works to retrieve this printer handle and work with it, but when I press
a button on the dialog it goes into case WM_COMMAND:
and my handle is false!

What am I doing wrong here? I need the access to the printer handle to use
GetPrinterData and SetPrinterData.

Any help appreciated.

Thanks,
--
\Manfred

RE: Property sheets in Printer Preferences by mwilner

mwilner
Mon Jun 04 15:23:01 CDT 2007

I figured that one out.
For some reason the structure is not retrieved correctly with the handle
from GetWindowLong and therefore is not valid. When using just a handle to
hPrinter it works all the time.

--
\Manfred



"Manfred Wilner" wrote:

> I have a problem with a property page in the printer preferences.
> I am setting a handle to my current printer in the creation of the property
> page.
> Page.lParam = (long)((OEMUIPSPARAM*)(pPSUIInfo->lParamInit))->hPrinter;
>
> When I open this page I save this printer handle in
> case WM_INITDIALOG:
> // OpenPrinter
> hPrinter = (HANDLE)((PROPSHEETPAGE *)lParam)->lParam;
> VERBOSE(PRNTEXT("Printer handle [%x]\n"), hPrinter);
> UserData.hPrinter = hPrinter;
> PUserData1 = &UserData;
> SetLastError(0);
> if ((PUserData =
> (CBMYUSERDATA*)SetWindowLong(hDlg,GWL_USERDATA,(DWORD)PUserData1)) == 0)
> {
> dwError = GetLastError();
> }
>
> Now when I get into the case case WM_NOTIFY:
> it works to retrieve this printer handle and work with it, but when I press
> a button on the dialog it goes into case WM_COMMAND:
> and my handle is false!
>
> What am I doing wrong here? I need the access to the printer handle to use
> GetPrinterData and SetPrinterData.
>
> Any help appreciated.
>
> Thanks,
> --
> \Manfred
>