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