]> git.saurik.com Git - wxWidgets.git/blob - src/msw/printdlg.cpp
Better alphabetized the event handler macros
[wxWidgets.git] / src / msw / printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ===========================================================================
13 // declarations
14 // ===========================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "printdlg.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 // Don't use the Windows print dialog if we're in wxUniv mode and using
32 // the PostScript architecture
33 #if wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXUNIVERSAL__) || !wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
34
35 #ifndef WX_PRECOMP
36 #include "wx/app.h"
37 #endif
38
39 #include "wx/cmndata.h"
40 #include "wx/printdlg.h"
41 #include "wx/dcprint.h"
42 #include "wx/paper.h"
43
44 #include <stdlib.h>
45
46 #include "wx/msw/private.h"
47
48 #include <commdlg.h>
49
50 #ifndef __WIN32__
51 #include <print.h>
52 #endif
53
54 //----------------------------------------------------------------------------
55 // wxWindowsPrintNativeData
56 //----------------------------------------------------------------------------
57
58 #ifdef __WXDEBUG__
59 static wxString wxGetPrintDlgError()
60 {
61 DWORD err = CommDlgExtendedError();
62 wxString msg = wxT("Unknown");
63 switch (err)
64 {
65 case CDERR_FINDRESFAILURE: msg = wxT("CDERR_FINDRESFAILURE"); break;
66 case CDERR_INITIALIZATION: msg = wxT("CDERR_INITIALIZATION"); break;
67 case CDERR_LOADRESFAILURE: msg = wxT("CDERR_LOADRESFAILURE"); break;
68 case CDERR_LOADSTRFAILURE: msg = wxT("CDERR_LOADSTRFAILURE"); break;
69 case CDERR_LOCKRESFAILURE: msg = wxT("CDERR_LOCKRESFAILURE"); break;
70 case CDERR_MEMALLOCFAILURE: msg = wxT("CDERR_MEMALLOCFAILURE"); break;
71 case CDERR_MEMLOCKFAILURE: msg = wxT("CDERR_MEMLOCKFAILURE"); break;
72 case CDERR_NOHINSTANCE: msg = wxT("CDERR_NOHINSTANCE"); break;
73 case CDERR_NOHOOK: msg = wxT("CDERR_NOHOOK"); break;
74 case CDERR_NOTEMPLATE: msg = wxT("CDERR_NOTEMPLATE"); break;
75 case CDERR_STRUCTSIZE: msg = wxT("CDERR_STRUCTSIZE"); break;
76 case PDERR_RETDEFFAILURE: msg = wxT("PDERR_RETDEFFAILURE"); break;
77 case PDERR_PRINTERNOTFOUND: msg = wxT("PDERR_PRINTERNOTFOUND"); break;
78 case PDERR_PARSEFAILURE: msg = wxT("PDERR_PARSEFAILURE"); break;
79 case PDERR_NODEVICES: msg = wxT("PDERR_NODEVICES"); break;
80 case PDERR_NODEFAULTPRN: msg = wxT("PDERR_NODEFAULTPRN"); break;
81 case PDERR_LOADDRVFAILURE: msg = wxT("PDERR_LOADDRVFAILURE"); break;
82 case PDERR_INITFAILURE: msg = wxT("PDERR_INITFAILURE"); break;
83 case PDERR_GETDEVMODEFAIL: msg = wxT("PDERR_GETDEVMODEFAIL"); break;
84 case PDERR_DNDMMISMATCH: msg = wxT("PDERR_DNDMMISMATCH"); break;
85 case PDERR_DEFAULTDIFFERENT: msg = wxT("PDERR_DEFAULTDIFFERENT"); break;
86 case PDERR_CREATEICFAILURE: msg = wxT("PDERR_CREATEICFAILURE"); break;
87 default: break;
88 }
89 return msg;
90 }
91 #endif
92
93 static HGLOBAL wxCreateDevNames(const wxString& driverName, const wxString& printerName, const wxString& portName)
94 {
95 HGLOBAL hDev = NULL;
96 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
97 if (driverName.IsEmpty() && printerName.IsEmpty() && portName.IsEmpty())
98 {
99 }
100 else
101 {
102 hDev = GlobalAlloc(GPTR, 4*sizeof(WORD)+
103 ( driverName.Length() + 1 +
104 printerName.Length() + 1 +
105 portName.Length()+1 ) * sizeof(wxChar) );
106 LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(hDev);
107 lpDev->wDriverOffset = sizeof(WORD) * 4 / sizeof(wxChar);
108 wxStrcpy((wxChar*)lpDev + lpDev->wDriverOffset, driverName);
109
110 lpDev->wDeviceOffset = (WORD)( lpDev->wDriverOffset +
111 driverName.Length() + 1 );
112 wxStrcpy((wxChar*)lpDev + lpDev->wDeviceOffset, printerName);
113
114 lpDev->wOutputOffset = (WORD)( lpDev->wDeviceOffset +
115 printerName.Length() + 1 );
116 wxStrcpy((wxChar*)lpDev + lpDev->wOutputOffset, portName);
117
118 lpDev->wDefault = 0;
119
120 GlobalUnlock(hDev);
121 }
122
123 return hDev;
124 }
125
126 IMPLEMENT_CLASS(wxWindowsPrintNativeData, wxPrintNativeDataBase)
127
128 wxWindowsPrintNativeData::wxWindowsPrintNativeData()
129 {
130 m_devMode = (void*) NULL;
131 m_devNames = (void*) NULL;
132 }
133
134 wxWindowsPrintNativeData::~wxWindowsPrintNativeData()
135 {
136 HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
137 if ( hDevMode )
138 GlobalFree(hDevMode);
139 HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
140 if ( hDevNames )
141 GlobalFree(hDevNames);
142 }
143
144 bool wxWindowsPrintNativeData::Ok() const
145 {
146 return (m_devMode != NULL) ;
147 }
148
149 bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
150 {
151 HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
152 HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
153
154 if (!hDevMode)
155 return false;
156
157 if ( hDevMode )
158 {
159 LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode);
160
161 //// Orientation
162 if (devMode->dmFields & DM_ORIENTATION)
163 data.SetOrientation( devMode->dmOrientation );
164
165 //// Collation
166 if (devMode->dmFields & DM_COLLATE)
167 {
168 if (devMode->dmCollate == DMCOLLATE_TRUE)
169 data.SetCollate( true );
170 else
171 data.SetCollate( false );
172 }
173
174 //// Number of copies
175 if (devMode->dmFields & DM_COPIES)
176 data.SetNoCopies( devMode->dmCopies );
177
178 if (devMode->dmFields & DM_DEFAULTSOURCE)
179 data.SetBin( (wxPrintBin)devMode->dmDefaultSource );
180
181 //// Printer name
182 if (devMode->dmDeviceName[0] != 0)
183 data.SetPrinterName( devMode->dmDeviceName );
184
185 //// Colour
186 if (devMode->dmFields & DM_COLOR)
187 {
188 if (devMode->dmColor == DMCOLOR_COLOR)
189 data.SetColour( true );
190 else
191 data.SetColour( false );
192 }
193 else
194 data.SetColour( true );
195
196 //// Paper size
197
198 // We don't know size of user defined paper and some buggy drivers
199 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
200 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
201 // code wouldn't set m_paperSize correctly.
202 if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER))
203 {
204 if (wxThePrintPaperDatabase)
205 {
206 wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize);
207 if (paper)
208 {
209 data.SetPaperId( paper->GetId() );
210 data.SetPaperSize( wxSize(paper->GetWidth() / 10,paper->GetHeight() / 10) );
211 }
212 else
213 {
214 // Shouldn't really get here
215 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
216 data.SetPaperId( wxPAPER_NONE );
217 data.SetPaperSize( wxSize(0,0) );
218 }
219 }
220 else
221 {
222 // Shouldn't really get here
223 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
224 data.SetPaperId( wxPAPER_NONE );
225 data.SetPaperSize( wxSize(0,0) );
226 }
227 }
228 else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH))
229 {
230 // DEVMODE is in tenths of a milimeter
231 data.SetPaperId( wxPAPER_NONE );
232 data.SetPaperSize( wxSize(devMode->dmPaperWidth / 10, devMode->dmPaperLength / 10) );
233 }
234 else
235 {
236 // Shouldn't really get here
237 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
238 data.SetPaperId( wxPAPER_NONE );
239 data.SetPaperSize( wxSize(0,0) );
240 }
241
242 //// Duplex
243
244 if (devMode->dmFields & DM_DUPLEX)
245 {
246 switch (devMode->dmDuplex)
247 {
248 case DMDUP_HORIZONTAL: data.SetDuplex( wxDUPLEX_HORIZONTAL ); break;
249 case DMDUP_VERTICAL: data.SetDuplex( wxDUPLEX_VERTICAL ); break;
250 default:
251 case DMDUP_SIMPLEX: data.SetDuplex( wxDUPLEX_SIMPLEX ); break;
252 }
253 }
254 else
255 data.SetDuplex( wxDUPLEX_SIMPLEX );
256
257 //// Quality
258
259 if (devMode->dmFields & DM_PRINTQUALITY)
260 {
261 switch (devMode->dmPrintQuality)
262 {
263 case DMRES_MEDIUM: data.SetQuality( wxPRINT_QUALITY_MEDIUM ); break;
264 case DMRES_LOW: data.SetQuality( wxPRINT_QUALITY_LOW ); break;
265 case DMRES_DRAFT: data.SetQuality( wxPRINT_QUALITY_DRAFT ); break;
266 case DMRES_HIGH: data.SetQuality( wxPRINT_QUALITY_HIGH ); break;
267 default:
268 {
269 // TODO: if the printer fills in the resolution in DPI, how
270 // will the application know if it's high, low, draft etc.??
271 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
272 data.SetQuality( devMode->dmPrintQuality );
273 break;
274
275 }
276 }
277 }
278 else
279 data.SetQuality( wxPRINT_QUALITY_HIGH );
280
281 GlobalUnlock(hDevMode);
282 }
283
284 if (hDevNames)
285 {
286 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(hDevNames);
287 if (lpDevNames)
288 {
289 // TODO: Unicode-ification
290
291 // Get the port name
292 // port is obsolete in WIN32
293 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
294
295 // Get the printer name
296 wxString printerName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset;
297
298 // Not sure if we should check for this mismatch
299 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
300
301 if (printerName != wxT(""))
302 data.SetPrinterName( printerName );
303
304 GlobalUnlock(hDevNames);
305 }
306 }
307
308 return true;
309 }
310
311 bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data )
312 {
313 HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
314 HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
315 if (!hDevMode)
316 {
317 // Use PRINTDLG as a way of creating a DEVMODE object
318 PRINTDLG pd;
319
320 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
321 #ifdef __GNUWIN32__
322 memset(&pd, 0, 66);
323 pd.lStructSize = 66;
324 #else
325 memset(&pd, 0, sizeof(PRINTDLG));
326 #ifdef __WXWINCE__
327 pd.cbStruct = sizeof(PRINTDLG);
328 #else
329 pd.lStructSize = sizeof(PRINTDLG);
330 #endif
331 #endif
332
333 pd.hwndOwner = (HWND)NULL;
334 pd.hDevMode = NULL; // Will be created by PrintDlg
335 pd.hDevNames = NULL; // Ditto
336 //pd.hInstance = (HINSTANCE) wxGetInstance();
337
338 pd.Flags = PD_RETURNDEFAULT;
339 pd.nCopies = 1;
340
341 // Fill out the DEVMODE structure
342 // so we can use it as input in the 'real' PrintDlg
343 if (!PrintDlg(&pd))
344 {
345 if ( pd.hDevMode )
346 GlobalFree(pd.hDevMode);
347 if ( pd.hDevNames )
348 GlobalFree(pd.hDevNames);
349 pd.hDevMode = NULL;
350 pd.hDevNames = NULL;
351
352 #if defined(__WXDEBUG__) && defined(__WIN32__)
353 wxString str(wxT("Printing error: "));
354 str += wxGetPrintDlgError();
355 wxLogDebug(str);
356 #endif
357 }
358 else
359 {
360 hDevMode = pd.hDevMode;
361 m_devMode = (void*)(long) hDevMode;
362 pd.hDevMode = NULL;
363
364 // We'll create a new DEVNAMEs structure below.
365 if ( pd.hDevNames )
366 GlobalFree(pd.hDevNames);
367 pd.hDevNames = NULL;
368
369 // hDevNames = pd->hDevNames;
370 // m_devNames = (void*)(long) hDevNames;
371 // pd->hDevnames = NULL;
372
373 }
374 }
375
376 if ( hDevMode )
377 {
378 LPDEVMODE devMode = (LPDEVMODE) GlobalLock(hDevMode);
379
380 //// Orientation
381 devMode->dmOrientation = (short)data.GetOrientation();
382
383 //// Collation
384 devMode->dmCollate = (data.GetCollate() ? DMCOLLATE_TRUE : DMCOLLATE_FALSE);
385 devMode->dmFields |= DM_COLLATE;
386
387 //// Number of copies
388 devMode->dmCopies = (short)data.GetNoCopies();
389 devMode->dmFields |= DM_COPIES;
390
391 //// Printer name
392 wxString name = data.GetPrinterName();
393 if (name != wxT(""))
394 {
395 //int len = wxMin(31, m_printerName.Len());
396 wxStrncpy((wxChar*)devMode->dmDeviceName,name.c_str(),31);
397 devMode->dmDeviceName[31] = wxT('\0');
398 }
399
400 //// Colour
401 if (data.GetColour())
402 devMode->dmColor = DMCOLOR_COLOR;
403 else
404 devMode->dmColor = DMCOLOR_MONOCHROME;
405 devMode->dmFields |= DM_COLOR;
406
407 //// Paper size
408 if (data.GetPaperId() == wxPAPER_NONE)
409 {
410 // DEVMODE is in tenths of a milimeter
411 devMode->dmPaperWidth = (short)(data.GetPaperSize().x * 10);
412 devMode->dmPaperLength = (short)(data.GetPaperSize().y * 10);
413 devMode->dmPaperSize = DMPAPER_USER;
414 devMode->dmFields |= DM_PAPERWIDTH;
415 devMode->dmFields |= DM_PAPERLENGTH;
416 }
417 else
418 {
419 if (wxThePrintPaperDatabase)
420 {
421 wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType( data.GetPaperId() );
422 if (paper)
423 {
424 devMode->dmPaperSize = (short)paper->GetPlatformId();
425 devMode->dmFields |= DM_PAPERSIZE;
426 }
427 }
428 }
429
430 //// Duplex
431 short duplex;
432 switch (data.GetDuplex())
433 {
434 case wxDUPLEX_HORIZONTAL:
435 duplex = DMDUP_HORIZONTAL;
436 break;
437 case wxDUPLEX_VERTICAL:
438 duplex = DMDUP_VERTICAL;
439 break;
440 default:
441 // in fact case wxDUPLEX_SIMPLEX:
442 duplex = DMDUP_SIMPLEX;
443 break;
444 }
445 devMode->dmDuplex = duplex;
446 devMode->dmFields |= DM_DUPLEX;
447
448 //// Quality
449
450 short quality;
451 switch (data.GetQuality())
452 {
453 case wxPRINT_QUALITY_MEDIUM:
454 quality = DMRES_MEDIUM;
455 break;
456 case wxPRINT_QUALITY_LOW:
457 quality = DMRES_LOW;
458 break;
459 case wxPRINT_QUALITY_DRAFT:
460 quality = DMRES_DRAFT;
461 break;
462 case wxPRINT_QUALITY_HIGH:
463 quality = DMRES_HIGH;
464 break;
465 default:
466 quality = (short)data.GetQuality();
467 break;
468 }
469 devMode->dmPrintQuality = quality;
470 devMode->dmFields |= DM_PRINTQUALITY;
471
472 if (data.GetBin() != wxPRINTBIN_DEFAULT)
473 {
474 switch (data.GetBin())
475 {
476 case wxPRINTBIN_ONLYONE: devMode->dmDefaultSource = DMBIN_ONLYONE; break;
477 case wxPRINTBIN_LOWER: devMode->dmDefaultSource = DMBIN_LOWER; break;
478 case wxPRINTBIN_MIDDLE: devMode->dmDefaultSource = DMBIN_MIDDLE; break;
479 case wxPRINTBIN_MANUAL: devMode->dmDefaultSource = DMBIN_MANUAL; break;
480 case wxPRINTBIN_ENVELOPE: devMode->dmDefaultSource = DMBIN_ENVELOPE; break;
481 case wxPRINTBIN_ENVMANUAL: devMode->dmDefaultSource = DMBIN_ENVMANUAL; break;
482 case wxPRINTBIN_AUTO: devMode->dmDefaultSource = DMBIN_AUTO; break;
483 case wxPRINTBIN_TRACTOR: devMode->dmDefaultSource = DMBIN_TRACTOR; break;
484 case wxPRINTBIN_SMALLFMT: devMode->dmDefaultSource = DMBIN_SMALLFMT; break;
485 case wxPRINTBIN_LARGEFMT: devMode->dmDefaultSource = DMBIN_LARGEFMT; break;
486 case wxPRINTBIN_LARGECAPACITY: devMode->dmDefaultSource = DMBIN_LARGECAPACITY; break;
487 case wxPRINTBIN_CASSETTE: devMode->dmDefaultSource = DMBIN_CASSETTE; break;
488 case wxPRINTBIN_FORMSOURCE: devMode->dmDefaultSource = DMBIN_FORMSOURCE; break;
489
490 default:
491 devMode->dmDefaultSource = (short)(DMBIN_USER + data.GetBin() - wxPRINTBIN_USER);
492 break;
493 }
494
495 devMode->dmFields |= DM_DEFAULTSOURCE;
496 }
497
498 GlobalUnlock(hDevMode);
499 }
500
501 if ( hDevNames )
502 {
503 GlobalFree(hDevNames);
504 }
505
506 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
507 m_devNames = (void*) (long) wxCreateDevNames(wxT(""), data.GetPrinterName(), wxT(""));
508
509 return true;
510 }
511
512 // ---------------------------------------------------------------------------
513 // wxPrintDialog
514 // ---------------------------------------------------------------------------
515
516 IMPLEMENT_CLASS(wxWindowsPrintDialog, wxPrintDialogBase)
517
518 wxWindowsPrintDialog::wxWindowsPrintDialog(wxWindow *p, wxPrintDialogData* data)
519 {
520 Create(p, data);
521 }
522
523 wxWindowsPrintDialog::wxWindowsPrintDialog(wxWindow *p, wxPrintData* data)
524 {
525 wxPrintDialogData data2;
526 if ( data )
527 data2 = *data;
528
529 Create(p, &data2);
530 }
531
532 bool wxWindowsPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
533 {
534 m_dialogParent = p;
535 m_printerDC = NULL;
536 m_destroyDC = true;
537
538 if ( data )
539 m_printDialogData = *data;
540
541 m_printDialogData.SetOwnerWindow(p);
542
543 return true;
544 }
545
546 wxWindowsPrintDialog::~wxWindowsPrintDialog()
547 {
548 if (m_destroyDC && m_printerDC)
549 delete m_printerDC;
550 }
551
552 int wxWindowsPrintDialog::ShowModal()
553 {
554 m_printDialogData.ConvertToNative();
555
556 PRINTDLG* p = (PRINTDLG *)m_printDialogData.GetNativeData() ;
557 if (m_dialogParent)
558 p->hwndOwner = (HWND) m_dialogParent->GetHWND();
559 else if (wxTheApp->GetTopWindow())
560 p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
561 else
562 p->hwndOwner = 0;
563
564 bool ret = (PrintDlg( p ) != 0);
565
566 p->hwndOwner = 0;
567
568 if ( ret != false && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
569 {
570 wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
571 m_printerDC = pdc;
572 m_printDialogData.ConvertFromNative();
573 return wxID_OK;
574 }
575 else
576 {
577 return wxID_CANCEL;
578 }
579 }
580
581 wxDC *wxWindowsPrintDialog::GetPrintDC()
582 {
583 if (m_printerDC)
584 {
585 m_destroyDC = false;
586 return m_printerDC;
587 }
588 else
589 return (wxDC*) NULL;
590 }
591
592 // ---------------------------------------------------------------------------
593 // wxPageSetupDialog
594 // ---------------------------------------------------------------------------
595
596 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
597
598 wxPageSetupDialog::wxPageSetupDialog()
599 {
600 m_dialogParent = NULL;
601 }
602
603 wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
604 {
605 Create(p, data);
606 }
607
608 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
609 {
610 m_dialogParent = p;
611
612 if (data)
613 m_pageSetupData = (*data);
614
615 #if defined(__WIN95__)
616 m_pageSetupData.SetOwnerWindow(p);
617 #endif
618 return true;
619 }
620
621 wxPageSetupDialog::~wxPageSetupDialog()
622 {
623 }
624
625 int wxPageSetupDialog::ShowModal()
626 {
627 #ifdef __WIN95__
628 m_pageSetupData.ConvertToNative();
629 PAGESETUPDLG *p = (PAGESETUPDLG *)m_pageSetupData.GetNativeData();
630 if (m_dialogParent)
631 p->hwndOwner = (HWND) m_dialogParent->GetHWND();
632 else if (wxTheApp->GetTopWindow())
633 p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
634 else
635 p->hwndOwner = 0;
636 BOOL retVal = PageSetupDlg( p ) ;
637 p->hwndOwner = 0;
638 if (retVal)
639 {
640 m_pageSetupData.ConvertFromNative();
641 return wxID_OK;
642 }
643 else
644 return wxID_CANCEL;
645 #else
646 wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
647 int ret = genericPageSetupDialog->ShowModal();
648 m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
649 genericPageSetupDialog->Close(true);
650 return ret;
651 #endif
652 }
653
654 #endif
655 // wxUSE_PRINTING_ARCHITECTURE