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 DEFAULT_DEBUG_CHANNEL(commdlg
)
28 /***********************************************************************
29 * PrintDlg16 (COMMDLG.20)
31 BOOL16 WINAPI
PrintDlg16( SEGPTR printdlg
)
37 LPPRINTDLG16 lpPrint
= (LPPRINTDLG16
)PTR_SEG_TO_LIN(printdlg
);
39 TRACE(commdlg
,"(%p) -- Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
41 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
42 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
45 if (lpPrint
->Flags
& PD_PRINTSETUP
)
46 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP
);
48 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT
);
50 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
51 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, TRUE
,
53 (DLGPROC16
)((lpPrint
->Flags
& PD_PRINTSETUP
) ?
54 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
55 MODULE_GetWndProcEntry16("PrintDlgProc")),
56 printdlg
, WIN_PROC_16
);
57 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpPrint
->hwndOwner
);
63 /***********************************************************************
64 * PrintDlgA (COMDLG32.17)
66 * Displays the the PRINT dialog box, which enables the user to specify
67 * specific properties of the print job.
69 * (Note: according to the MS Platform SDK, this call was in the past
70 * also used to display some PRINT SETUP dialog. As this is superseded
71 * by PageSetupDlg, this now results in an error!)
74 * nonzero if the user pressed the OK button
75 * zero if the user cancelled the window or an error occurred
78 * The function is a stub only, returning TRUE to allow more programs
81 BOOL WINAPI
PrintDlgA(
82 LPPRINTDLGA lppd
/* ptr to PRINTDLG32 struct */
85 /* My implementing strategy:
87 * step 1: display the dialog and implement the layout-flags
88 * step 2: enter valid information in the fields (e.g. real printers)
89 * step 3: fix the RETURN-TRUE-ALWAYS Fixme by checking lppd->Flags for
91 * step 4: implement all other specs
92 * step 5: allow customisation of the dialog box
94 * current implementation is in step 1.
99 LPCVOID ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_PRINT32
);
100 HINSTANCE hInst
= WIN_GetWindowInstance( lppd
->hwndOwner
);
102 FIXME(commdlg
, "KVG (%p): stub\n", lppd
);
105 * FIXME : Should respond to TEMPLATE and HOOK flags here
106 * For now, only the standard dialog works.
108 if (lppd
->Flags
& (PD_ENABLEPRINTHOOK
| PD_ENABLEPRINTTEMPLATE
|
109 PD_ENABLEPRINTTEMPLATEHANDLE
| PD_ENABLESETUPHOOK
|
110 PD_ENABLESETUPTEMPLATE
|PD_ENABLESETUPTEMPLATEHANDLE
))
111 FIXME(commdlg
, ": unimplemented flag (ignored)\n");
114 * if lppd->Flags PD_RETURNDEFAULT is specified, the PrintDlg function
115 * does not display the dialog box, but returns with valid entries
116 * for hDevMode and hDevNames .
118 * Currently the flag is recognised, but we return empty hDevMode and
119 * and hDevNames. This will be fixed when I am in step 3.
121 if (lppd
->Flags
& PD_RETURNDEFAULT
)
123 WARN(commdlg
, ": PrintDlg was requested to return printer info only."
124 "\n The return value currently does NOT provide these.\n");
125 COMDLG32_SetCommDlgExtendedError(PDERR_NODEVICES
);
126 /* return TRUE, thus never checked! */
130 if (lppd
->Flags
& PD_PRINTSETUP
)
132 FIXME(commdlg
, ": PrintDlg was requested to display PrintSetup box.\n");
133 COMDLG32_SetCommDlgExtendedError(PDERR_INITFAILURE
);
137 hwndDialog
= DIALOG_CreateIndirect(hInst
, ptr
, TRUE
, lppd
->hwndOwner
,
138 (DLGPROC16
)PrintDlgProcA
, (LPARAM
)lppd
, WIN_PROC_32A
);
140 bRet
= DIALOG_DoDialogBox(hwndDialog
, lppd
->hwndOwner
);
148 /***********************************************************************
149 * PrintDlg32W (COMDLG32.18)
151 BOOL WINAPI
PrintDlgW( LPPRINTDLGW printdlg
)
153 FIXME(commdlg
, "A really empty stub\n" );
159 /***********************************************************************
160 * PRINTDLG_WMInitDialog [internal]
162 LRESULT
PRINTDLG_WMInitDialog(HWND hDlg
, WPARAM wParam
, LPARAM lParam
,
165 SetWindowLongA(hDlg
, DWL_USER
, lParam
);
166 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
168 if (lppd
->lStructSize
!= sizeof(PRINTDLGA
))
170 FIXME(commdlg
,"structure size failure !!!\n");
171 /* EndDialog (hDlg, 0);
175 /* Flag processing to set the according buttons on/off and
176 * Initialise the various values
179 /* Print range (All/Range/Selection) */
180 if (lppd
->nMinPage
== lppd
->nMaxPage
)
181 lppd
->Flags
&= ~PD_NOPAGENUMS
;
182 /* FIXME: I allow more freedom than either Win95 or WinNT,
183 * as officially we should return error if
184 * ToPage or FromPage is out-of-range
186 if (lppd
->nToPage
< lppd
->nMinPage
)
187 lppd
->nToPage
= lppd
->nMinPage
;
188 if (lppd
->nToPage
> lppd
->nMaxPage
)
189 lppd
->nToPage
= lppd
->nMaxPage
;
190 if (lppd
->nFromPage
< lppd
->nMinPage
)
191 lppd
->nFromPage
= lppd
->nMinPage
;
192 if (lppd
->nFromPage
> lppd
->nMaxPage
)
193 lppd
->nFromPage
= lppd
->nMaxPage
;
194 SetDlgItemInt(hDlg
, edt2
, lppd
->nFromPage
, FALSE
);
195 SetDlgItemInt(hDlg
, edt3
, lppd
->nToPage
, FALSE
);
196 CheckRadioButton(hDlg
, rad1
, rad3
, rad1
);
197 if (lppd
->Flags
& PD_NOSELECTION
)
198 EnableWindow(GetDlgItem(hDlg
, rad3
), FALSE
);
200 if (lppd
->Flags
& PD_SELECTION
)
201 CheckRadioButton(hDlg
, rad1
, rad3
, rad3
);
202 if (lppd
->Flags
& PD_NOPAGENUMS
)
204 EnableWindow(GetDlgItem(hDlg
, rad2
), FALSE
);
205 EnableWindow(GetDlgItem(hDlg
, stc10
),FALSE
);
206 EnableWindow(GetDlgItem(hDlg
, edt2
), FALSE
);
207 EnableWindow(GetDlgItem(hDlg
, stc11
),FALSE
);
208 EnableWindow(GetDlgItem(hDlg
, edt3
), FALSE
);
212 if (lppd
->Flags
& PD_PAGENUMS
)
213 CheckRadioButton(hDlg
, rad1
, rad3
, rad2
);
215 /* FIXME: in Win95, the radiobutton "All" is displayed as
216 * "Print all xxx pages"... This is not done here (yet?)
220 if (lppd
->Flags
& PD_COLLATE
)
221 FIXME(commdlg
, "PD_COLLATE not implemented yet\n");
224 CheckDlgButton(hDlg
, chx1
, (lppd
->Flags
& PD_PRINTTOFILE
) ? 1 : 0);
225 if (lppd
->Flags
& PD_DISABLEPRINTTOFILE
)
226 EnableWindow(GetDlgItem(hDlg
, chx1
), FALSE
);
227 if (lppd
->Flags
& PD_HIDEPRINTTOFILE
)
228 ShowWindow(GetDlgItem(hDlg
, chx1
), SW_HIDE
);
232 TRACE(commdlg
, "succesful!\n");
237 /***********************************************************************
238 * PRINTDLG_ValidateAndDuplicateSettings [internal]
240 BOOL
PRINTDLG_ValidateAndDuplicateSettings(HWND hDlg
, LPPRINTDLGA lppd
)
244 char TempBuffer
[256];
246 /* check whether nFromPage and nToPage are within range defined by
247 * nMinPage and nMaxPage
249 /* FIXMNo checking on rad2 is performed now, because IsDlgButtonCheck
250 * currently doesn't seem to know a state BST_CHECKED
252 /* if (IsDlgButtonChecked(hDlg, rad2) == BST_CHECKED) */
254 nFromPage
= GetDlgItemInt(hDlg
, edt2
, NULL
, FALSE
);
255 nToPage
= GetDlgItemInt(hDlg
, edt3
, NULL
, FALSE
);
256 if (nFromPage
< lppd
->nMinPage
|| nFromPage
> lppd
->nMaxPage
||
257 nToPage
< lppd
->nMinPage
|| nToPage
> lppd
->nMaxPage
)
259 FIXME(commdlg
, "The MessageBox is not internationalised.");
260 sprintf(TempBuffer
, "This value lies not within Page range\n"
261 "Please enter a value between %d and %d",
262 lppd
->nMinPage
, lppd
->nMaxPage
);
263 MessageBoxA(hDlg
, TempBuffer
, "Print", MB_OK
| MB_ICONWARNING
);
266 lppd
->nFromPage
= nFromPage
;
267 lppd
->nToPage
= nToPage
;
275 /***********************************************************************
276 * PRINTDLG_WMCommand [internal]
278 static LRESULT
PRINTDLG_WMCommand(HWND hDlg
, WPARAM wParam
,
279 LPARAM lParam
, LPPRINTDLGA lppd
)
284 if (PRINTDLG_ValidateAndDuplicateSettings(hDlg
, lppd
) != TRUE
)
286 MessageBoxA(hDlg
, "OK was hit!", NULL
, MB_OK
);
290 MessageBoxA(hDlg
, "CANCEL was hit!", NULL
, MB_OK
);
291 EndDialog(hDlg
, FALSE
);
292 /* DestroyWindow(hDlg); */
300 /***********************************************************************
301 * PrintDlgProcA [internal]
303 LRESULT WINAPI
PrintDlgProcA(HWND hDlg
, UINT uMsg
, WPARAM wParam
,
308 if (uMsg
!=WM_INITDIALOG
)
310 lppd
=(LPPRINTDLGA
)GetWindowLongA(hDlg
, DWL_USER
);
316 lppd
=(LPPRINTDLGA
)lParam
;
317 if (!PRINTDLG_WMInitDialog(hDlg
, wParam
, lParam
, lppd
))
319 TRACE(commdlg
, "PRINTDLG_WMInitDialog returned FALSE\n");
322 MessageBoxA(hDlg
,"Warning: this dialog has no functionality yet!",
328 return PRINTDLG_WMCommand(hDlg
, wParam
, lParam
, lppd
);
342 /***********************************************************************
343 * PrintDlgProc16 (COMMDLG.21)
345 LRESULT WINAPI
PrintDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
351 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
352 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
358 EndDialog(hWnd
, TRUE
);
361 EndDialog(hWnd
, FALSE
);
370 /***********************************************************************
371 * PrintSetupDlgProc (COMMDLG.22)
373 LRESULT WINAPI
PrintSetupDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
379 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
380 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
385 EndDialog(hWnd
, TRUE
);
388 EndDialog(hWnd
, FALSE
);
399 /***********************************************************************
400 * PageSetupDlgA (COMDLG32.15)
402 BOOL WINAPI
PageSetupDlgA(LPPAGESETUPDLGA setupdlg
) {
403 FIXME(commdlg
,"(%p), stub!\n",setupdlg
);