X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/888dde65f43d5f57e8fb2028b27191cca1741403..fe6f7f3c78174df4818c9e4f12c377b9f0cc323c:/src/msw/dcprint.cpp?ds=sidebyside diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 628e6e81b2..7eac01116f 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -327,17 +327,21 @@ WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) } - 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 }