1 /***********************************************************************\
2 *                               commdlg.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *             Translated from MinGW API for MS-Windows 3.12             *
7 *                                                                       *
8 *                       Placed into public domain                       *
9 \***********************************************************************/
10 module win32.commdlg;
11 pragma(lib, "comdlg32.lib");
12 
13 private import win32.w32api;
14 import win32.windef, win32.winuser;
15 import win32.wingdi; // for LPLOGFONTA
16 
17 const TCHAR[]
18 	LBSELCHSTRING = "commdlg_LBSelChangedNotify",
19 	SHAREVISTRING = "commdlg_ShareViolation",
20 	FILEOKSTRING  = "commdlg_FileNameOK",
21 	COLOROKSTRING = "commdlg_ColorOK",
22 	SETRGBSTRING  = "commdlg_SetRGBColor",
23 	HELPMSGSTRING = "commdlg_help",
24 	FINDMSGSTRING = "commdlg_FindReplace";
25 
26 enum : UINT {
27 	CDN_FIRST          = -601, // also in commctrl.h
28 	CDN_LAST           = -699,
29 	CDN_INITDONE       = CDN_FIRST,
30 	CDN_SELCHANGE      = CDN_FIRST - 1,
31 	CDN_FOLDERCHANGE   = CDN_FIRST - 2,
32 	CDN_SHAREVIOLATION = CDN_FIRST - 3,
33 	CDN_HELP           = CDN_FIRST - 4,
34 	CDN_FILEOK         = CDN_FIRST - 5,
35 	CDN_TYPECHANGE     = CDN_FIRST - 6
36 }
37 
38 enum : UINT {
39 	CDM_FIRST           = WM_USER + 100,
40 	CDM_LAST            = WM_USER + 200,
41 	CDM_GETSPEC         = CDM_FIRST,
42 	CDM_GETFILEPATH,
43 	CDM_GETFOLDERPATH,
44 	CDM_GETFOLDERIDLIST,
45 	CDM_SETCONTROLTEXT,
46 	CDM_HIDECONTROL,
47 	CDM_SETDEFEXT    // = CDM_FIRST + 6
48 }
49 
50 // flags for ChooseColor
51 enum : DWORD {
52 	CC_RGBINIT              = 0x0001,
53 	CC_FULLOPEN             = 0x0002,
54 	CC_PREVENTFULLOPEN      = 0x0004,
55 	CC_SHOWHELP             = 0x0008,
56 	CC_ENABLEHOOK           = 0x0010,
57 	CC_ENABLETEMPLATE       = 0x0020,
58 	CC_ENABLETEMPLATEHANDLE = 0x0040,
59 	CC_SOLIDCOLOR           = 0x0080,
60 	CC_ANYCOLOR             = 0x0100
61 }
62 
63 // flags for ChooseFont
64 enum : DWORD {
65 	CF_SCREENFONTS          = 0x00000001,
66 	CF_PRINTERFONTS         = 0x00000002,
67 	CF_BOTH                 = 0x00000003,
68 	CF_SHOWHELP             = 0x00000004,
69 	CF_ENABLEHOOK           = 0x00000008,
70 	CF_ENABLETEMPLATE       = 0x00000010,
71 	CF_ENABLETEMPLATEHANDLE = 0x00000020,
72 	CF_INITTOLOGFONTSTRUCT  = 0x00000040,
73 	CF_USESTYLE             = 0x00000080,
74 	CF_EFFECTS              = 0x00000100,
75 	CF_APPLY                = 0x00000200,
76 	CF_ANSIONLY             = 0x00000400,
77 	CF_SCRIPTSONLY          = CF_ANSIONLY,
78 	CF_NOVECTORFONTS        = 0x00000800,
79 	CF_NOOEMFONTS           = 0x00000800,
80 	CF_NOSIMULATIONS        = 0x00001000,
81 	CF_LIMITSIZE            = 0x00002000,
82 	CF_FIXEDPITCHONLY       = 0x00004000,
83 	CF_WYSIWYG              = 0x00008000,
84 	CF_FORCEFONTEXIST       = 0x00010000,
85 	CF_SCALABLEONLY         = 0x00020000,
86 	CF_TTONLY               = 0x00040000,
87 	CF_NOFACESEL            = 0x00080000,
88 	CF_NOSTYLESEL           = 0x00100000,
89 	CF_NOSIZESEL            = 0x00200000,
90 	CF_SELECTSCRIPT         = 0x00400000,
91 	CF_NOSCRIPTSEL          = 0x00800000,
92 	CF_NOVERTFONTS          = 0x01000000
93 }
94 
95 // Font type for ChooseFont
96 enum : WORD {
97 	BOLD_FONTTYPE      = 0x0100,
98 	ITALIC_FONTTYPE    = 0x0200,
99 	REGULAR_FONTTYPE   = 0x0400,
100 	SCREEN_FONTTYPE    = 0x2000,
101 	PRINTER_FONTTYPE   = 0x4000,
102 	SIMULATED_FONTTYPE = 0x8000
103 }
104 
105 enum : UINT {
106 	WM_CHOOSEFONT_GETLOGFONT = WM_USER +   1,
107 	WM_CHOOSEFONT_SETLOGFONT = WM_USER + 101,
108 	WM_CHOOSEFONT_SETFLAGS   = WM_USER + 102
109 }
110 
111 // flags for OpenFileName
112 enum : DWORD {
113 	OFN_SHAREWARN            = 0,
114 	OFN_SHARENOWARN          = 0x000001,
115 	OFN_READONLY             = 0x000001,
116 	OFN_SHAREFALLTHROUGH     = 0x000002,
117 	OFN_OVERWRITEPROMPT      = 0x000002,
118 	OFN_HIDEREADONLY         = 0x000004,
119 	OFN_NOCHANGEDIR          = 0x000008,
120 	OFN_SHOWHELP             = 0x000010,
121 	OFN_ENABLEHOOK           = 0x000020,
122 	OFN_ENABLETEMPLATE       = 0x000040,
123 	OFN_ENABLETEMPLATEHANDLE = 0x000080,
124 	OFN_NOVALIDATE           = 0x000100,
125 	OFN_ALLOWMULTISELECT     = 0x000200,
126 	OFN_EXTENSIONDIFFERENT   = 0x000400,
127 	OFN_PATHMUSTEXIST        = 0x000800,
128 	OFN_FILEMUSTEXIST        = 0x001000,
129 	OFN_CREATEPROMPT         = 0x002000,
130 	OFN_SHAREAWARE           = 0x004000,
131 	OFN_NOREADONLYRETURN     = 0x008000,
132 	OFN_NOTESTFILECREATE     = 0x010000,
133 	OFN_NONETWORKBUTTON      = 0x020000,
134 	OFN_NOLONGNAMES          = 0x040000,
135 	OFN_EXPLORER             = 0x080000,
136 	OFN_NODEREFERENCELINKS   = 0x100000,
137 	OFN_LONGNAMES            = 0x200000,
138 	OFN_ENABLESIZING         = 0x800000
139 }
140 
141 enum : DWORD {
142 	FR_DOWN                 = 0x00000001,
143 	FR_WHOLEWORD            = 0x00000002,
144 	FR_MATCHCASE            = 0x00000004,
145 	FR_FINDNEXT             = 0x00000008,
146 	FR_REPLACE              = 0x00000010,
147 	FR_REPLACEALL           = 0x00000020,
148 	FR_DIALOGTERM           = 0x00000040,
149 	FR_SHOWHELP             = 0x00000080,
150 	FR_ENABLEHOOK           = 0x00000100,
151 	FR_ENABLETEMPLATE       = 0x00000200,
152 	FR_NOUPDOWN             = 0x00000400,
153 	FR_NOMATCHCASE          = 0x00000800,
154 	FR_NOWHOLEWORD          = 0x00001000,
155 	FR_ENABLETEMPLATEHANDLE = 0x00002000,
156 	FR_HIDEUPDOWN           = 0x00004000,
157 	FR_HIDEMATCHCASE        = 0x00008000,
158 	FR_HIDEWHOLEWORD        = 0x00010000,
159 	FR_MATCHDIAC            = 0x20000000,
160 	FR_MATCHKASHIDA         = 0x40000000,
161 	FR_MATCHALEFHAMZA       = 0x80000000
162 }
163 
164 enum : DWORD {
165 	PD_ALLPAGES                   = 0,
166 	PD_SELECTION                  = 0x000001,
167 	PD_PAGENUMS                   = 0x000002,
168 	PD_NOSELECTION                = 0x000004,
169 	PD_NOPAGENUMS                 = 0x000008,
170 	PD_COLLATE                    = 0x000010,
171 	PD_PRINTTOFILE                = 0x000020,
172 	PD_PRINTSETUP                 = 0x000040,
173 	PD_NOWARNING                  = 0x000080,
174 	PD_RETURNDC                   = 0x000100,
175 	PD_RETURNIC                   = 0x000200,
176 	PD_RETURNDEFAULT              = 0x000400,
177 	PD_SHOWHELP                   = 0x000800,
178 	PD_ENABLEPRINTHOOK            = 0x001000,
179 	PD_ENABLESETUPHOOK            = 0x002000,
180 	PD_ENABLEPRINTTEMPLATE        = 0x004000,
181 	PD_ENABLESETUPTEMPLATE        = 0x008000,
182 	PD_ENABLEPRINTTEMPLATEHANDLE  = 0x010000,
183 	PD_ENABLESETUPTEMPLATEHANDLE  = 0x020000,
184 	PD_USEDEVMODECOPIES           = 0x040000,
185 	PD_USEDEVMODECOPIESANDCOLLATE = 0x040000,
186 	PD_DISABLEPRINTTOFILE         = 0x080000,
187 	PD_HIDEPRINTTOFILE            = 0x100000,
188 	PD_NONETWORKBUTTON            = 0x200000
189 }
190 
191 static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
192 	enum : DWORD {
193 		PD_CURRENTPAGE      = 0x00400000,
194 		PD_NOCURRENTPAGE    = 0x00800000,
195 		PD_EXCLUSIONFLAGS   = 0x01000000,
196 		PD_USELARGETEMPLATE = 0x10000000,
197 	}
198 
199 	enum : HRESULT {
200 		PD_RESULT_CANCEL,
201 		PD_RESULT_PRINT,
202 		PD_RESULT_APPLY
203 	}
204 
205 	const DWORD START_PAGE_GENERAL = 0xFFFFFFFF;
206 }
207 
208 enum {
209 	PSD_DEFAULTMINMARGINS             = 0,
210 	PSD_INWININIINTLMEASURE           = 0,
211 	PSD_MINMARGINS                    = 0x000001,
212 	PSD_MARGINS                       = 0x000002,
213 	PSD_INTHOUSANDTHSOFINCHES         = 0x000004,
214 	PSD_INHUNDREDTHSOFMILLIMETERS     = 0x000008,
215 	PSD_DISABLEMARGINS                = 0x000010,
216 	PSD_DISABLEPRINTER                = 0x000020,
217 	PSD_NOWARNING                     = 0x000080,
218 	PSD_DISABLEORIENTATION            = 0x000100,
219 	PSD_DISABLEPAPER                  = 0x000200,
220 	PSD_RETURNDEFAULT                 = 0x000400,
221 	PSD_SHOWHELP                      = 0x000800,
222 	PSD_ENABLEPAGESETUPHOOK           = 0x002000,
223 	PSD_ENABLEPAGESETUPTEMPLATE       = 0x008000,
224 	PSD_ENABLEPAGESETUPTEMPLATEHANDLE = 0x020000,
225 	PSD_ENABLEPAGEPAINTHOOK           = 0x040000,
226 	PSD_DISABLEPAGEPAINTING           = 0x080000
227 }
228 
229 enum : UINT {
230 	WM_PSD_PAGESETUPDLG = WM_USER,
231 	WM_PSD_FULLPAGERECT,
232 	WM_PSD_MINMARGINRECT,
233 	WM_PSD_MARGINRECT,
234 	WM_PSD_GREEKTEXTRECT,
235 	WM_PSD_ENVSTAMPRECT,
236 	WM_PSD_YAFULLPAGERECT // = WM_USER + 6
237 }
238 
239 enum : int {
240 	CD_LBSELNOITEMS = -1,
241 	CD_LBSELCHANGE,
242 	CD_LBSELSUB,
243 	CD_LBSELADD
244 }
245 
246 const WORD DN_DEFAULTPRN = 1;
247 
248 /+
249 // Both MinGW and the windows docs indicate that there are macros for the send messages
250 // the controls. These seem to be totally unnecessary -- and at least one of MinGW or
251 // Windows Docs is buggy!
252 
253 int CommDlg_OpenSave_GetSpec(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
254 	return SendMessage(hWndControl, CDM_GETSPEC, wParam, lParam);
255 }
256 
257 int CommDlg_OpenSave_GetFilePath(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
258 	return SendMessage(hWndControl, CDM_GETFILEPATH, wParam, lParam);
259 }
260 
261 int CommDlg_OpenSave_GetFolderPath(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
262 	return SendMessage(hWndControl, CDM_GETFOLDERPATH, wParam, lParam);
263 }
264 
265 int CommDlg_OpenSave_GetFolderIDList(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
266 	return SendMessage(hWndControl, CDM_GETFOLDERIDLIST, wParam, lParam);
267 }
268 
269 void CommDlg_OpenSave_SetControlText(HWND hWndControl, LPARAM lparam, WPARAM wParam) {
270 	return SendMessage(hWndControl, CDM_SETCONTROLTEXT, wParam, lParam);
271 }
272 
273 void CommDlg_OpenSave_HideControl(HWND hWndControl, WPARAM wParam) {
274 	return SendMessage(hWndControl, CDM_HIDECONTROL, wParam, 0);
275 }
276 
277 void CommDlg_OpenSave_SetDefExt(HWND hWndControl, TCHAR* lparam) {
278 	return SendMessage(hWndControl, CDM_SETCONTROLTEXT, 0, cast(LPARAM)lParam);
279 }
280 
281 // These aliases seem even more unnecessary
282 alias CommDlg_OpenSave_GetSpec
283 	CommDlg_OpenSave_GetSpecA, CommDlg_OpenSave_GetSpecW;
284 alias CommDlg_OpenSave_GetFilePath
285 	CommDlg_OpenSave_GetFilePathA, CommDlg_OpenSave_GetFilePathW;
286 alias CommDlg_OpenSave_GetFolderPath
287 	CommDlg_OpenSave_GetFolderPathA, CommDlg_OpenSave_GetFolderPathW;
288 +/
289 
290 // Callbacks.
291 extern(Windows) {
292 alias UINT function (HWND, UINT, WPARAM, LPARAM)
293 	LPCCHOOKPROC, LPCFHOOKPROC, LPFRHOOKPROC, LPOFNHOOKPROC,
294 	LPPAGEPAINTHOOK, LPPAGESETUPHOOK, LPSETUPHOOKPROC, LPPRINTHOOKPROC;
295 }
296 
297 align (1):
298 
299 struct CHOOSECOLORA {
300 	DWORD        lStructSize = CHOOSECOLORA.sizeof;
301 	HWND         hwndOwner;
302 	HWND         hInstance;
303 	COLORREF     rgbResult;
304 	COLORREF*    lpCustColors;
305 	DWORD        Flags;
306 	LPARAM       lCustData;
307 	LPCCHOOKPROC lpfnHook;
308 	LPCSTR       lpTemplateName;
309 }
310 alias CHOOSECOLORA* LPCHOOSECOLORA;
311 
312 struct CHOOSECOLORW {
313 	DWORD        lStructSize = CHOOSECOLORW.sizeof;
314 	HWND         hwndOwner;
315 	HWND         hInstance;
316 	COLORREF     rgbResult;
317 	COLORREF*    lpCustColors;
318 	DWORD        Flags;
319 	LPARAM       lCustData;
320 	LPCCHOOKPROC lpfnHook;
321 	LPCWSTR      lpTemplateName;
322 }
323 alias CHOOSECOLORW* LPCHOOSECOLORW;
324 
325 align (4) struct CHOOSEFONTA {
326 	DWORD        lStructSize = CHOOSEFONTA.sizeof;
327 	HWND         hwndOwner;
328 	HDC          hDC;
329 	LPLOGFONTA   lpLogFont;
330 	INT          iPointSize;
331 	DWORD        Flags;
332 	DWORD        rgbColors;
333 	LPARAM       lCustData;
334 	LPCFHOOKPROC lpfnHook;
335 	LPCSTR       lpTemplateName;
336 	HINSTANCE    hInstance;
337 	LPSTR        lpszStyle;
338 	WORD         nFontType;
339 	//WORD         ___MISSING_ALIGNMENT__;
340 	INT          nSizeMin;
341 	INT          nSizeMax;
342 }
343 alias CHOOSEFONTA* LPCHOOSEFONTA;
344 
345 align (4) struct CHOOSEFONTW {
346 	DWORD        lStructSize = CHOOSEFONTW.sizeof;
347 	HWND         hwndOwner;
348 	HDC          hDC;
349 	LPLOGFONTW   lpLogFont;
350 	INT          iPointSize;
351 	DWORD        Flags;
352 	DWORD        rgbColors;
353 	LPARAM       lCustData;
354 	LPCFHOOKPROC lpfnHook;
355 	LPCWSTR      lpTemplateName;
356 	HINSTANCE    hInstance;
357 	LPWSTR       lpszStyle;
358 	WORD         nFontType;
359 	//WORD         ___MISSING_ALIGNMENT__;
360 	INT          nSizeMin;
361 	INT          nSizeMax;
362 }
363 alias CHOOSEFONTW* LPCHOOSEFONTW;
364 
365 struct DEVNAMES {
366 	WORD wDriverOffset;
367 	WORD wDeviceOffset;
368 	WORD wOutputOffset;
369 	WORD wDefault;
370 }
371 alias DEVNAMES* LPDEVNAMES;
372 
373 struct FINDREPLACEA {
374 	DWORD        lStructSize = FINDREPLACEA.sizeof;
375 	HWND         hwndOwner;
376 	HINSTANCE    hInstance;
377 	DWORD        Flags;
378 	LPSTR        lpstrFindWhat;
379 	LPSTR        lpstrReplaceWith;
380 	WORD         wFindWhatLen;
381 	WORD         wReplaceWithLen;
382 	LPARAM       lCustData;
383 	LPFRHOOKPROC lpfnHook;
384 	LPCSTR       lpTemplateName;
385 }
386 alias FINDREPLACEA* LPFINDREPLACEA;
387 
388 struct FINDREPLACEW {
389 	DWORD        lStructSize = FINDREPLACEW.sizeof;
390 	HWND         hwndOwner;
391 	HINSTANCE    hInstance;
392 	DWORD        Flags;
393 	LPWSTR       lpstrFindWhat;
394 	LPWSTR       lpstrReplaceWith;
395 	WORD         wFindWhatLen;
396 	WORD         wReplaceWithLen;
397 	LPARAM       lCustData;
398 	LPFRHOOKPROC lpfnHook;
399 	LPCWSTR      lpTemplateName;
400 }
401 alias FINDREPLACEW* LPFINDREPLACEW;
402 
403 struct OPENFILENAMEA {
404 	DWORD         lStructSize = OPENFILENAMEA.sizeof;
405 	HWND          hwndOwner;
406 	HINSTANCE     hInstance;
407 	LPCSTR        lpstrFilter;
408 	LPSTR         lpstrCustomFilter;
409 	DWORD         nMaxCustFilter;
410 	DWORD         nFilterIndex;
411 	LPSTR         lpstrFile;
412 	DWORD         nMaxFile;
413 	LPSTR         lpstrFileTitle;
414 	DWORD         nMaxFileTitle;
415 	LPCSTR        lpstrInitialDir;
416 	LPCSTR        lpstrTitle;
417 	DWORD         Flags;
418 	WORD          nFileOffset;
419 	WORD          nFileExtension;
420 	LPCSTR        lpstrDefExt;
421 	DWORD         lCustData;
422 	LPOFNHOOKPROC lpfnHook;
423 	LPCSTR        lpTemplateName;
424     
425     static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x0500) {
426         void          *pvReserved;
427         DWORD         dwReserved;
428         DWORD         FlagsEx;
429     }    
430 }
431 alias OPENFILENAMEA* LPOPENFILENAMEA;
432 
433 struct OPENFILENAMEW {
434 	DWORD         lStructSize = OPENFILENAMEW.sizeof;
435 	HWND          hwndOwner;
436 	HINSTANCE     hInstance;
437 	LPCWSTR       lpstrFilter;
438 	LPWSTR        lpstrCustomFilter;
439 	DWORD         nMaxCustFilter;
440 	DWORD         nFilterIndex;
441 	LPWSTR        lpstrFile;
442 	DWORD         nMaxFile;
443 	LPWSTR        lpstrFileTitle;
444 	DWORD         nMaxFileTitle;
445 	LPCWSTR       lpstrInitialDir;
446 	LPCWSTR       lpstrTitle;
447 	DWORD         Flags;
448 	WORD          nFileOffset;
449 	WORD          nFileExtension;
450 	LPCWSTR       lpstrDefExt;
451 	DWORD         lCustData;
452 	LPOFNHOOKPROC lpfnHook;
453 	LPCWSTR       lpTemplateName;
454     
455     static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x0500) {
456         void          *pvReserved;
457         DWORD         dwReserved;
458         DWORD         FlagsEx;
459     }       
460 }
461 alias OPENFILENAMEW* LPOPENFILENAMEW;
462 
463 const size_t OPENFILENAME_SIZE_VERSION_400 = 76;
464 
465 struct OFNOTIFYA {
466 	NMHDR           hdr;
467 	LPOPENFILENAMEA lpOFN;
468 	LPSTR           pszFile;
469 }
470 alias OFNOTIFYA* LPOFNOTIFYA;
471 
472 struct OFNOTIFYW {
473 	NMHDR           hdr;
474 	LPOPENFILENAMEW lpOFN;
475 	LPWSTR          pszFile;
476 }
477 alias OFNOTIFYW* LPOFNOTIFYW;
478 
479 struct PAGESETUPDLGA {
480 	DWORD           lStructSize = PAGESETUPDLGA.sizeof;
481 	HWND            hwndOwner;
482 	HGLOBAL         hDevMode;
483 	HGLOBAL         hDevNames;
484 	DWORD           Flags;
485 	POINT           ptPaperSize;
486 	RECT            rtMinMargin;
487 	RECT            rtMargin;
488 	HINSTANCE       hInstance;
489 	LPARAM          lCustData;
490 	LPPAGESETUPHOOK lpfnPageSetupHook;
491 	LPPAGEPAINTHOOK lpfnPagePaintHook;
492 	LPCSTR          lpPageSetupTemplateName;
493 	HGLOBAL         hPageSetupTemplate;
494 }
495 alias PAGESETUPDLGA* LPPAGESETUPDLGA;
496 
497 struct PAGESETUPDLGW {
498 	DWORD           lStructSize = PAGESETUPDLGW.sizeof;
499 	HWND            hwndOwner;
500 	HGLOBAL         hDevMode;
501 	HGLOBAL         hDevNames;
502 	DWORD           Flags;
503 	POINT           ptPaperSize;
504 	RECT            rtMinMargin;
505 	RECT            rtMargin;
506 	HINSTANCE       hInstance;
507 	LPARAM          lCustData;
508 	LPPAGESETUPHOOK lpfnPageSetupHook;
509 	LPPAGEPAINTHOOK lpfnPagePaintHook;
510 	LPCWSTR         lpPageSetupTemplateName;
511 	HGLOBAL         hPageSetupTemplate;
512 }
513 alias PAGESETUPDLGW* LPPAGESETUPDLGW;
514 
515 struct PRINTDLGA {
516 	DWORD           lStructSize = PRINTDLGA.sizeof;
517 	HWND            hwndOwner;
518 	HANDLE          hDevMode;
519 	HANDLE          hDevNames;
520 	HDC             hDC;
521 	DWORD           Flags;
522 	WORD            nFromPage;
523 	WORD            nToPage;
524 	WORD            nMinPage;
525 	WORD            nMaxPage;
526 	WORD            nCopies;
527 	HINSTANCE       hInstance;
528 	DWORD           lCustData;
529 	LPPRINTHOOKPROC lpfnPrintHook;
530 	LPSETUPHOOKPROC lpfnSetupHook;
531 	LPCSTR          lpPrintTemplateName;
532 	LPCSTR          lpSetupTemplateName;
533 	HANDLE          hPrintTemplate;
534 	HANDLE          hSetupTemplate;
535 }
536 alias PRINTDLGA* LPPRINTDLGA;
537 
538 struct PRINTDLGW {
539 	DWORD           lStructSize = PRINTDLGW.sizeof;
540 	HWND            hwndOwner;
541 	HANDLE          hDevMode;
542 	HANDLE          hDevNames;
543 	HDC             hDC;
544 	DWORD           Flags;
545 	WORD            nFromPage;
546 	WORD            nToPage;
547 	WORD            nMinPage;
548 	WORD            nMaxPage;
549 	WORD            nCopies;
550 	HINSTANCE       hInstance;
551 	DWORD           lCustData;
552 	LPPRINTHOOKPROC lpfnPrintHook;
553 	LPSETUPHOOKPROC lpfnSetupHook;
554 	LPCWSTR         lpPrintTemplateName;
555 	LPCWSTR         lpSetupTemplateName;
556 	HANDLE          hPrintTemplate;
557 	HANDLE          hSetupTemplate;
558 }
559 alias PRINTDLGW* LPPRINTDLGW;
560 
561 static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
562 	import win32.unknwn; // for LPUNKNOWN
563 	import win32.prsht;  // for HPROPSHEETPAGE
564 
565 	struct PRINTPAGERANGE {
566 		DWORD  nFromPage;
567 		DWORD  nToPage;
568 	}
569 	alias PRINTPAGERANGE* LPPRINTPAGERANGE;
570 
571 	struct PRINTDLGEXA {
572 		DWORD            lStructSize = PRINTDLGEXA.sizeof;
573 		HWND             hwndOwner;
574 		HGLOBAL          hDevMode;
575 		HGLOBAL          hDevNames;
576 		HDC              hDC;
577 		DWORD            Flags;
578 		DWORD            Flags2;
579 		DWORD            ExclusionFlags;
580 		DWORD            nPageRanges;
581 		DWORD            nMaxPageRanges;
582 		LPPRINTPAGERANGE lpPageRanges;
583 		DWORD            nMinPage;
584 		DWORD            nMaxPage;
585 		DWORD            nCopies;
586 		HINSTANCE        hInstance;
587 		LPCSTR           lpPrintTemplateName;
588 		LPUNKNOWN        lpCallback;
589 		DWORD            nPropertyPages;
590 		HPROPSHEETPAGE*  lphPropertyPages;
591 		DWORD            nStartPage;
592 		DWORD            dwResultAction;
593 	}
594 	alias PRINTDLGEXA* LPPRINTDLGEXA;
595 
596 	struct PRINTDLGEXW {
597 		DWORD            lStructSize = PRINTDLGEXW.sizeof;
598 		HWND             hwndOwner;
599 		HGLOBAL          hDevMode;
600 		HGLOBAL          hDevNames;
601 		HDC              hDC;
602 		DWORD            Flags;
603 		DWORD            Flags2;
604 		DWORD            ExclusionFlags;
605 		DWORD            nPageRanges;
606 		DWORD            nMaxPageRanges;
607 		LPPRINTPAGERANGE lpPageRanges;
608 		DWORD            nMinPage;
609 		DWORD            nMaxPage;
610 		DWORD            nCopies;
611 		HINSTANCE        hInstance;
612 		LPCWSTR          lpPrintTemplateName;
613 		LPUNKNOWN        lpCallback;
614 		DWORD            nPropertyPages;
615 		HPROPSHEETPAGE*  lphPropertyPages;
616 		DWORD            nStartPage;
617 		DWORD            dwResultAction;
618 	}
619 	alias PRINTDLGEXW* LPPRINTDLGEXW;
620 
621 } // _WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500
622 
623 extern (Windows) {
624 	BOOL ChooseColorA(LPCHOOSECOLORA);
625 	BOOL ChooseColorW(LPCHOOSECOLORW);
626 	BOOL ChooseFontA(LPCHOOSEFONTA);
627 	BOOL ChooseFontW(LPCHOOSEFONTW);
628 	DWORD CommDlgExtendedError();
629 	HWND FindTextA(LPFINDREPLACEA);
630 	HWND FindTextW(LPFINDREPLACEW);
631 	short GetFileTitleA(LPCSTR, LPSTR, WORD);
632 	short GetFileTitleW(LPCWSTR, LPWSTR, WORD);
633 	BOOL GetOpenFileNameA(LPOPENFILENAMEA);
634 	BOOL GetOpenFileNameW(LPOPENFILENAMEW);
635 	BOOL GetSaveFileNameA(LPOPENFILENAMEA);
636 	BOOL GetSaveFileNameW(LPOPENFILENAMEW);
637 	BOOL PageSetupDlgA(LPPAGESETUPDLGA);
638 	BOOL PageSetupDlgW(LPPAGESETUPDLGW);
639 	BOOL PrintDlgA(LPPRINTDLGA);
640 	BOOL PrintDlgW(LPPRINTDLGW);
641 	HWND ReplaceTextA(LPFINDREPLACEA);
642 	HWND ReplaceTextW(LPFINDREPLACEW);
643 
644 	static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
645 		HRESULT PrintDlgExA(LPPRINTDLGEXA);
646 		HRESULT PrintDlgExW(LPPRINTDLGEXW);
647 	}
648 }
649 
650 version (Unicode) {
651 	alias CHOOSECOLORW CHOOSECOLOR;
652 	alias CHOOSEFONTW CHOOSEFONT;
653 	alias FINDREPLACEW FINDREPLACE;
654 	alias OPENFILENAMEW OPENFILENAME;
655 	alias OFNOTIFYW OFNOTIFY;
656 	alias PAGESETUPDLGW PAGESETUPDLG;
657 	alias PRINTDLGW PRINTDLG;
658 
659 	alias ChooseColorW ChooseColor;
660 	alias ChooseFontW ChooseFont;
661 	alias FindTextW FindText;
662 	alias GetFileTitleW GetFileTitle;
663 	alias GetOpenFileNameW GetOpenFileName;
664 	alias GetSaveFileNameW GetSaveFileName;
665 	alias PageSetupDlgW PageSetupDlg;
666 	alias PrintDlgW PrintDlg;
667 	alias ReplaceTextW ReplaceText;
668 
669 	static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
670 		alias PRINTDLGEXW PRINTDLGEX;
671 		alias PrintDlgExW PrintDlgEx;
672 	}
673 
674 } else { // UNICODE
675 
676 	alias CHOOSECOLORA CHOOSECOLOR;
677 	alias CHOOSEFONTA CHOOSEFONT;
678 	alias FINDREPLACEA FINDREPLACE;
679 	alias OPENFILENAMEA OPENFILENAME;
680 	alias OFNOTIFYA OFNOTIFY;
681 	alias PAGESETUPDLGA PAGESETUPDLG;
682 	alias PRINTDLGA PRINTDLG;
683 
684 	alias ChooseColorA ChooseColor;
685 	alias ChooseFontA ChooseFont;
686 	alias FindTextA FindText;
687 	alias GetFileTitleA GetFileTitle;
688 	alias GetOpenFileNameA GetOpenFileName;
689 	alias GetSaveFileNameA GetSaveFileName;
690 	alias PageSetupDlgA PageSetupDlg;
691 	alias PrintDlgA PrintDlg;
692 	alias ReplaceTextA ReplaceText;
693 
694 	static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
695 		alias PRINTDLGEXA PRINTDLGEX;
696 		alias PrintDlgExA PrintDlgEx;
697 	}
698 
699 } // UNICODE
700 
701 alias CHOOSECOLOR* LPCHOOSECOLOR;
702 alias CHOOSEFONT* LPCHOOSEFONT;
703 alias FINDREPLACE* LPFINDREPLACE;
704 alias OPENFILENAME* LPOPENFILENAME;
705 alias OFNOTIFY* LPOFNOTIFY;
706 alias PAGESETUPDLG* LPPAGESETUPDLG;
707 alias PRINTDLG* LPPRINTDLG;
708 static if (_WIN32_WINNT_ONLY && _WIN32_WINNT >= 0x500) {
709 	alias PRINTDLGEX* LPPRINTDLGEX;
710 }