+ lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
+ lpszDeviceName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset;
+ lpszPortName = (LPTSTR)lpDevNames + lpDevNames->wOutputOffset;
+
+ deviceName = lpszDeviceName;
+ portName = lpszPortName;
+
+ GlobalUnlock(pd.hDevNames);
+ GlobalFree(pd.hDevNames);
+ pd.hDevNames=NULL;
+ }
+
+ if (pd.hDevMode)
+ {
+ GlobalFree(pd.hDevMode);
+ pd.hDevMode=NULL;
+ }
+ return ( !deviceName.empty() );
+}
+
+#endif // !wxUSE_PS_PRINTING
+
+// Gets an HDC for the specified printer configuration
+WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst)
+{
+#if wxUSE_PS_PRINTING
+ // TODO
+ wxUnusedVar(printDataConst);
+ return 0;
+#else // native Windows printing
+ wxWindowsPrintNativeData *data =
+ (wxWindowsPrintNativeData *) printDataConst.GetNativeData();
+
+ data->TransferFrom( printDataConst );
+
+ wxString deviceName = printDataConst.GetPrinterName();
+ if ( deviceName.empty() )
+ {
+ // Retrieve the default device name
+ wxString portName;
+ if ( !wxGetDefaultDeviceName(deviceName, portName) )
+ {
+ return 0; // Could not get default device name
+ }
+ }
+
+
+ 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.t_str(),
+ NULL, // unused
+ static_cast<DEVMODE *>(lockDevMode.Get())
+ );
+ if ( !hDC )
+ {
+ wxLogLastError(wxT("CreateDC(printer)"));