OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
printdia.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of Print and PrintSetup common Dialogs classes
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_PRINTDIA_H)
10#define OWL_PRINTDIA_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/commdial.h>
18#include <owl/dc.h>
19
20namespace owl {
21
22#include <owl/preclass.h>
23
24/// \addtogroup print
25/// @{
26
27//
28/// \class TPrintDialog
29/// TPrintDialog displays a modal print or a page setup
30/// dialog. The print dialog box lets you print a document. The print setup dialog
31/// box lets you configure the printer and specify additional print job
32/// characteristics. The page setup dialog lets you specify page settings, such as
33/// margins, and paper orientation. You can also use TPrinter and TPrintout to
34/// provide support for printer dialog boxes. TPrintDialog uses the
35/// TPrintDialog::TData structure to initialize the dialog box with the user's
36/// printer options, such as the number of pages to print, the output device, and so on.
37//
39{
40 public:
41
42 //
43 /// TPrintDialog::TData contains information required to initialize the printer
44 /// dialog box with the user's print selections. This information consists of the
45 /// number of copies to be printed, the first and last pages to print, the maximum
46 /// and minimum number of pages that can be printed and various flag values that
47 /// indicate whether the Pages radio button is displayed, the Print to File check
48 /// box is enabled, and so on.TPrintDialog uses this struct to initialize the print
49 /// dialog box. Whenever the user changes the print requirements, this struct is
50 /// updated.
51 ///
52 /// If an error occurs, TPrintDialog::TData returns one of the common dialog
53 /// extended error codes. TPrintDialog::TData also takes care of locking and
54 /// unlocking memory associated with the DEVMODE and DEVNAMES structures, which
55 /// contain information about the printer driver, the printer, and the output
56 /// printer port.
57 //
59 public:
60
61 /// Flags , which are used to initialize the printer dialog box, can be one or more
62 /// of the following values that control the appearance and functionality of the
63 /// dialog box:
64 ///
65 /// - \c \b PD_ALLPAGES Indicates that the All radio button was selected when the user
66 /// closed the dialog box.
67 /// - \c \b PD_COLLATE Causes the Collate checkbox to be checked when the dialog box is
68 /// created.
69 /// - \c \b PD_DISABLEPRINTTOFILE Disables the Print to File check box.
70 /// - \c \b PD_HIDEPRINTTOFILE Hides and disables the Print to File check box.
71 /// - \c \b PD_NOPAGENUMS Disables the Pages radio button and the associated edit
72 /// control.
73 /// - \c \b PD_NOSELECTION Disables the Selection radio button.
74 /// - \c \b PD_NOWARNING Prevents the warning message from being displayed when there is
75 /// no default printer.
76 /// - \c \b PD_PAGENUMS Selects the Pages radio button when the dialog box is created.
77 /// - \c \b PD_PRINTSETUP Displays the Print Setup dialog box rather than the Print
78 /// dialog box.
79 /// - \c \b PD_PRINTTOFILE Checks the Print to File check box when the dialog box is
80 /// created.
81 /// - \c \b PD_RETURNDC Returns a device context matching the selections that the user
82 /// made in the dialog box.
83 /// - \c \b PD_RETURNDEFAULT Returns DevNames structures that are initialized for the
84 /// default printer without displaying a dialog box.
85 /// - \c \b PD_RETURNIC Returns an information context matching the selections that the
86 /// user made in the dialog box.
87 /// - \c \b PD_SELECTION Selects the Selection radio button when the dialog box is
88 /// created.
89 /// - \c \b PD_SHOWHELP Shows the Help button in the dialog box.
90 /// - \c \b PD_USEDEVMODECOPIES If a printer driver supports multiple copies, setting this
91 /// flag causes the requested number of copies to be stored in the dmCopies member
92 /// of the DevMode structure and 1 in Copies. If a printer driver does not support
93 /// multiple copies, setting this flag disables the Copies edit control. If this
94 /// flag is not set, the number 1 is stored in DevMode and the requested number of
95 /// copies in Copies.
96 //
98
99 /// If the dialog box is successfully executed, Error returns 0. Otherwise, it
100 /// contains one of the following error codes.
101 ///
102 /// - \c \b CDERR_DIALOGFAILURE Failed to create a dialog box.
103 /// - \c \b CDERR_FINDRESFAILURE Failed to find a specified resource.
104 /// - \c \b CDERR_INITIALIZATION Failed to initialize the common dialog box function.
105 /// A lack of sufficient memory can generate this error.
106 /// - \c \b CDERR_LOCKRESOURCEFAILURE Failed to lock a specified resource.
107 /// - \c \b CDERR_LOADRESFAILURE Failed to load a specified resource.
108 /// - \c \b CDERR_LOADSTRFAILURE Failed to load a specified string.
109 /// - \c \b CDERR_MEMALLOCFAILURE Unable to allocate memory for internal data structures.
110 /// - \c \b CDERR_MEMLOCKFAILURE Unable to lock the memory associated with a handle.
111 /// - \c \b CDERR_REGISTERMSGFAIL A message, designed for the purpose of communicating
112 /// between two applications, could not be registered.
113 /// - \c \b PDERR_CREATEICFAILURE TPrintDialog failed to create an information context.
114 /// - \c \b PDERR_DEFAULTDIFFERENT The printer described by structure members doesn't match
115 /// the default printer. This error message can occur if the user changes the
116 /// printer specified in the control panel.
117 /// - \c \b PDERR_DNDMMISMATCH The printer specified in DevMode and in DevNames is
118 /// different.
119 /// - \c \b PDERR_GETDEVMODEFAIL The printer device-driver failed to initialize the DevMode
120 /// structure.
121 /// - \c \b PDERR_INITFAILURE The TPrintDialog structure could not be initialized.
122 /// - \c \b PDERR_LOADDRVFAILURE The specified printer's device driver could not be loaded.
123 /// - \c \b PDERR_NODEFAULTPRN A default printer could not be identified.
124 /// - \c \b PDERR_NODEVICES No printer drivers exist.
125 /// - \c \b PDERR_PARSEFAILURE The string in the [devices] section of the WIN.INI file
126 /// could not be parsed.
127 /// - \c \b PDERR_PRINTERNOTFOUND The [devices] section of the WIN.INI file doesn't contain
128 /// the specified printer.
129 /// - \c \b PDERR_RETDEFFAILURE Either DevMode or DevNames contain zero.
130 /// - \c \b PDERR_SETUPFAILURE TPrintDialog failed to load the required resources.
131 //
133
134 int FromPage; ///< FromPage indicates the beginning page to print.
135 int ToPage; ///< ToPage indicates the ending page to print.
136 int MinPage; ///< MinPage indicates the minimum number of pages that can be printed.
137 int MaxPage; ///< MaxPage indicates the maximum number of pages that can be printed.
138 int Copies; ///< Copies indicates the actual number of pages to be printed.
139
140 uint32 PageSetupFlags; ///< Additional page setup dialog flags
141 TPoint PaperSize; ///< Size of the paper user has chosen
142 TRect MinMargin; ///< Minimum allowable margins of the paper
143 TRect Margin; ///< Initial margins for the paper
144 bool DoPageSetup; ///< Flag to do page setup?
145 bool UseOldDialog; ///< Flag to force use of the old print dialog under Win2K/XP/
146
147 TData();
148 ~TData();
149
150 void Lock();
151 void Unlock();
152
153 /// Accessors and mutators for the internal Win32 DEVMODE structure.
154 /// @{
155 void ClearDevMode();
156 const DEVMODE* GetDevMode() const;
157 DEVMODE* GetDevMode();
158 void SetDevMode(const DEVMODE* devMode);
159 /// @}
160
161 /// Accessors and mutators for the internal Win32 DEVNAMES structure.
162 /// @{
163 void ClearDevNames();
164 const DEVNAMES* GetDevNames() const;
165 LPCTSTR GetDriverName() const;
166 LPCTSTR GetDeviceName() const;
167 LPCTSTR GetOutputName() const;
168 void SetDevNames(const tstring& driver, const tstring& device, const tstring& output);
169 /// @}
170
171 /// Transfers the printers device context.
172 //
173 TPrintDC* TransferDC();
174
175 void* Read(ipstream& is, uint32 version);
176 void Write(opstream& os);
177
178 private:
179
180 HGLOBAL HDevMode;
181 HGLOBAL HDevNames;
182 HDC HDc;
183 DEVMODE* DevMode;
184 DEVNAMES* DevNames;
185
186 // Hide to prevent copying & assignment.
187 //
188 TData(const TData&);
189 TData& operator =(const TData&);
190
191 friend class TPrintDialog;
192 };
193
194 TPrintDialog(TWindow* parent, TData&,
197 LPCTSTR title = 0,
198 TModule* = 0);
199
200 TPrintDialog(TWindow* parent, TData&,
201 const tstring& printTemplateName,
202 const tstring& setupTemplateName = tstring(),
203 const tstring& title = tstring(),
204 TModule* = 0);
205
206 bool GetDefaultPrinter();
207 auto DoExecute() -> int override;
208
209 protected:
210
211 void Init();
212 auto DialogFunction(TMsgId, TParam1, TParam2) -> INT_PTR override;
213
214 // Default behavior inline for message response functions
215 //
216 void CmSetup(); //EV_COMMAND(psh1,
217
218 PRINTDLG& GetPD();
219 void SetPD(const PRINTDLG&);
220
221 TData& GetData();
222
224
225 /// Specifies the dialog box print job characteristics such as page range, number of
226 /// copies, device context, and so on necessary to initialize the print or print
227 /// setup dialog box.
228 //
229 PRINTDLG Pd;
230 PRINTDLGEX Pde;
231 PRINTPAGERANGE PdeRange;
232 PAGESETUPDLG Psd;
233
234 /// Data is a reference to the TData object passed in the constructor. The TData
235 /// object contains print specifications such as the number of copies to be printed,
236 /// the number of pages, the output device name, and so on.
237 //
238 TData& Data;
239
240 private:
241
242 // NOTE: We store both a TResId and a string for each template. If the TResId, passed to the
243 // primary constructor, is a string pointer, then a copy of the string is made, and the TResID
244 // is set to refer to the buffered string (see Init). This prevents issues with dangling string
245 // pointers. If the TResId is a short integer, or NULL, then the corresponding string is empty.
246 // For the secondary constructor, that takes an owl::tstring template name, a copy of the
247 // string is made, and the corresponding TResId is set to refer to the copy (again, see Init).
248 //
249 TResId PrintTemplate;
250 tstring PrintTemplateName;
251 TResId SetupTemplate;
252 tstring SetupTemplateName;
253
254 // Hide to prevent copying & assignment.
255 //
256 TPrintDialog(const TPrintDialog&);
257 TPrintDialog& operator=(const TPrintDialog&);
258
259 DECLARE_RESPONSE_TABLE(TPrintDialog);
261};
262
263/// @}
264
265#include <owl/posclass.h>
266
267} // OWL namespace
268
269#endif // OWL_PRINTDIA_H
Derived from TDialog, TCommonDialog is the abstract base class for TCommonDialog objects.
Definition commdial.h:62
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
A DC class that provides access to a printer.
Definition dc.h:874
TPrintDialog::TData contains information required to initialize the printer dialog box with the user'...
Definition printdia.h:58
uint32 PageSetupFlags
Additional page setup dialog flags.
Definition printdia.h:140
bool UseOldDialog
Flag to force use of the old print dialog under Win2K/XP/.
Definition printdia.h:145
uint32 Error
If the dialog box is successfully executed, Error returns 0.
Definition printdia.h:132
TPoint PaperSize
Size of the paper user has chosen.
Definition printdia.h:141
TRect MinMargin
Minimum allowable margins of the paper.
Definition printdia.h:142
int MaxPage
MaxPage indicates the maximum number of pages that can be printed.
Definition printdia.h:137
int FromPage
FromPage indicates the beginning page to print.
Definition printdia.h:134
uint32 Flags
Flags , which are used to initialize the printer dialog box, can be one or more of the following valu...
Definition printdia.h:97
int ToPage
ToPage indicates the ending page to print.
Definition printdia.h:135
int MinPage
MinPage indicates the minimum number of pages that can be printed.
Definition printdia.h:136
TRect Margin
Initial margins for the paper.
Definition printdia.h:143
int Copies
Copies indicates the actual number of pages to be printed.
Definition printdia.h:138
bool DoPageSetup
Flag to do page setup?
Definition printdia.h:144
TPrintDialog displays a modal print or a page setup dialog.
Definition printdia.h:39
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
Base class for writing streamable objects.
Definition objstrm.h:480
Definition of Common Dialog abstract base class.
Definition of GDI DC encapsulation classes: TDC, TWindowDC, TScreenDC, TDesktopDC,...
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_CASTABLE
Definition objstrm.h:1440
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
std::string tstring
Definition defs.h:79
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338