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