X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/888dde65f43d5f57e8fb2028b27191cca1741403..fcdd53359135f790b85728c4254b97095a56dad8:/src/msw/dcprint.cpp diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 628e6e81b2..8a0b13d38f 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -228,7 +228,7 @@ void wxPrinterDCImpl::EndPage() } -wxRect wxPrinterDCImpl::GetPaperRect() +wxRect wxPrinterDCImpl::GetPaperRect() const { if (!IsOk()) return wxRect(0, 0, 0, 0); @@ -327,17 +327,21 @@ WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) } - HGLOBAL hDevMode = (HGLOBAL)(DWORD) data->GetDevMode(); + GlobalPtrLock lockDevMode; + const HGLOBAL devMode = data->GetDevMode(); + if ( devMode ) + lockDevMode.Init(devMode); - DEVMODE *lpDevMode = hDevMode ? (DEVMODE *)::GlobalLock(hDevMode) : NULL; - - HDC hDC = ::CreateDC(NULL, deviceName.wx_str(), NULL, lpDevMode); + HDC hDC = ::CreateDC + ( + NULL, // no driver name as we use device name + deviceName.wx_str(), + NULL, // unused + static_cast(lockDevMode.Get()) + ); if ( !hDC ) wxLogLastError(_T("CreateDC(printer)")); - if ( lpDevMode ) - ::GlobalUnlock(hDevMode); - return (WXHDC) hDC; #endif // PostScript/Windows printing }