]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/printdlg.cpp
Enable variadic macros for VC9 and later.
[wxWidgets.git] / src / msw / printdlg.cpp
index fac6fdf7438aaffba63abb11dab564ddc7b59720..857be199c416204a6fa11c93c43cbdd3cb196302 100644 (file)
@@ -407,7 +407,7 @@ void wxWindowsPrintNativeData::InitializeDevMode(const wxString& printerName, Wi
             // Step 1:
             // Allocate a buffer of the correct size.
             dwNeeded = DocumentProperties( NULL,
-                printer,         // Handle to our printer.
+                *printer,        // Handle to our printer.
                 szPrinterName,   // Name of the printer.
                 NULL,            // Asking for size, so
                 NULL,            // these are not used.
@@ -418,7 +418,7 @@ void wxWindowsPrintNativeData::InitializeDevMode(const wxString& printerName, Wi
             // Step 2:
             // Get the default DevMode for the printer
             dwRet = DocumentProperties( NULL,
-                printer,
+                *printer,
                 szPrinterName,
                 tempDevMode,     // The address of the buffer to fill.
                 NULL,            // Not using the input buffer.
@@ -990,38 +990,34 @@ bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data )
         return false;
 
     pd = new PAGESETUPDLG;
-    pd->hDevMode = NULL;
-    pd->hDevNames = NULL;
     m_pageDlg = (void *)pd;
 
-    // Pass the devmode data (created in m_printData.ConvertToNative)
-    // to the PRINTDLG structure, since it'll
-    // be needed when PrintDlg is called.
-
-    if (pd->hDevMode)
+    // We must not set hDevMode and hDevNames when using PSD_RETURNDEFAULT,
+    // otherwise the call to PageSetupDlg() would fail.
+    if ( data.GetDefaultInfo() )
     {
-        GlobalFree(pd->hDevMode);
         pd->hDevMode = NULL;
+        pd->hDevNames = NULL;
     }
-    pd->hDevMode = (HGLOBAL) native_data->GetDevMode();
-    native_data->SetDevMode(NULL);
+    else
+    {
+        // Pass the devmode data (created in m_printData.ConvertToNative)
+        // to the PRINTDLG structure, since it'll
+        // be needed when PrintDlg is called.
 
-    // Shouldn't assert; we should be able to test Ok-ness at a higher level
-    //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
+        pd->hDevMode = (HGLOBAL) native_data->GetDevMode();
+        native_data->SetDevMode(NULL);
 
-    // Pass the devnames data (created in m_printData.ConvertToNative)
-    // to the PRINTDLG structure, since it'll
-    // be needed when PrintDlg is called.
+        // Shouldn't assert; we should be able to test Ok-ness at a higher level
+        //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
 
-    if (pd->hDevNames)
-    {
-        GlobalFree(pd->hDevNames);
-        pd->hDevNames = NULL;
-    }
-    pd->hDevNames = (HGLOBAL) native_data->GetDevNames();
-    native_data->SetDevNames(NULL);
+        // Pass the devnames data (created in m_printData.ConvertToNative)
+        // to the PRINTDLG structure, since it'll
+        // be needed when PrintDlg is called.
 
-//        pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
+        pd->hDevNames = (HGLOBAL) native_data->GetDevNames();
+        native_data->SetDevNames(NULL);
+    }
 
     pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
 
@@ -1066,17 +1062,6 @@ bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data )
     pd->hPageSetupTemplate = NULL;
     pd->lpPageSetupTemplateName = NULL;
 
-/*
-    if ( pd->hDevMode )
-    {
-        DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
-        memset(devMode, 0, sizeof(DEVMODE));
-        devMode->dmSize = sizeof(DEVMODE);
-        devMode->dmOrientation = m_orientation;
-        devMode->dmFields = DM_ORIENTATION;
-        GlobalUnlock(pd->hDevMode);
-    }
-*/
     return true;
 }