]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dcprint.cpp
Fixed non-precompiled headers compilation
[wxWidgets.git] / src / msw / dcprint.cpp
index 628e6e81b2217364fed0c46add04d756739c6603..7eac01116f3b85fef2dfc527d0a0bbaa15df18fe 100644 (file)
@@ -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
 }