1 // File V3d_View_Print.cxx
4 // e-mail t-hartl@muenchen.matra-dtv.fr
6 /************************************************************************/
8 /************************************************************************/
12 #pragma comment( lib, "comdlg32.lib" )
15 #include <V3d_View.jxx>
16 #include <Standard_NotImplemented.hxx>
27 //**********************************************************************
31 //**********************************************************************
35 memset(&_pd, 0, sizeof(PRINTDLG));
38 _pd.lStructSize = sizeof(PRINTDLG);
41 //**********************************************************************
46 if (_pd.hDevNames) GlobalFree(_pd.hDevNames);
47 if (_pd.hDevMode) GlobalFree(_pd.hDevMode);
48 if (_pd.hDC) DeleteDC(_pd.hDC);
52 /************************************************************************/
54 /************************************************************************/
56 Standard_Boolean V3d_View::Print (const Aspect_Handle hPrnDC,
57 const Standard_Boolean showDialog,
58 const Standard_Boolean showBackground,
59 const Standard_CString filename,
60 const Aspect_PrintAlgo printAlgorithm) const
63 if( MyView->IsDefined() )
67 return MyView->Print(hPrnDC, showBackground,
68 filename, printAlgorithm) ;
72 if (device._pd.hDC == NULL || showDialog )
75 DeleteDC(device._pd.hDC);
78 device._pd.Flags = PD_RETURNDC | PD_NOSELECTION | PD_RETURNDEFAULT;
82 device._pd.Flags = PD_RETURNDC | PD_NOSELECTION;
86 ispd = PrintDlg((LPPRINTDLG)(&(device._pd)));
90 return Standard_False;
93 if (!(device._pd.hDC))
95 if (device._pd.hDevNames)
97 GlobalFree(device._pd.hDevNames);
98 device._pd.hDevNames = NULL;
100 if (device._pd.hDevMode)
102 GlobalFree(device._pd.hDevMode);
103 device._pd.hDevMode = NULL;
105 MessageBox(0, "Couldn't create Printer Device Context", "Error", MB_OK | MB_ICONSTOP);
106 return Standard_False;
110 // process scale factor accordingly to the new printing approach
111 DEVMODE* aMode = (LPDEVMODE)GlobalLock(device._pd.hDevMode);
113 // convert percents to multiplication factor, 100% = 1.0
114 Standard_Real aScaleFactor = (Standard_Real) aMode->dmScale / 100.0;
115 GlobalUnlock (device._pd.hDevMode);
116 return MyView->Print(device._pd.hDC, showBackground,
117 filename, printAlgorithm, aScaleFactor) ;
120 Standard_NotImplemented::Raise ("V3d_View::Print is implemented only on Windows");
122 return Standard_False;