2 * COMMDLG - Print Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 * Copyright 1999 Klaas van Gend
13 #include "wine/winbase16.h"
14 #include "wine/winuser16.h"
26 /***********************************************************************
27 * PrintDlg16 (COMMDLG.20)
29 BOOL16 WINAPI
PrintDlg16( SEGPTR printdlg
)
35 LPPRINTDLG16 lpPrint
= (LPPRINTDLG16
)PTR_SEG_TO_LIN(printdlg
);
37 TRACE(commdlg
,"(%p) -- Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
39 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
40 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
43 if (lpPrint
->Flags
& PD_PRINTSETUP
)
44 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP
);
46 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT
);
48 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
49 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, TRUE
,
51 (DLGPROC16
)((lpPrint
->Flags
& PD_PRINTSETUP
) ?
52 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
53 MODULE_GetWndProcEntry16("PrintDlgProc")),
54 printdlg
, WIN_PROC_16
);
55 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpPrint
->hwndOwner
);
61 /***********************************************************************
62 * PrintDlgA (COMDLG32.17)
64 * Displays the the PRINT dialog box, which enables the user to specify
65 * specific properties of the print job.
67 * (Note: according to the MS Platform SDK, this call was in the past
68 * also used to display some PRINT SETUP dialog. As this is superseded
69 * by PageSetupDlg, this now results in an error!)
72 * nonzero if the user pressed the OK button
73 * zero if the user cancelled the window or an error occurred
76 * The function is a stub only, returning TRUE to allow more programs
79 BOOL WINAPI
PrintDlgA(
80 LPPRINTDLGA lppd
/* ptr to PRINTDLG32 struct */
83 /* My implementing strategy:
85 * step 1: display the dialog and implement the layout-flags
86 * step 2: enter valid information in the fields (e.g. real printers)
87 * step 3: fix the RETURN-TRUE-ALWAYS Fixme by checking lppd->Flags for
89 * step 4: implement all other specs
90 * step 5: allow customisation of the dialog box
92 * current implementation is in step 1.
97 LPCVOID ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_PRINT32
);
98 HINSTANCE hInst
= WIN_GetWindowInstance( lppd
->hwndOwner
);
100 FIXME(commdlg
, "KVG (%p): stub\n", lppd
);
103 * FIXME : Should respond to TEMPLATE and HOOK flags here
104 * For now, only the standard dialog works.
106 if (lppd
->Flags
& (PD_ENABLEPRINTHOOK
| PD_ENABLEPRINTTEMPLATE
|
107 PD_ENABLEPRINTTEMPLATEHANDLE
| PD_ENABLESETUPHOOK
|
108 PD_ENABLESETUPTEMPLATE
|PD_ENABLESETUPTEMPLATEHANDLE
))
109 FIXME(commdlg
, ": unimplemented flag (ignored)\n");
112 * if lppd->Flags PD_RETURNDEFAULT is specified, the PrintDlg function
113 * does not display the dialog box, but returns with valid entries
114 * for hDevMode and hDevNames .
116 * Currently the flag is recognised, but we return empty hDevMode and
117 * and hDevNames. This will be fixed when I am in step 3.
119 if (lppd
->Flags
& PD_RETURNDEFAULT
)
121 WARN(commdlg
, ": PrintDlg was requested to return printer info only."
122 "\n The return value currently does NOT provide these.\n");
123 COMDLG32_SetCommDlgExtendedError(PDERR_NODEVICES
);
124 /* return TRUE, thus never checked! */
128 if (lppd
->Flags
& PD_PRINTSETUP
)
130 FIXME(commdlg
, ": PrintDlg was requested to display PrintSetup box.\n");
131 COMDLG32_SetCommDlgExtendedError(PDERR_INITFAILURE
);
135 hwndDialog
= DIALOG_CreateIndirect(hInst
, ptr
, TRUE
, lppd
->hwndOwner
,
136 (DLGPROC16
)PrintDlgProcA
, (LPARAM
)lppd
, WIN_PROC_32A
);
138 bRet
= DIALOG_DoDialogBox(hwndDialog
, lppd
->hwndOwner
);
146 /***********************************************************************
147 * PrintDlg32W (COMDLG32.18)
149 BOOL WINAPI
PrintDlgW( LPPRINTDLGW printdlg
)
151 FIXME(commdlg
, "A really empty stub\n" );
157 /***********************************************************************
158 * PRINTDLG_WMInitDialog [internal]
160 LRESULT
PRINTDLG_WMInitDialog(HWND hDlg
, WPARAM wParam
, LPARAM lParam
,
163 SetWindowLongA(hDlg
, DWL_USER
, lParam
);
164 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
166 if (lppd
->lStructSize
!= sizeof(PRINTDLGA
))
168 FIXME(commdlg
,"structure size failure !!!\n");
169 /* EndDialog (hDlg, 0);
173 /* Flag processing to set the according buttons on/off and
174 * Initialise the various values
177 /* Print range (All/Range/Selection) */
178 if (lppd
->nMinPage
== lppd
->nMaxPage
)
179 lppd
->Flags
&= ~PD_NOPAGENUMS
;
180 /* FIXME: I allow more freedom than either Win95 or WinNT,
181 * as officially we should return error if
182 * ToPage or FromPage is out-of-range
184 if (lppd
->nToPage
< lppd
->nMinPage
)
185 lppd
->nToPage
= lppd
->nMinPage
;
186 if (lppd
->nToPage
> lppd
->nMaxPage
)
187 lppd
->nToPage
= lppd
->nMaxPage
;
188 if (lppd
->nFromPage
< lppd
->nMinPage
)
189 lppd
->nFromPage
= lppd
->nMinPage
;
190 if (lppd
->nFromPage
> lppd
->nMaxPage
)
191 lppd
->nFromPage
= lppd
->nMaxPage
;
192 SetDlgItemInt(hDlg
, edt2
, lppd
->nFromPage
, FALSE
);
193 SetDlgItemInt(hDlg
, edt3
, lppd
->nToPage
, FALSE
);
194 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
);
195 if (lppd
->Flags
& PD_NOSELECTION
)
196 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
198 if (lppd
->Flags
& PD_SELECTION
)
199 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
200 if (lppd
->Flags
& PD_NOPAGENUMS
)
202 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
203 EnableWindow(GetDlgItem(hDlg
, stc10
),FALSE
);
204 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
205 EnableWindow(GetDlgItem(hDlg
, stc11
),FALSE
);
206 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
210 if (lppd
->Flags
& PD_PAGENUMS
)
211 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
213 /* FIXME: in Win95, the radiobutton "All" is displayed as
214 * "Print all xxx pages"... This is not done here (yet?)
218 if (lppd
->Flags
& PD_COLLATE
)
219 FIXME(commdlg
, "PD_COLLATE not implemented yet\n");
222 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
223 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
224 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
225 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
226 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
230 TRACE(commdlg
, "succesful!\n");
235 /***********************************************************************
236 * PRINTDLG_ValidateAndDuplicateSettings [internal]
238 BOOL
PRINTDLG_ValidateAndDuplicateSettings(HWND hDlg
, LPPRINTDLGA lppd
)
242 char TempBuffer
[256];
244 /* check whether nFromPage and nToPage are within range defined by
245 * nMinPage and nMaxPage
247 /* FIXMNo checking on rad2 is performed now, because IsDlgButtonCheck
248 * currently doesn't seem to know a state BST_CHECKED
250 /* if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) */
252 nFromPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
253 nToPage
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
254 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
255 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
)
257 FIXME(commdlg
, "The MessageBox is not internationalised.");
258 sprintf(TempBuffer
, "This value lies not within Page range\n"
259 "Please enter a value between %d and %d",
260 lppd
->nMinPage
, lppd
->nMaxPage
);
261 MessageBoxA(hDlg
, TempBuffer
, "Print", MB_OK
| MB_ICONWARNING
);
264 lppd
->nFromPage
= nFromPage
;
265 lppd
->nToPage
= nToPage
;
273 /***********************************************************************
274 * PRINTDLG_WMCommand [internal]
276 static LRESULT
PRINTDLG_WMCommand(HWND hDlg
, WPARAM wParam
,
277 LPARAM lParam
, LPPRINTDLGA lppd
)
282 if (PRINTDLG_ValidateAndDuplicateSettings(hDlg
, lppd
) != TRUE
)
284 MessageBoxA(hDlg
, "OK was hit!", NULL
, MB_OK
);
288 MessageBoxA(hDlg
, "CANCEL was hit!", NULL
, MB_OK
);
289 EndDialog(hDlg
, FALSE
);
290 /* DestroyWindow(hDlg); */
298 /***********************************************************************
299 * PrintDlgProcA [internal]
301 LRESULT WINAPI
PrintDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
306 if (uMsg
!=WM_INITDIALOG
)
308 lppd
=(LPPRINTDLGA
)GetWindowLongA(hDlg
, DWL_USER
);
314 lppd
=(LPPRINTDLGA
)lParam
;
315 if (!PRINTDLG_WMInitDialog(hDlg
, wParam
, lParam
, lppd
))
317 TRACE(commdlg
, "PRINTDLG_WMInitDialog returned FALSE\n");
320 MessageBoxA(hDlg
,"Warning: this dialog has no functionality yet!",
326 return PRINTDLG_WMCommand(hDlg
, wParam
, lParam
, lppd
);
340 /***********************************************************************
341 * PrintDlgProc16 (COMMDLG.21)
343 LRESULT WINAPI
PrintDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
349 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
350 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
356 EndDialog(hWnd
, TRUE
);
359 EndDialog(hWnd
, FALSE
);
368 /***********************************************************************
369 * PrintSetupDlgProc (COMMDLG.22)
371 LRESULT WINAPI
PrintSetupDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
377 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
378 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
383 EndDialog(hWnd
, TRUE
);
386 EndDialog(hWnd
, FALSE
);
397 /***********************************************************************
398 * PageSetupDlgA (COMDLG32.15)
400 BOOL WINAPI
PageSetupDlgA(LPPAGESETUPDLGA setupdlg
) {
401 FIXME(commdlg
,"(%p), stub!\n",setupdlg
);