Module Prnt_dlg.pkg
1// **************************************************************************** //
2// ** ** //
3// ** File : Prnt_Dlg.pkg ** //
4// ** ** //
5// ** Author : Ulbe Stellema ** //
6// ** : Data Access Nederland ** //
7// ** : 05 december 1998 ** //
8// ** ** //
9// ** Purpose : This package contains support for calling the windows ** //
10// ** : PrintDlg and PageSetupDlg functions. ** //
11// ** ** //
12// **************************************************************************** //
13
14Use windows.pkg
15Use DLL.pkg
16Use globmem.pkg
17Use MsgBox.pkg // for debugging purposes
18Use GlobalFunctionsProcedures.pkg
19
20// PAGESETUPDLG.Flags constants
21Define PSD_DEFAULTMINMARGINS for |CI$00000000
22Define PSD_INWININIINTLMEASURE for |CI$00000000
23Define PSD_MINMARGINS for |CI$00000001
24Define PSD_MARGINS for |CI$00000002
25Define PSD_INTHOUSANDTHSOFINCHES for |CI$00000004
26Define PSD_INHUNDREDTHSOFMILLIMETERS for |CI$00000008
27Define PSD_DISABLEMARGINS for |CI$00000010
28Define PSD_DISABLEPRINTER for |CI$00000020
29Define PSD_NOWARNING for |CI$00000080
30Define PSD_DISABLEORIENTATION for |CI$00000100
31Define PSD_RETURNDEFAULT for |CI$00000400
32Define PSD_DISABLEPAPER for |CI$00000200
33Define PSD_SHOWHELP for |CI$00000800
34Define PSD_ENABLEPAGESETUPHOOK for |CI$00002000
35Define PSD_ENABLEPAGESETUPTEMPLATE for |CI$00008000
36Define PSD_ENABLEPAGESETUPTEMPLATEHANDLE for |CI$00020000
37Define PSD_ENABLEPAGEPAINTHOOK for |CI$00040000
38Define PSD_DISABLEPAGEPAINTING for |CI$00080000
39Define PSD_NONETWORKBUTTON for |CI$00200000
40
41// PRINTDLG.Flags constants
42Define PD_ALLPAGES for |CI$00000000
43Define PD_SELECTION for |CI$00000001
44Define PD_PAGENUMS for |CI$00000002
45Define PD_NOSELECTION for |CI$00000004
46Define PD_NOPAGENUMS for |CI$00000008
47Define PD_COLLATE for |CI$00000010
48Define PD_PRINTTOFILE for |CI$00000020
49Define PD_PRINTSETUP for |CI$00000040
50Define PD_NOWARNING for |CI$00000080
51Define PD_RETURNDC for |CI$00000100
52Define PD_RETURNIC for |CI$00000200
53Define PD_RETURNDEFAULT for |CI$00000400
54Define PD_SHOWHELP for |CI$00000800
55Define PD_ENABLEPRINTHOOK for |CI$00001000
56Define PD_ENABLESETUPHOOK for |CI$00002000
57Define PD_ENABLEPRINTTEMPLATE for |CI$00004000
58Define PD_ENABLESETUPTEMPLATE for |CI$00008000
59Define PD_ENABLEPRINTTEMPLATEHANDLE for |CI$00010000
60Define PD_ENABLESETUPTEMPLATEHANDLE for |CI$00020000
61Define PD_USEDEVMODECOPIES for |CI$00040000
62Define PD_USEDEVMODECOPIESANDCOLLATE for |CI$00040000
63Define PD_DISABLEPRINTTOFILE for |CI$00080000
64Define PD_HIDEPRINTTOFILE for |CI$00100000
65Define PD_NONETWORKBUTTON for |CI$00200000
66
67// DEVMODE.dmDeviceName length constant
68Define CCHDEVICENAME for 32
69
70// DEVMODE.dmSpecVersion constants
71Define DM_SPECVERSION_401 for |CI$0401 // Windows 98, Windows NT and Windows 2000
72Define DM_SPECVERSION_400 for |CI$0400 // Windows 95
73Define DM_SPECVERSION_320 for |CI$0320 // Windows NT 3.20
74
75// DEVMODE.dmFormName length constant
76Define CCHFORMNAME for 32
77
78// DEVMODE.dmFields constants
79Define DM_ORIENTATION for |CI$00000001
80Define DM_PAPERSIZE for |CI$00000002
81Define DM_PAPERLENGTH for |CI$00000004
82Define DM_PAPERWIDTH for |CI$00000008
83Define DM_SCALE for |CI$00000010
84Define DM_POSITION for |CI$00000020
85Define DM_COPIES for |CI$00000100
86Define DM_DEFAULTSOURCE for |CI$00000200
87Define DM_PRINTQUALITY for |CI$00000400
88Define DM_COLOR for |CI$00000800
89Define DM_DUPLEX for |CI$00001000
90Define DM_YRESOLUTION for |CI$00002000
91Define DM_TTOPTION for |CI$00004000
92Define DM_COLLATE for |CI$00008000
93Define DM_FORMNAME for |CI$00010000
94Define DM_LOGPIXELS for |CI$00020000
95Define DM_BITSPERPEL for |CI$00040000
96Define DM_PELSWIDTH for |CI$00080000
97Define DM_PELSHEIGHT for |CI$00100000
98Define DM_DISPLAYFLAGS for |CI$00200000
99Define DM_DISPLAYFREQUENCY for |CI$00400000
100Define DM_ICMMETHOD for |CI$00800000
101Define DM_ICMINTENT for |CI$01000000
102Define DM_MEDIATYPE for |CI$02000000
103Define DM_DITHERTYPE for |CI$04000000
104Define DM_PANNINGWIDTH for |CI$08000000
105Define DM_PANNINGHEIGHT for |CI$10000000
106
107// DEVMODE.dmOrientation constants
108Define DMORIENT_PORTRAIT for 1
109Define DMORIENT_LANDSCAPE for 2
110
111// DEVMODE.dmPaperSize constants
112Define DMPAPER_LETTER for 1 // Letter 8 1/2 x 11 in
113Define DMPAPER_LETTERSMALL for 2 // Letter Small 8 1/2 x 11 in
114Define DMPAPER_TABLOID for 3 // Tabloid 11 x 17 in
115Define DMPAPER_LEDGER for 4 // Ledger 17 x 11 in
116Define DMPAPER_LEGAL for 5 // Legal 8 1/2 x 14 in
117Define DMPAPER_STATEMENT for 6 // Statement 5 1/2 x 8 1/2 in
118Define DMPAPER_EXECUTIVE for 7 // Executive 7 1/4 x 10 1/2 in
119Define DMPAPER_A3 for 8 // A3 297 x 420 mm
120Define DMPAPER_A4 for 9 // A4 210 x 297 mm
121Define DMPAPER_A4SMALL for 10 // A4 Small 210 x 297 mm
122Define DMPAPER_A5 for 11 // A5 148 x 210 mm
123Define DMPAPER_B4 for 12 // B4 (JIS) 250 x 354
124Define DMPAPER_B5 for 13 // B5 (JIS) 182 x 257 mm
125Define DMPAPER_FOLIO for 14 // Folio 8 1/2 x 13 in
126Define DMPAPER_QUARTO for 15 // Quarto 215 x 275 mm
127Define DMPAPER_10X14 for 16 // 10x14 in
128Define DMPAPER_11X17 for 17 // 11x17 in
129Define DMPAPER_NOTE for 18 // Note 8 1/2 x 11 in
130Define DMPAPER_ENV_9 for 19 // Envelope #9 3 7/8 x 8 7/8
131Define DMPAPER_ENV_10 for 20 // Envelope #10 4 1/8 x 9 1/2
132Define DMPAPER_ENV_11 for 21 // Envelope #11 4 1/2 x 10 3/8
133Define DMPAPER_ENV_12 for 22 // Envelope #12 4 \276 x 11
134Define DMPAPER_ENV_14 for 23 // Envelope #14 5 x 11 1/2
135Define DMPAPER_CSHEET for 24 // C size sheet
136Define DMPAPER_DSHEET for 25 // D size sheet
137Define DMPAPER_ESHEET for 26 // E size sheet
138Define DMPAPER_ENV_DL for 27 // Envelope DL 110 x 220mm
139Define DMPAPER_ENV_C5 for 28 // Envelope C5 162 x 229 mm
140Define DMPAPER_ENV_C3 for 29 // Envelope C3 324 x 458 mm
141Define DMPAPER_ENV_C4 for 30 // Envelope C4 229 x 324 mm
142Define DMPAPER_ENV_C6 for 31 // Envelope C6 114 x 162 mm
143Define DMPAPER_ENV_C65 for 32 // Envelope C65 114 x 229 mm
144Define DMPAPER_ENV_B4 for 33 // Envelope B4 250 x 353 mm
145Define DMPAPER_ENV_B5 for 34 // Envelope B5 176 x 250 mm
146Define DMPAPER_ENV_B6 for 35 // Envelope B6 176 x 125 mm
147Define DMPAPER_ENV_ITALY for 36 // Envelope 110 x 230 mm
148Define DMPAPER_ENV_MONARCH for 37 // Envelope Monarch 3.875 x 7.5 in
149Define DMPAPER_ENV_PERSONAL for 38 // 6 3/4 Envelope 3 5/8 x 6 1/2 in
150Define DMPAPER_FANFOLD_US for 39 // US Std Fanfold 14 7/8 x 11 in
151Define DMPAPER_FANFOLD_STD_GERMAN for 40 // German Std Fanfold 8 1/2 x 12 in
152Define DMPAPER_FANFOLD_LGL_GERMAN for 41 // German Legal Fanfold 8 1/2 x 13 in
153Define DMPAPER_ISO_B4 for 42 // B4 (ISO) 250 x 353 mm
154Define DMPAPER_JAPANESE_POSTCARD for 43 // Japanese Postcard 100 x 148 mm
155Define DMPAPER_9X11 for 44 // 9 x 11 in
156Define DMPAPER_10X11 for 45 // 10 x 11 in
157Define DMPAPER_15X11 for 46 // 15 x 11 in
158Define DMPAPER_ENV_INVITE for 47 // Envelope Invite 220 x 220 mm
159Define DMPAPER_RESERVED_48 for 48 // RESERVED--DO NOT USE
160Define DMPAPER_RESERVED_49 for 49 // RESERVED--DO NOT USE
161Define DMPAPER_LETTER_EXTRA for 50 // Letter Extra 9 \275 x 12 in
162Define DMPAPER_LEGAL_EXTRA for 51 // Legal Extra 9 \275 x 15 in
163Define DMPAPER_TABLOID_EXTRA for 52 // Tabloid Extra 11.69 x 18 in
164Define DMPAPER_A4_EXTRA for 53 // A4 Extra 9.27 x 12.69 in
165Define DMPAPER_LETTER_TRANSVERSE for 54 // Letter Transverse 8 \275 x 11 in
166Define DMPAPER_A4_TRANSVERSE for 55 // A4 Transverse 210 x 297 mm
167Define DMPAPER_LETTER_EXTRA_TRANSVERSE for 56 // Letter Extra Transverse 9\275 x 12 in
168Define DMPAPER_A_PLUS for 57 // SuperA/SuperA/A4 227 x 356 mm
169Define DMPAPER_B_PLUS for 58 // SuperB/SuperB/A3 305 x 487 mm
170Define DMPAPER_LETTER_PLUS for 59 // Letter Plus 8.5 x 12.69 in
171Define DMPAPER_A4_PLUS for 60 // A4 Plus 210 x 330 mm
172Define DMPAPER_A5_TRANSVERSE for 61 // A5 Transverse 148 x 210 mm
173Define DMPAPER_B5_TRANSVERSE for 62 // B5 (JIS) Transverse 182 x 257 mm
174Define DMPAPER_A3_EXTRA for 63 // A3 Extra 322 x 445 mm
175Define DMPAPER_A5_EXTRA for 64 // A5 Extra 174 x 235 mm
176Define DMPAPER_B5_EXTRA for 65 // B5 (ISO) Extra 201 x 276 mm
177Define DMPAPER_A2 for 66 // A2 420 x 594 mm
178Define DMPAPER_A3_TRANSVERSE for 67 // A3 Transverse 297 x 420 mm
179Define DMPAPER_A3_EXTRA_TRANSVERSE for 68 // A3 Extra Transverse 322 x 445 mm
180Define DMPAPER_DBL_JAPANESE_POSTCARD for 69 // Japanese Double Postcard 200 x 148 mm
181Define DMPAPER_A6 for 70 // A6 105 x 148 mm
182Define DMPAPER_JENV_KAKU2 for 71 // Japanese Envelope Kaku #2
183Define DMPAPER_JENV_KAKU3 for 72 // Japanese Envelope Kaku #3
184Define DMPAPER_JENV_CHOU3 for 73 // Japanese Envelope Chou #3
185Define DMPAPER_JENV_CHOU4 for 74 // Japanese Envelope Chou #4
186Define DMPAPER_LETTER_ROTATED for 75 // Letter Rotated 11 x 8 1/2 11 in
187Define DMPAPER_A3_ROTATED for 76 // A3 Rotated 420 x 297 mm
188Define DMPAPER_A4_ROTATED for 77 // A4 Rotated 297 x 210 mm
189Define DMPAPER_A5_ROTATED for 78 // A5 Rotated 210 x 148 mm
190Define DMPAPER_B4_JIS_ROTATED for 79 // B4 (JIS) Rotated 364 x 257 mm
191Define DMPAPER_B5_JIS_ROTATED for 80 // B5 (JIS) Rotated 257 x 182 mm
192Define DMPAPER_JAPANESE_POSTCARD_ROTATED for 81 // Japanese Postcard Rotated 148 x 100 mm
193Define DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED for 82 // Double Japanese Postcard Rotated 148 x 200 mm
194Define DMPAPER_A6_ROTATED for 83 // A6 Rotated 148 x 105 mm
195Define DMPAPER_JENV_KAKU2_ROTATED for 84 // Japanese Envelope Kaku #2 Rotated
196Define DMPAPER_JENV_KAKU3_ROTATED for 85 // Japanese Envelope Kaku #3 Rotated
197Define DMPAPER_JENV_CHOU3_ROTATED for 86 // Japanese Envelope Chou #3 Rotated
198Define DMPAPER_JENV_CHOU4_ROTATED for 87 // Japanese Envelope Chou #4 Rotated
199Define DMPAPER_B6_JIS for 88 // B6 (JIS) 128 x 182 mm
200Define DMPAPER_B6_JIS_ROTATED for 89 // B6 (JIS) Rotated 182 x 128 mm
201Define DMPAPER_12X11 for 90 // 12 x 11 in
202Define DMPAPER_JENV_YOU4 for 91 // Japanese Envelope You #4
203Define DMPAPER_JENV_YOU4_ROTATED for 92 // Japanese Envelope You #4 Rotated
204Define DMPAPER_P16K for 93 // PRC 16K 146 x 215 mm
205Define DMPAPER_P32K for 94 // PRC 32K 97 x 151 mm
206Define DMPAPER_P32KBIG for 95 // PRC 32K(Big) 97 x 151 mm
207Define DMPAPER_PENV_1 for 96 // PRC Envelope #1 102 x 165 mm
208Define DMPAPER_PENV_2 for 97 // PRC Envelope #2 102 x 176 mm
209Define DMPAPER_PENV_3 for 98 // PRC Envelope #3 125 x 176 mm
210Define DMPAPER_PENV_4 for 99 // PRC Envelope #4 110 x 208 mm
211Define DMPAPER_PENV_5 for 100 // PRC Envelope #5 110 x 220 mm
212Define DMPAPER_PENV_6 for 101 // PRC Envelope #6 120 x 230 mm
213Define DMPAPER_PENV_7 for 102 // PRC Envelope #7 160 x 230 mm
214Define DMPAPER_PENV_8 for 103 // PRC Envelope #8 120 x 309 mm
215Define DMPAPER_PENV_9 for 104 // PRC Envelope #9 229 x 324 mm
216Define DMPAPER_PENV_10 for 105 // PRC Envelope #10 324 x 458 mm
217Define DMPAPER_P16K_ROTATED for 106 // PRC 16K Rotated
218Define DMPAPER_P32K_ROTATED for 107 // PRC 32K Rotated
219Define DMPAPER_P32KBIG_ROTATED for 108 // PRC 32K(Big) Rotated
220Define DMPAPER_PENV_1_ROTATED for 109 // PRC Envelope #1 Rotated 165 x 102 mm
221Define DMPAPER_PENV_2_ROTATED for 110 // PRC Envelope #2 Rotated 176 x 102 mm
222Define DMPAPER_PENV_3_ROTATED for 111 // PRC Envelope #3 Rotated 176 x 125 mm
223Define DMPAPER_PENV_4_ROTATED for 112 // PRC Envelope #4 Rotated 208 x 110 mm
224Define DMPAPER_PENV_5_ROTATED for 113 // PRC Envelope #5 Rotated 220 x 110 mm
225Define DMPAPER_PENV_6_ROTATED for 114 // PRC Envelope #6 Rotated 230 x 120 mm
226Define DMPAPER_PENV_7_ROTATED for 115 // PRC Envelope #7 Rotated 230 x 160 mm
227Define DMPAPER_PENV_8_ROTATED for 116 // PRC Envelope #8 Rotated 309 x 120 mm
228Define DMPAPER_PENV_9_ROTATED for 117 // PRC Envelope #9 Rotated 324 x 229 mm
229Define DMPAPER_PENV_10_ROTATED for 118 // PRC Envelope #10 Rotated 458 x 324 mm
230Define DMPAPER_USER for 256
231
232// DEVMODE.dmDefaultSource constants
233Define DMBIN_UPPER for 1
234Define DMBIN_ONLYONE for 1
235Define DMBIN_LOWER for 2
236Define DMBIN_MIDDLE for 3
237Define DMBIN_MANUAL for 4
238Define DMBIN_ENVELOPE for 5
239Define DMBIN_ENVMANUAL for 6
240Define DMBIN_AUTO for 7
241Define DMBIN_TRACTOR for 8
242Define DMBIN_SMALLFMT for 9
243Define DMBIN_LARGEFMT for 10
244Define DMBIN_LARGECAPACITY for 11
245Define DMBIN_CASSETTE for 14
246Define DMBIN_FORMSOURCE for 15
247Define DMBIN_USER for 256
248
249// DEVMODE.dmPrintQuality constants
250Define DMRES_DRAFT for (-1)
251Define DMRES_LOW for (-2)
252Define DMRES_MEDIUM for (-3)
253Define DMRES_HIGH for (-4)
254
255// DEVMODE.dmColor constants
256Define DMCOLOR_MONOCHROME for 1
257Define DMCOLOR_COLOR for 2
258
259// DEVMODE.dmDuplex constants
260Define DMDUP_SIMPLEX for 1
261Define DMDUP_VERTICAL for 2
262Define DMDUP_HORIZONTAL for 3
263
264// DEVMODE.dmTTOption constants
265Define DMTT_BITMAP for 1 // print TT fonts as graphics
266Define DMTT_DOWNLOAD for 2 // download TT fonts as soft fonts
267Define DMTT_SUBDEV for 3 // substitute device fonts for TT fonts
268Define DMTT_DOWNLOAD_OUTLINE for 4 // download TT fonts as outline soft fonts
269
270// DEVMODE.dmCollate constants
271Define DMCOLLATE_FALSE for 0
272Define DMCOLLATE_TRUE for 1
273
274// DEVMODE.dmNup constants
275Define DMNUP_SYSTEM for 1
276Define DMNUP_ONEUP for 2
277
278// DEVMODE.dmICMMethod constants
279Define DMICMMETHOD_NONE for 1 // ICM disabled */
280Define DMICMMETHOD_SYSTEM for 2 // ICM handled by system */
281Define DMICMMETHOD_DRIVER for 3 // ICM handled by driver */
282Define DMICMMETHOD_DEVICE for 4 // ICM handled by device */
283Define DMICMMETHOD_USER for 256 // Device-specific methods start here */
284
285// DEVMODE.dmICMIntent constants
286Define DMICM_SATURATE for 1 // Maximize color saturation */
287Define DMICM_CONTRAST for 2 // Maximize color contrast */
288Define DMICM_COLORIMETRIC for 3 // Use specific color metric */
289Define DMICM_ABS_COLORIMETRIC for 4 // Use specific color metric */
290Define DMICM_USER for 256 // Device-specific intents start here */
291
292// DEVMODE.dmMediaType constants
293Define DMMEDIA_STANDARD for 1 // Standard paper */
294Define DMMEDIA_TRANSPARENCY for 2 // Transparency */
295Define DMMEDIA_GLOSSY for 3 // Glossy paper */
296Define DMMEDIA_USER for 256 // Device-specific media start here */
297
298// DEVMODE.DitherType constants
299Define DMDITHER_NONE for 1 // No dithering */
300Define DMDITHER_COARSE for 2 // Dither with a coarse brush */
301Define DMDITHER_FINE for 3 // Dither with a fine brush */
302Define DMDITHER_LINEART for 4 // LineArt dithering */
303Define DMDITHER_ERRORDIFFUSION for 5 // LineArt dithering */
304Define DMDITHER_RESERVED6 for 6 // LineArt dithering */
305Define DMDITHER_RESERVED7 for 7 // LineArt dithering */
306Define DMDITHER_RESERVED8 for 8 // LineArt dithering */
307Define DMDITHER_RESERVED9 for 9 // LineArt dithering */
308Define DMDITHER_GRAYSCALE for 10 // Device does grayscaling */
309Define DMDITHER_USER for 256 // Device-specific dithers start here */
310
311// External function declarations
312External_Function PrintDlg "PrintDlgA" COMDLG32.DLL ;
313 Pointer lppd ;
314 Returns Integer
315
316External_Function PageSetupDlg "PageSetupDlgA" COMDLG32.DLL ;
317 Pointer lppsd ;
318 Returns Integer
319
320External_Function CommDlgExtendedError "CommDlgExtendedError" COMDLG32.DLL ;
321 Returns dWord
322
323// Structure declarations
324Type POINT
325 Field POINT.x as dWord
326 Field POINT.y as dWord
327End_Type // POINT
328
329Type RECT
330 Field RECT.left as dWord
331 Field RECT.top as dWord
332 Field RECT.right as dWord
333 Field RECT.bottom as dWord
334End_Type // RECT
335
336Type PRINTDLG
337 Field PRINTDLG.lStructSize as dWord // 1
338 Field PRINTDLG.hwndOwner as Handle // 5
339 Field PRINTDLG.hDevMode as Handle // 9
340 Field PRINTDLG.hDevNames as Handle // 13
341 Field PRINTDLG.hDC as Handle // 17
342 Field PRINTDLG.Flags as dWord // 21
343 Field PRINTDLG.nFromPage as Word // 25
344 Field PRINTDLG.nToPage as Word // 27
345 Field PRINTDLG.nMinPage as Word // 29
346 Field PRINTDLG.nMaxPage as Word // 31
347 Field PRINTDLG.nCopies as Word // 33
348 Field PRINTDLG.hInstance as Handle
349 Field PRINTDLG.lCustData as Pointer
350 Field PRINTDLG.lpfnPrintHook as Pointer
351 Field PRINTDLG.lpfnSetupHook as Pointer
352 Field PRINTDLG.lpPrintTemplateName as Pointer
353 Field PRINTDLG.lpSetupTemplateName as Pointer
354 Field PRINTDLG.hPrintTemplate as Handle
355 Field PRINTDLG.hSetupTemplate as Handle
356End_Type // PRINTDLG
357
358Type PAGESETUPDLG
359 Field PAGESETUPDLG.lStructSize as dWord // 1
360 Field PAGESETUPDLG.hwndOwner as Handle // 5
361 Field PAGESETUPDLG.hDevMode as Handle // 9
362 Field PAGESETUPDLG.hDevNames as Handle // 13
363 Field PAGESETUPDLG.Flags as dWord // 17
364 Field PAGESETUPDLG.ptPaperSize.x as dWord // 21
365 Field PAGESETUPDLG.ptPaperSize.y as dWord // 25
366 Field PAGESETUPDLG.rtMinMargin.left as dWord // 29
367 Field PAGESETUPDLG.rtMinMargin.top as dWord // 33
368 Field PAGESETUPDLG.rtMinMargin.right as dWord // 37
369 Field PAGESETUPDLG.rtMinMargin.bottom as dWord // 41
370 Field PAGESETUPDLG.rtMargin.left as dWord // 45
371 Field PAGESETUPDLG.rtMargin.top as dWord // 49
372 Field PAGESETUPDLG.rtMargin.right as dWord // 53
373 Field PAGESETUPDLG.rtMargin.bottom as dWord // 57
374 Field PAGESETUPDLG.hInstance as Handle // 61
375 Field PAGESETUPDLG.lCustData as Pointer // 65
376 Field PAGESETUPDLG.lpfnPageSetupHook as Pointer // 69
377 Field PAGESETUPDLG.lpfnPagePaintHook as Pointer // 73
378 Field PAGESETUPDLG.lpPageSetupTemplateName as Pointer // 77
379 Field PAGESETUPDLG.hPageSetupTemplate as Handle // 81
380End_Type // PAGESETUPDLG
381
382Type DEVMODE
383 Field DEVMODE.dmDeviceName as Char CCHDEVICENAME
384 Field DEVMODE.dmSpecVersion as Word
385 Field DEVMODE.dmDriverVersion as Word
386 Field DEVMODE.dmSize as Word
387 Field DEVMODE.dmDriverExtra as Word
388 Field DEVMODE.dmFields as dWord
389 Field DEVMODE.dmOrientation as Short
390 Field DEVMODE.dmPaperSize as Short
391 Field DEVMODE.dmPaperLength as Short
392 Field DEVMODE.dmPaperWidth as Short
393 Field DEVMODE.dmScale as Short
394 Field DEVMODE.dmCopies as Short
395 Field DEVMODE.dmDefaultSource as Short
396 Field DEVMODE.dmPrintQuality as Short
397 Field DEVMODE.dmColor as Short
398 Field DEVMODE.dmDuplex as Short
399 Field DEVMODE.dmYResolution as Short
400 Field DEVMODE.dmTTOption as Short
401 Field DEVMODE.dmCollate as Short
402 Field DEVMODE.dmFormName as Char CCHFORMNAME
403 Field DEVMODE.dmLogPixels as Word
404 Field DEVMODE.dmBitsPerPel as dWord
405 Field DEVMODE.dmPelsWidth as dWord
406 Field DEVMODE.dmPelsHeight as dWord
407 Field DEVMODE.dmNup as dWord
408 Field DEVMODE.dmICMMethod as dWord
409 Field DEVMODE.dmICMIntent as dWord
410 Field DEVMODE.dmMediaType as dWord
411 Field DEVMODE.dmDitherType as dWord
412 Field DEVMODE.dmReserved1 as dWord
413 Field DEVMODE.dmReserved2 as dWord
414 //Field DEVMODE.dmPanningWidth as dWord
415 //Field DEVMODE.dmPanningHeight as dWord
416End_Type // DEVMODE
417
418Type DEVNAMES
419 Field DEVNAMES.wDriverOffset as Word
420 Field DEVNAMES.wDeviceOffset as Word
421 Field DEVNAMES.wOutputOffset as Word
422 Field DEVNAMES.wDefault as Word
423End_Type // DEVNAMES
424
425
426// **************************************************************************** //
427// ** ** //
428// ** Class : Print_Dialog_Mixin ** //
429// ** ** //
430// ** Purpose : This class defines properties and funcions common to both ** //
431// ** the PrintDialog and PageSetupDialog dialog boxes. ** //
432// ** ** //
433// **************************************************************************** //
434
435Class Print_Dialog_Mixin Is A Mixin
436
437 // ************************************************************************ //
438 // ** ** //
439 // ** Procedure : Define_Print_Dialog ** //
440 // ** ** //
441 // ** Purpose : Define properties common to the PrintDialog and ** //
442 // ** PageSetupDialog boxes. ** //
443 // ** ** //
444 // ************************************************************************ //
445
446 { Visibility=Private }
447 Procedure Define_Print_Dialog
448
449 // PRINTDLG and PAGESETUPDLG properties
450
451 // This has been changed. -1 means to use the main_window's window_handle, 0 means
452 // use no parent (it will be modeless), any other value is a window_handle. Note that
453 // this is used indirectly by ParentWindowHandle to get the real window handle. Normally
454 // a developer will never need to change this.
455 { Visibility=Private }
456 Property Handle hWindow -1
457 { Visibility=Private }
458 Property Handle DevModeHandle 0
459 { Visibility=Private }
460 Property Handle DevNamesHandle 0
461
462 //Property String DevMode ""
463 //Property String DevNames ""
464
465 // DEVMODE and DEVNAMES properties
466 Property String DriverName ""
467 Property String DeviceName ""
468 Property String OutputName ""
469
470 // DEVMODE properties
471 { Category=Behavior }
472 Property Integer Orientation 0
473 { Category=Behavior }
474 Property Integer PaperSize 0
475 { Category=Behavior }
476 Property Integer PaperLength 0
477 { Category=Behavior }
478 Property Integer PaperWidth 0
479 { Category=Behavior }
480 Property Integer Scale 0
481 { Category=Behavior }
482 Property Integer Copies 0
483 { Category=Behavior }
484 Property Integer DefaultSource 0
485 { Category=Behavior }
486 Property Integer PrintQuality 0
487 { Category=Behavior }
488 Property Integer Color 0
489 { Category=Behavior }
490 Property Integer Duplex 0
491 { Category=Behavior }
492 Property Integer YResolution 0
493 { Category=Behavior }
494 Property Integer TTOption 0
495 { Category=Behavior }
496 Property Integer Collate 0
497 Property String FormName ""
498 { Category=Behavior }
499 Property Integer ICMMethod 0
500 { Category=Behavior }
501 Property Integer ICMIntent 0
502 { Category=Behavior }
503 Property Integer MediaType 0
504 { Category=Behavior }
505 Property Integer DitherType 0
506
507 End_Procedure // Define_Print_Dialog
508
509 // **************************************************************************** //
510 // ** ** //
511 // ** Function : PointerToString ** //
512 // ** ** //
513 // ** Purpose : This function takes a pointer to a null terminated string ** //
514 // ** and returns the string without the null. ** //
515 // ** ** //
516 // **************************************************************************** //
517
518 { Visibility=Private }
519 Function PointerToString Pointer pString Returns String
520 String sCharacter sString
521 Pointer pCharacter
522 Integer iResult
523
524 // Create a single character buffer
525 Move (Character(0)) To sCharacter
526 GetAddress Of sCharacter To pCharacter
527
528 // Read characters until the null character
529 // WARNING: No overflow checking is performed
530 Move (CopyMemory(pCharacter,pString,1)) To iResult
531 While (Ascii(sCharacter) <> 0)
532 Append sString sCharacter
533 Increment pString
534 Move (CopyMemory(pCharacter,pString,1)) To iResult
535 Loop // While (Ascii(sCharacter) <> 0)
536 Function_Return sString
537 End_Function // PointerToString
538
539 // ************************************************************************ //
540 // ** ** //
541 // ** Function : InitDevMode ** //
542 // ** ** //
543 // ** Purpose : This function returns a handle to a global memory ** //
544 // ** object that contains a DEVMODE structure. ** //
545 // ** ** //
546 // ** Returns : Returns the handle to the global memory object, zero if ** //
547 // ** the global memory object could not be allocated. ** //
548 // ** ** //
549 // ************************************************************************ //
550
551 { Visibility=Private }
552 Function InitDevMode Returns Handle
553 Integer iFields iVoid iResult
554 Pointer pHeap pDevMode
555 String sDevMode
556 Handle hHeap
557
558 // Allocate memory for DEVMODE structure
559 Move (GlobalAlloc(GMEM_MOVEABLE,DEVMODE_Size)) To hHeap
560 If (hHeap = 0) Begin
561 Move (ShowLastError()) To iResult
562 Function_Return 0
563 End // If (hHeap = 0) Begin
564
565 // Lock allocated memory
566 Move (GlobalLock(hHeap)) To pHeap
567 If (pHeap = 0) Begin
568 Move (ShowLastError()) To iResult
569 Function_Return hHeap
570 End // If (pHeap = 0) Begin
571
572 ZeroType DEVMODE To sDevMode
573 Put_String (DeviceName(Self)) To sDevMode At DEVMODE.dmDeviceName
574 Put DM_SPECVERSION_400 To sDevMode At DEVMODE.dmSpecVersion
575 Put DEVMODE_Size To sDevMode At DEVMODE.dmSize
576
577 // Create dmFields bit pattern
578 If (Orientation(Self) <> 0) Move (iFields iOr DM_ORIENTATION) To iFields
579 If (PaperSize(Self) <> 0) Move (iFields iOr DM_PAPERSIZE) To iFields
580 If (PaperLength(Self) <> 0) Move (iFields iOr DM_PAPERLENGTH) To iFields
581 If (PaperWidth(Self) <> 0) Move (iFields iOr DM_PAPERWIDTH) To iFields
582 If (Scale(Self) <> 0) Move (iFields iOr DM_SCALE) To iFields
583 If (Copies(Self) <> 0) Move (iFields iOr DM_COPIES) To iFields
584 If (DefaultSource(Self) <> 0) Move (iFields iOr DM_DEFAULTSOURCE) To iFields
585 If (PrintQuality(Self) <> 0) Move (iFields iOr DM_PRINTQUALITY) To iFields
586 If (Color(Self) <> 0) Move (iFields iOr DM_COLOR) To iFields
587 If (Duplex(Self) <> 0) Move (iFields iOr DM_DUPLEX) To iFields
588 If (YResolution(Self) <> 0) Move (iFields iOr DM_YRESOLUTION) To iFields
589 If (TTOption(Self) <> 0) Move (iFields iOr DM_TTOPTION) To iFields
590 If (Collate(Self) <> 0) Move (iFields iOr DM_COLLATE) To iFields
591 If (FormName(Self) <> "") Move (iFields iOr DM_FORMNAME) To iFields
592 If (ICMMethod(Self) <> 0) Move (iFields iOr DM_ICMMETHOD) To iFields
593 If (ICMIntent(Self) <> 0) Move (iFields iOr DM_ICMINTENT) To iFields
594 If (MediaType(Self) <> 0) Move (iFields iOr DM_MEDIATYPE) To iFields
595 If (DitherType(Self) <> 0) Move (iFields iOr DM_DITHERTYPE) To iFields
596
597 Put iFields to sDevMode at DEVMODE.dmFields
598 Put (Orientation(Self)) to sDevMode at DEVMODE.dmOrientation
599 Put (PaperSize(Self)) to sDevMode at DEVMODE.dmPaperSize
600 Put (PaperLength(Self)) to sDevMode at DEVMODE.dmPaperLength
601 Put (PaperWidth(Self)) to sDevMode at DEVMODE.dmPaperWidth
602 Put (Scale(Self)) to sDevMode at DEVMODE.dmScale
603 Put (Copies(Self)) to sDevMode at DEVMODE.dmCopies
604 Put (DefaultSource(Self)) to sDevMode at DEVMODE.dmDefaultSource
605 Put (PrintQuality(Self)) to sDevMode at DEVMODE.dmPrintQuality
606 Put (Color(Self)) to sDevMode at DEVMODE.dmColor
607 Put (Duplex(Self)) to sDevMode at DEVMODE.dmDuplex
608 Put (YResolution(Self)) to sDevMode at DEVMODE.dmYResolution
609 Put (TTOption(Self)) to sDevMode at DEVMODE.dmTTOption
610 Put (Collate(Self)) to sDevMode at DEVMODE.dmCollate
611 Put_String (FormName(Self)) to sDevMode at DEVMODE.dmFormName
612 Put (ICMMethod(Self)) to sDevMode at DEVMODE.dmICMMethod
613 Put (ICMIntent(Self)) to sDevMode at DEVMODE.dmICMIntent
614 Put (MediaType(Self)) to sDevMode at DEVMODE.dmMediaType
615 Put (DitherType(Self)) to sDevMode at DEVMODE.dmDitherType
616
617 // Copy the DEVMODE structure to the heap
618 GetAddress of sDevMode To pDevMode
619 Move (CopyMemory(pHeap,pDevMode,DEVMODE_Size)) To iVoid
620
621 // Unlock allocated memory
622 Move (GlobalUnlock(hHeap)) To iResult
623 If (iResult = 0) Move (ShowLastError()) To iResult
624
625 Function_Return hHeap
626 End_Function // InitDevMode
627
628 // ************************************************************************ //
629 // ** ** //
630 // ** Function : InitDevNames ** //
631 // ** ** //
632 // ** Purpose : This function returns a handle to a global memory ** //
633 // ** object that contains a DEVNAMES structure. ** //
634 // ** ** //
635 // ** Returns : Returns the handle to the global memory object, zero if ** //
636 // ** the global memory object could not be allocated. ** //
637 // ** ** //
638 // ************************************************************************ //
639
640 { Visibility=Private }
641 Function InitDevNames Returns Handle
642 Pointer pHeap pDriverName pDeviceName pOutputName pDevNames
643 String sDriverName sDeviceName sOutputName sDevNames
644 Integer iSize iVoid iResult
645 Handle hHeap
646
647 ZeroType DEVNAMES To sDevNames
648 Move (DriverName(Self)+Character(0)) To sDriverName
649 Move (DeviceName(Self)+Character(0)) To sDeviceName
650 Move (OutputName(Self)+Character(0)) To sOutputName
651
652 GetAddress of sDriverName to pDriverName
653 GetAddress of sDeviceName to pDeviceName
654 GetAddress of sOutputName to pOutputName
655
656 // Allocate memory for the DEVNAMES structure
657 Move (DEVNAMES_Size+Length(sDriverName)+Length(sDeviceName)+Length(sOutputName)) To iSize
658 Move (GlobalAlloc(GMEM_MOVEABLE,iSize)) To hHeap
659 If (hHeap = 0) Begin
660 Move (ShowLastError()) To iResult
661 Function_Return 0
662 End // If (hHeap = 0) Begin
663
664 // Lock allocated memory
665 Move (GlobalLock(hHeap)) To pHeap
666 If (pHeap = 0) Begin
667 Move (ShowLastError()) To iResult
668 Function_Return hHeap
669 End // If (pHeap = 0) Begin
670
671 // Copy the driver, device and port name strings to the heap
672 Move (DEVNAMES_Size) To iSize
673 Move (CopyMemory(pHeap+iSize,pDriverName,Length(sDriverName))) To iVoid
674 Put iSize to sDevNames at DEVNAMES.wDriverOffset
675 Move (iSize+Length(sDriverName)) To iSize
676 Move (CopyMemory(pHeap+iSize,pDeviceName,Length(sDeviceName))) To iVoid
677 Put iSize to sDevNames at DEVNAMES.wDeviceOffset
678 Move (iSize+Length(sDeviceName)) To iSize
679 Move (CopyMemory((pHeap+iSize),pOutputName,Length(sOutputName))) To iVoid
680 Put iSize to sDevNames at DEVNAMES.wOutputOffset
681
682 // Copy the DEVNAMES structure to the heap
683 GetAddress of sDevNames To pDevNames
684 Move (CopyMemory(pHeap,pDevNames,DEVNAMES_Size)) To iVoid
685
686 // Unlock allocated memory
687 Move (GlobalUnlock(hHeap)) To iResult
688 If (iResult = 0) Move (ShowLastError()) To iResult
689
690 Function_Return hHeap
691 End_Function // InitDevNames
692
693 // ************************************************************************ //
694 // ** ** //
695 // ** Function : ReadDevMode ** //
696 // ** ** //
697 // ** Purpose : This function reads the members of the DEVMODE ** //
698 // ** structure when the PrintDialog or PageSetupDlg function ** //
699 // ** returns. ** //
700 // ** ** //
701 // ************************************************************************ //
702
703 { Visibility=Private }
704 Function ReadDevMode Handle hDevMode Returns Integer
705 Integer iResult iFields
706 String sDevMode sHeap
707 Pointer pDevMode pHeap
708
709 // Create a DEVMODE structure
710 ZeroType DEVMODE To sDevMode
711 GetAddress Of sDevMode to pDevMode
712
713 // Lock allocated memory
714 Move (GlobalLock(hDevMode)) To pHeap
715 If (pHeap = 0) Begin
716 Move (ShowLastError()) To iResult
717 Function_Return DFTrue
718 End // If (pHeap = 0) Begin
719
720 // Copy the structure from the heap to our DEVMODE structure
721 Move (CopyMemory(pDevMode,pHeap,DEVMODE_Size)) To iResult
722
723 GetBuff From sDevMode At DEVMODE.dmFields To iFields
724 // Retrieve the members
725 If (iFields iAnd DM_ORIENTATION) Set Orientation To (BytesToShort(sDevMode,45))
726 If (iFields iAnd DM_PAPERSIZE) Set PaperSize To (BytesToShort(sDevMode,47))
727 If (iFields iAnd DM_PAPERLENGTH) Set PaperLength To (BytesToShort(sDevMode,49))
728 If (iFields iAnd DM_PAPERWIDTH) Set PaperWidth To (BytesToShort(sDevMode,51))
729 If (iFields iAnd DM_SCALE) Set Scale To (BytesToShort(sDevMode,53))
730 If (iFields iAnd DM_COPIES) Set Copies To (BytesToShort(sDevMode,55))
731 If (iFields iAnd DM_DEFAULTSOURCE) Set DefaultSource To (BytesToShort(sDevMode,57))
732 If (iFields iAnd DM_PRINTQUALITY) Set PrintQuality To (BytesToShort(sDevMode,59))
733 If (iFields iAnd DM_COLOR) Set Color To (BytesToShort(sDevMode,61))
734 If (iFields iAnd DM_DUPLEX) Set Duplex To (BytesToShort(sDevMode,63))
735 If (iFields iAnd DM_YRESOLUTION) Set YResolution To (BytesToShort(sDevMode,65))
736 If (iFields iAnd DM_TTOPTION) Set TTOption To (BytesToShort(sDevMode,67))
737 If (iFields iAnd DM_COLLATE) Set Collate To (BytesToShort(sDevMode,69))
738 If (iFields iAnd DM_FORMNAME) Set FormName To (Mid(sDevMode,CCHFORMNAME,71))
739 If (iFields iAnd DM_ICMMETHOD) Set ICMMethod To (BytesToDWord(sDevMode,121))
740 If (iFields iAnd DM_ICMINTENT) Set ICMIntent To (BytesToDWord(sDevMode,125))
741 If (iFields iAnd DM_MEDIATYPE) Set MediaType To (BytesToDWord(sDevMode,129))
742 If (iFields iAnd DM_DITHERTYPE) Set DitherType To (BytesToDWord(sDevMode,133))
743
744 // Unlock memory
745 Move (GlobalUnlock(hDevMode)) To iResult
746 If (iResult = 0) Move (ShowLastError()) To iResult
747
748 Set DevModeHandle To hDevMode
749 Function_Return DFFalse
750 End_Function // ReadDevMode
751
752 // ************************************************************************ //
753 // ** ** //
754 // ** Function : ReadDevNames ** //
755 // ** ** //
756 // ** Purpose : This function reads the members of the DEVNAMES ** //
757 // ** structure when the PrintDialog or PageSetupDlg function ** //
758 // ** returns. ** //
759 // ** ** //
760 // ************************************************************************ //
761
762 { Visibility=Private }
763 Function ReadDevNames Handle hDevNames Returns Integer
764 Integer iResult iOffset
765 String sDevNames sHeap
766 Pointer pDevNames pHeap
767
768 // Create a DEVNAMES structure
769 ZeroType DEVNAMES To sDevNames
770 GetAddress Of sDevNames To pDevNames
771
772 // Lock allocated memory
773 Move (GlobalLock(hDevNames)) To pHeap
774 If (pHeap = 0) Begin
775 Move (ShowLastError()) To iResult
776 Function_Return DFTrue
777 End // If (pHeap = 0) Begin
778
779 // Copy the structure from the heap to our DEVNAMES structure
780 Move (CopyMemory(pDevNames,pHeap,DEVNAMES_Size)) To iResult
781
782 // Retrieve the members
783 GetBuff From sDevNames At DEVNAMES.wDriverOffset To iOffset
784 Set DriverName To (PointerToString(self,pHeap+iOffset))
785
786 GetBuff From sDevNames At DEVNAMES.wDeviceOffset To iOffset
787 Set DeviceName To (PointerToString(self,pHeap+iOffset))
788
789 GetBuff From sDevNames At DEVNAMES.wOutputOffset To iOffset
790 Set OutputName To (PointerToString(self,pHeap+iOffset))
791
792 // Unlock memory
793 Move (GlobalUnlock(hDevNames)) To iResult
794 If (iResult = 0) Move (ShowLastError()) To iResult
795
796 Set DevNamesHandle To hDevNames
797 Function_Return DFFalse
798 End_Function // DevNames
799
800 // ************************************************************************ //
801 // ** ** //
802 // ** Function : ParentWindowHandle ** //
803 // ** ** //
804 // ** Purpose : This function returns the windows handle to be used ** //
805 // ** as the parent window handle ** //
806 // ** ** //
807 // ** Returns : Should return a valid handle or 0. If zero the dialog ** //
808 // ** will be modeless (which you probably would never want) ** //
809 // ** ** //
810 // ************************************************************************ //
811
812 { Visibility=Private }
813 Function ParentWindowHandle returns handle
814 Handle hWnd
815 Handle hoObj
816 Get Focus of desktop to hoObj // start with the focus
817 Move (gOwnerWindowHandle(hoObj)) to hWnd // global function finds the right handle for us
818 function_return hWnd
819 End_Function
820
821End_Class // Print_Dialog_Mixin
822
823// **************************************************************************** //
824// ** ** //
825// ** Class : PageSetupDialog ** //
826// ** ** //
827// ** Purpose : This class is a wrapper for the Page Setup dialog box. ** //
828// ** ** //
829// **************************************************************************** //
830
831{ Visibility=Private Obsolete=True ClassLibrary=Windows }
832Class PageSetupDialog Is A cObject
833
834 // ************************************************************************ //
835 // ** ** //
836 // ** Procedure : Construct_Object ** //
837 // ** ** //
838 // ** Purpose : Define some properties for the Page Setup dialog box. ** //
839 // ** ** //
840 // ************************************************************************ //
841
842 Procedure Construct_Object
843 Forward Send Construct_Object
844
845 Send Define_Print_Dialog
846
847 Property Integer Flags 0
848 Property Integer PaperSizeX 0
849 Property Integer PaperSizeY 0
850 Property Integer MinMarginLeft 0
851 Property Integer MinMarginTop 0
852 Property Integer MinMarginRight 0
853 Property Integer MinMarginBottom 0
854 Property Integer MarginLeft 0
855 Property Integer MarginTop 0
856 Property Integer MarginRight 0
857 Property Integer MarginBottom 0
858 End_Procedure // Construct_Object
859
860 Import_Class_Protocol Print_Dialog_Mixin
861
862
863
864 // ************************************************************************ //
865 // ** ** //
866 // ** Function : PageSetupDialog ** //
867 // ** ** //
868 // ** Purpose : This function displays the Page Setup dialog box. ** //
869 // ** ** //
870 // ** Returns : If the user clicks the OK button, the return value is ** //
871 // ** non-zero (true). If the user cancels or closes the Page ** //
872 // ** Setup dialog or an error occurs, the return value is ** //
873 // ** zero (false). ** //
874 // ** ** //
875 // ************************************************************************ //
876
877 Function PageSetupDlg Returns Integer
878 Handle hDevMode hDevNames
879 Pointer pPageSetupDlg
880 String sPageSetupDlg
881 Integer iResult iFlags
882
883 // Make sure the Flags property contains valid flags
884 Get Flags To iFlags
885
886 // Filter unsupported flags
887 If (iFlags iAnd PSD_ENABLEPAGEPAINTHOOK) Move (iFlags - PSD_ENABLEPAGEPAINTHOOK) To iFlags
888 If (iFlags iAnd PSD_ENABLEPAGESETUPHOOK) Move (iFlags - PSD_ENABLEPAGESETUPHOOK) To iFlags
889 If (iFlags iAnd PSD_ENABLEPAGESETUPTEMPLATE) Move (iFlags - PSD_ENABLEPAGESETUPTEMPLATE) To iFlags
890 If (iFlags iAnd PSD_ENABLEPAGESETUPTEMPLATEHANDLE) Move (iFlags - PSD_ENABLEPAGESETUPTEMPLATEHANDLE) To iFlags
891
892 // If the PSD_RETURNDEFAULT flag is set the hDevMode and hDevNames must be zero
893 If ((iFlags iAnd PSD_RETURNDEFAULT) = 0) Begin
894 Get InitDevMode To hDevMode
895 Get InitDevNames To hDevNames
896 End // If ((iFlags iAnd PSD_RETURNDEFAULT) = 0) Begin
897
898 ZeroType PAGESETUPDLG to sPageSetupDlg
899 Put PAGESETUPDLG_Size to sPageSetupDlg at PAGESETUPDLG.lStructSize
900 Put (ParentWindowHandle(Self)) to sPageSetupDlg at PAGESETUPDLG.hwndOwner
901 Put hDevMode to sPageSetupDlg at PAGESETUPDLG.hDevMode
902 Put hDevNames to sPageSetupDlg at PAGESETUPDLG.hDevNames
903 Put iFlags to sPageSetupDlg at PAGESETUPDLG.Flags
904 Put (PaperSizeX(Self)) to sPageSetupDlg at PAGESETUPDLG.ptPaperSize.x
905 Put (PaperSizeY(Self)) to sPageSetupDlg at PAGESETUPDLG.ptPaperSize.y
906 Put (MinMarginLeft(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMinMargin.Left
907 Put (MinMarginTop(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMinMargin.Top
908 Put (MinMarginRight(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMinMargin.Right
909 Put (MinMarginBottom(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMinMargin.Bottom
910 Put (MarginLeft(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMargin.Left
911 Put (MarginTop(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMargin.Top
912 Put (MarginRight(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMargin.Right
913 Put (MarginBottom(Self)) to sPageSetupDlg at PAGESETUPDLG.rtMargin.Bottom
914
915 GetAddress Of sPageSetupDlg To pPageSetupDlg
916 Move (PageSetupDlg(pPageSetupDlg)) To iResult
917 If (iResult = 0) Begin
918 Move (CommDlgExtendedError()) To iResult
919 If (iResult <> 0) Function_Return iResult
920 Function_Return DFTrue
921 End // If (iResult = 0) Begin
922
923 GetBuff From sPageSetupDlg at PAGESETUPDLG.hDevNames to hDevNames
924 GetBuff From sPageSetupDlg at PAGESETUPDLG.hDevMode to hDevMode
925
926 Move (ReadDevNames(Self,hDevNames)) To iResult
927 Move (ReadDevMode(Self,hDevMode)) To iResult
928
929 // Retrieve flags
930 GetBuff from sPageSetupDlg at PAGESETUPDLG.Flags To iFlags
931 Set Flags To iFlags
932
933 // And other members
934 Set PaperSizeX To (BytesToDWord(sPageSetupDlg,21))
935 Set PaperSizeY To (BytesToDWord(sPageSetupDlg,25))
936 Set MinMarginLeft To (BytesToDWord(sPageSetupDlg,29))
937 Set MinMarginTop To (BytesToDWord(sPageSetupDlg,33))
938 Set MinMarginRight To (BytesToDWord(sPageSetupDlg,37))
939 Set MinMarginBottom To (BytesToDWord(sPageSetupDlg,41))
940 Set MarginLeft To (BytesToDWord(sPageSetupDlg,45))
941 Set MarginTop To (BytesToDWord(sPageSetupDlg,49))
942 Set MarginRight To (BytesToDWord(sPageSetupDlg,53))
943 Set MarginBottom To (BytesToDWord(sPageSetupDlg,57))
944
945 // Free the allocated memory
946 //If (GlobalFree(hDevMode)) Move (ShowLastError()) To iResult
947 //If (GlobalFree(hDevNames)) Move (ShowLastError()) To iResult
948
949 Function_Return DFFalse
950 End_Function // PageSetupDlg
951
952End_Class // PageSetupDlg
953
954// **************************************************************************** //
955// ** ** //
956// ** Class : PrintDialog ** //
957// ** ** //
958// ** Purpose : This class is a wrapper for the Print Setup dialog box. ** //
959// ** ** //
960// **************************************************************************** //
961
962{ ClassLibrary=Windows }
963{ HelpTopic=PrintDialog }
964Class PrintDialog Is A cObject
965
966 // ************************************************************************ //
967 // ** ** //
968 // ** Procedure : Construct_Object ** //
969 // ** ** //
970 // ** Purpose : Define some properties for the Print Setup dialog box. ** //
971 // ** ** //
972 // ************************************************************************ //
973
974 Procedure Construct_Object
975 Forward Send Construct_Object
976
977 Send Define_Print_Dialog
978
979 Property Handle DeviceContext 0
980 { Category=Behavior }
981 Property Integer Flags 0
982 { Category=Behavior }
983 Property Integer FromPage 0
984 { Category=Behavior }
985 Property Integer ToPage 0
986 { Category=Behavior }
987 Property Integer MinPage 0
988 { Category=Behavior }
989 Property Integer MaxPage 0
990 //Property Integer Copies 0
991 End_Procedure // Construct_Object
992
993 Import_Class_Protocol Print_Dialog_Mixin
994
995 // ************************************************************************ //
996 // ** ** //
997 // ** Function : PrintDlg ** //
998 // ** ** //
999 // ** Purpose : This function displays the Print Setup dialog box. ** //
1000 // ** ** //
1001 // ** Returns : If the user clicks the OK button, the return value is ** //
1002 // ** non-zero (true). If the user cancels or closes the ** //
1003 // ** Print Setup dialog or an error occurs, the return value ** //
1004 // ** is zero (false). ** //
1005 // ** ** //
1006 // ************************************************************************ //
1007
1008 Function PrintDialog Returns Integer
1009 Handle hDevMode hDevNames hDC
1010 Integer iResult iFlags
1011 Pointer pPrintDlg
1012 String sPrintDlg
1013
1014 // Make sure the Flags property contains valid flags
1015 Get Flags To iFlags
1016 Move (iFlags iOr PD_USEDEVMODECOPIES) To iFlags
1017
1018 // Filter unsupported flags
1019 If (iFlags iAnd PD_ENABLEPRINTHOOK) Move (iFlags - PD_ENABLEPRINTHOOK) To iFlags
1020 If (iFlags iAnd PD_ENABLEPRINTTEMPLATE) Move (iFlags - PD_ENABLEPRINTTEMPLATE) To iFlags
1021 If (iFlags iAnd PD_ENABLEPRINTTEMPLATEHANDLE) Move (iFlags - PD_ENABLEPRINTTEMPLATEHANDLE) To iFlags
1022 If (iFlags iAnd PD_ENABLESETUPHOOK) Move (iFlags - PD_ENABLESETUPHOOK) To iFlags
1023 If (iFlags iAnd PD_ENABLESETUPTEMPLATE) Move (iFlags - PD_ENABLESETUPTEMPLATE) To iFlags
1024 If (iFlags iAnd PD_ENABLESETUPTEMPLATEHANDLE) Move (iFlags - PD_ENABLESETUPTEMPLATEHANDLE) To iFlags
1025
1026 // If the PSD_RETURNDEFAULT flag is set the hDevMode and hDevNames must be zero
1027 If ((iFlags iAnd PSD_RETURNDEFAULT) = 0) Begin
1028 Get InitDevMode To hDevMode
1029 Get InitDevNames To hDevNames
1030 End // If ((iFlags iAnd PSD_RETURNDEFAULT) = 0) Begin
1031
1032 ZeroType PRINTDLG To sPrintDlg
1033 Put PRINTDLG_Size to sPrintDlg at PRINTDLG.lStructSize
1034 Put (ParentWindowHandle(Self)) to sPrintDlg at PRINTDLG.hwndOwner
1035 Put hDevMode to sPrintDlg at PRINTDLG.hDevMode
1036 Put hDevNames to sPrintDlg at PRINTDLG.hDevNames
1037 Put iFlags to sPrintDlg at PRINTDLG.Flags
1038 Put (FromPage(Self)) to sPrintDlg at PRINTDLG.nFromPage
1039 Put (ToPage(Self)) to sPrintDlg at PRINTDLG.nToPage
1040 Put (MinPage(Self)) to sPrintDlg at PRINTDLG.nMinPage
1041 Put (MaxPage(Self)) to sPrintDlg at PRINTDLG.nMaxPage
1042 Put (Copies(Self)) to sPrintDlg at PRINTDLG.nCopies
1043
1044 GetAddress Of sPrintDlg To pPrintDlg
1045 Move (PrintDlg(pPrintDlg)) To iResult
1046 If (iResult = 0) Begin
1047 Move (CommDlgExtendedError()) To iResult
1048 If (iResult <> 0) Function_Return iResult
1049 Function_Return DFTrue
1050 End // If (iResult = 0) Begin
1051
1052 GetBuff From sPrintDlg at PRINTDLG.hDevNames to hDevNames
1053 GetBuff From sPrintDlg at PRINTDLG.hDevMode to hDevMode
1054
1055 Move (ReadDevNames(Self,hDevNames)) To iResult
1056 Move (ReadDevMode(Self,hDevMode)) To iResult
1057
1058 // Retrieve the DC
1059 GetBuff from sPrintDlg at PRINTDLG.hDC to hDC
1060 Set DeviceContext To hDC
1061
1062 // Retrieve flags
1063 GetBuff from sPrintDlg at PRINTDLG.Flags To iFlags
1064 Set Flags To iFlags
1065
1066 // Retrieve other members
1067 Set FromPage to (BytesToShort(sPrintDlg,25))
1068 Set ToPage to (BytesToShort(sPrintDlg,27))
1069 Set MinPage to (BytesToShort(sPrintDlg,29))
1070 Set MaxPage to (BytesToShort(sPrintDlg,31))
1071 //Set Copies to (BytesToShort(sPrintDlg,33))
1072
1073 // Free the allocated memory
1074 //If (GlobalFree(hDevMode)) Move (ShowLastError()) To iResult
1075 //If (GlobalFree(hDevNames)) Move (ShowLastError()) To iResult
1076
1077 Function_Return DFFalse
1078 End_Function // PrintDialog
1079
1080End_Class // PrintDialog
1081