}
- HGLOBAL hDevMode = (HGLOBAL)(DWORD) data->GetDevMode();
-
- DEVMODE *lpDevMode = hDevMode ? (DEVMODE *)::GlobalLock(hDevMode) : NULL;
-
- HDC hDC = ::CreateDC(NULL, deviceName.wx_str(), NULL, lpDevMode);
+ GlobalPtrLock lockDevMode;
+ const HGLOBAL devMode = data->GetDevMode();
+ if ( devMode )
+ lockDevMode.Init(devMode);
+
+ HDC hDC = ::CreateDC
+ (
+ NULL, // no driver name as we use device name
+ deviceName.wx_str(),
+ NULL, // unused
+ wx_static_cast(DEVMODE *, lockDevMode.Get())
+ );
if ( !hDC )
wxLogLastError(_T("CreateDC(printer)"));
- if ( lpDevMode )
- ::GlobalUnlock(hDevMode);
-
return (WXHDC) hDC;
#endif // PostScript/Windows printing
}