1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW Windows headers
5  *
6  * Authors: Vladimir Vlasov
7  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8  * Source: $(DRUNTIMESRC core/sys/windows/_prsht.d)
9  */
10 module core.sys.windows.prsht;
11 version (Windows):
12 
13 version (ANSI) {} else version = Unicode;
14 pragma(lib, "comctl32");
15 
16 import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.winuser;
17 
18 enum MAXPROPPAGES = 100;
19 
20 enum {
21     PSP_DEFAULT      = 0x00000000,
22     PSP_DLGINDIRECT  = 0x00000001,
23     PSP_USEHICON     = 0x00000002,
24     PSP_USEICONID    = 0x00000004,
25     PSP_USETITLE     = 0x00000008,
26     PSP_RTLREADING   = 0x00000010,
27     PSP_HASHELP      = 0x00000020,
28     PSP_USEREFPARENT = 0x00000040,
29     PSP_USECALLBACK  = 0x00000080,
30     PSP_PREMATURE    = 0x00000400
31 }
32 
33 static if (_WIN32_IE >= 0x400) {
34     enum {
35         PSP_HIDEHEADER        = 0x00000800,
36         PSP_USEHEADERTITLE    = 0x00001000,
37         PSP_USEHEADERSUBTITLE = 0x00002000
38     }
39 }
40 
41 enum {
42     PSPCB_RELEASE = 1,
43     PSPCB_CREATE
44 }
45 
46 enum {
47     PSH_DEFAULT           = 0x00000000,
48     PSH_PROPTITLE         = 0x00000001,
49     PSH_USEHICON          = 0x00000002,
50     PSH_USEICONID         = 0x00000004,
51     PSH_PROPSHEETPAGE     = 0x00000008,
52     PSH_WIZARDHASFINISH   = 0x00000010,
53     PSH_WIZARD            = 0x00000020,
54     PSH_USEPSTARTPAGE     = 0x00000040,
55     PSH_NOAPPLYNOW        = 0x00000080,
56     PSH_USECALLBACK       = 0x00000100,
57     PSH_HASHELP           = 0x00000200,
58     PSH_MODELESS          = 0x00000400,
59     PSH_RTLREADING        = 0x00000800,
60     PSH_WIZARDCONTEXTHELP = 0x00001000
61 }
62 
63 static if (_WIN32_IE >= 0x400) {
64     enum {
65         PSH_WATERMARK        = 0x00008000,
66         PSH_USEHBMWATERMARK  = 0x00010000,
67         PSH_USEHPLWATERMARK  = 0x00020000,
68         PSH_STRETCHWATERMARK = 0x00040000,
69         PSH_HEADER           = 0x00080000,
70         PSH_USEHBMHEADER     = 0x00100000,
71         PSH_USEPAGELANG      = 0x00200000
72     }
73     static if (_WIN32_IE < 0x0500) {
74         enum {
75             PSH_WIZARD97 = 0x00002000
76         }
77     } else {
78         enum {
79             PSH_WIZARD97 = 0x01000000
80         }
81     }
82 }
83 
84 static if (_WIN32_IE >= 0x500) {
85     enum {
86         PSH_WIZARD_LITE   = 0x00400000,
87         PSH_NOCONTEXTHELP = 0x02000000
88     }
89 }
90 
91 enum {
92     PSCB_INITIALIZED = 1,
93     PSCB_PRECREATE
94 }
95 
96 enum {
97     PSN_FIRST       = (-200),
98     PSN_LAST        = (-299),
99     PSN_SETACTIVE   = (-200),
100     PSN_KILLACTIVE  = (-201),
101     PSN_APPLY       = (-202),
102     PSN_RESET       = (-203),
103     PSN_HELP        = (-205),
104     PSN_WIZBACK     = (-206),
105     PSN_WIZNEXT     = (-207),
106     PSN_WIZFINISH   = (-208),
107     PSN_QUERYCANCEL = (-209)
108 }
109 static if (_WIN32_IE >= 0x400) {
110     enum {
111         PSN_GETOBJECT = (-210)
112     }
113 }
114 static if (_WIN32_IE >= 0x500) {
115     enum {
116         PSN_TRANSLATEACCELERATOR = (-212),
117         PSN_QUERYINITIALFOCUS    = (-213)
118     }
119 }
120 
121 enum {
122     PSNRET_NOERROR,
123     PSNRET_INVALID,
124     PSNRET_INVALID_NOCHANGEPAGE,
125     PSNRET_MESSAGEHANDLED
126 }
127 
128 enum {
129     ID_PSRESTARTWINDOWS = 0x2,
130     ID_PSREBOOTSYSTEM   = ID_PSRESTARTWINDOWS | 0x1
131 }
132 
133 enum {
134     WIZ_CXDLG  = 276,
135     WIZ_CYDLG  = 140,
136     WIZ_CXBMP  = 80,
137     WIZ_BODYX  = 92,
138     WIZ_BODYCX = 184
139 }
140 
141 enum {
142     PROP_SM_CXDLG  = 212,
143     PROP_SM_CYDLG  = 188,
144     PROP_MED_CXDLG = 227,
145     PROP_MED_CYDLG = 215,
146     PROP_LG_CXDLG  = 252,
147     PROP_LG_CYDLG  = 218
148 }
149 
150 enum {
151     PSBTN_BACK,
152     PSBTN_NEXT,
153     PSBTN_FINISH,
154     PSBTN_OK,
155     PSBTN_APPLYNOW,
156     PSBTN_CANCEL,
157     PSBTN_HELP,
158     PSBTN_MAX = 6
159 }
160 
161 enum {
162     PSWIZB_BACK           = 1,
163     PSWIZB_NEXT           = 2,
164     PSWIZB_FINISH         = 4,
165     PSWIZB_DISABLEDFINISH = 8
166 }
167 
168 enum {
169     PSM_SETCURSEL = WM_USER + 101,
170     PSM_REMOVEPAGE,
171     PSM_ADDPAGE,
172     PSM_CHANGED,
173     PSM_RESTARTWINDOWS,
174     PSM_REBOOTSYSTEM,
175     PSM_CANCELTOCLOSE,
176     PSM_QUERYSIBLINGS,
177     PSM_UNCHANGED,
178     PSM_APPLY,
179     PSM_SETTITLEA,
180     PSM_SETWIZBUTTONS,
181     PSM_PRESSBUTTON,
182     PSM_SETCURSELID,
183     PSM_SETFINISHTEXTA,
184     PSM_GETTABCONTROL,
185     PSM_ISDIALOGMESSAGE,
186     PSM_GETCURRENTPAGEHWND,
187     PSM_INSERTPAGE,
188     PSM_SETTITLEW,
189     PSM_SETFINISHTEXTW // = WM_USER + 121,
190 }
191 
192 extern (Windows) {
193     alias UINT function(HWND, UINT, LPPROPSHEETPAGEA) LPFNPSPCALLBACKA;
194     alias UINT function(HWND, UINT, LPPROPSHEETPAGEW) LPFNPSPCALLBACKW;
195     alias int function(HWND, UINT, LPARAM) PFNPROPSHEETCALLBACK;
196 }
197 
198 align(4):
199 
200 struct PROPSHEETPAGEA {
201     DWORD dwSize = PROPSHEETPAGEA.sizeof;
202     DWORD dwFlags;
203     HINSTANCE hInstance;
204     union {
205         LPCSTR         pszTemplate;
206         LPCDLGTEMPLATE pResource;
207     }
208     union {
209         HICON  hIcon;
210         LPCSTR pszIcon;
211     }
212     LPCSTR  pszTitle;
213     DLGPROC pfnDlgProc;
214     LPARAM  lParam;
215     LPFNPSPCALLBACKA pfnCallback;
216     UINT*     pcRefParent;
217     static if (_WIN32_IE >= 0x400) {
218         LPCSTR pszHeaderTitle;
219         LPCSTR pszHeaderSubTitle;
220     }
221 }
222 alias PROPSHEETPAGEA*        LPPROPSHEETPAGEA;
223 alias const(PROPSHEETPAGEA)* LPCPROPSHEETPAGEA;
224 
225 struct PROPSHEETPAGEW {
226     DWORD     dwSize = PROPSHEETPAGEW.sizeof;
227     DWORD     dwFlags;
228     HINSTANCE hInstance;
229     union {
230         LPCWSTR        pszTemplate;
231         LPCDLGTEMPLATE pResource;
232     }
233     union {
234         HICON   hIcon;
235         LPCWSTR pszIcon;
236     }
237     LPCWSTR   pszTitle;
238     DLGPROC   pfnDlgProc;
239     LPARAM    lParam;
240     LPFNPSPCALLBACKW pfnCallback;
241     UINT*     pcRefParent;
242     static if (_WIN32_IE >= 0x400) {
243         LPCWSTR pszHeaderTitle;
244         LPCWSTR pszHeaderSubTitle;
245     }
246 }
247 alias PROPSHEETPAGEW*        LPPROPSHEETPAGEW;
248 alias const(PROPSHEETPAGEW)* LPCPROPSHEETPAGEW;
249 
250 mixin DECLARE_HANDLE!("HPROPSHEETPAGE");
251 
252 struct PROPSHEETHEADERA {
253     DWORD dwSize = PROPSHEETHEADERA.sizeof;
254     DWORD dwFlags;
255     HWND  hwndParent;
256     HINSTANCE hInstance;
257     union {
258         HICON   hIcon;
259         LPCSTR  pszIcon;
260     }
261     LPCSTR pszCaption;
262     UINT   nPages;
263     union {
264         UINT   nStartPage;
265         LPCSTR pStartPage;
266     }
267     union {
268         LPCPROPSHEETPAGEA ppsp;
269         HPROPSHEETPAGE*   phpage;
270     }
271     PFNPROPSHEETCALLBACK pfnCallback;
272     static if (_WIN32_IE >= 0x400) {
273         union {
274             HBITMAP hbmWatermark;
275             LPCSTR  pszbmWatermark;
276         }
277         HPALETTE hplWatermark;
278         union {
279             HBITMAP hbmHeader;
280             LPCSTR  pszbmHeader;
281         }
282     }
283 }
284 alias PROPSHEETHEADERA*        LPPROPSHEETHEADERA;
285 alias const(PROPSHEETHEADERA)* LPCPROPSHEETHEADERA;
286 
287 struct PROPSHEETHEADERW {
288     DWORD     dwSize = PROPSHEETHEADERW.sizeof;
289     DWORD     dwFlags;
290     HWND      hwndParent;
291     HINSTANCE hInstance;
292     union {
293         HICON   hIcon;
294         LPCWSTR pszIcon;
295     }
296     LPCWSTR   pszCaption;
297     UINT      nPages;
298     union {
299         UINT    nStartPage;
300         LPCWSTR pStartPage;
301     }
302     union {
303         LPCPROPSHEETPAGEW ppsp;
304         HPROPSHEETPAGE*   phpage;
305     }
306     PFNPROPSHEETCALLBACK pfnCallback;
307     static if (_WIN32_IE >= 0x400) {
308         union {
309             HBITMAP hbmWatermark;
310             LPCWSTR pszbmWatermark;
311         }
312         HPALETTE hplWatermark;
313         union {
314             HBITMAP hbmHeader;
315             LPCWSTR pszbmHeader;
316         }
317     }
318 }
319 alias PROPSHEETHEADERW*        LPPROPSHEETHEADERW;
320 alias const(PROPSHEETHEADERW)* LPCPROPSHEETHEADERW;
321 
322 extern (Windows) {
323     alias BOOL function(HPROPSHEETPAGE, LPARAM) LPFNADDPROPSHEETPAGE;
324     alias BOOL function(LPVOID, LPFNADDPROPSHEETPAGE, LPARAM)
325       LPFNADDPROPSHEETPAGES;
326 }
327 
328 struct PSHNOTIFY {
329     NMHDR  hdr;
330     LPARAM lParam;
331 }
332 alias PSHNOTIFY* LPPSHNOTIFY;
333 
334 extern (Windows) {
335     HPROPSHEETPAGE CreatePropertySheetPageA(LPCPROPSHEETPAGEA);
336     HPROPSHEETPAGE CreatePropertySheetPageW(LPCPROPSHEETPAGEW);
337     BOOL DestroyPropertySheetPage(HPROPSHEETPAGE);
338     INT_PTR PropertySheetA(LPCPROPSHEETHEADERA);
339     INT_PTR PropertySheetW(LPCPROPSHEETHEADERW);
340 }
341 
342 version (Unicode) {
343     alias LPFNPSPCALLBACKW         LPFNPSPCALLBACK;
344     alias PROPSHEETPAGEW           PROPSHEETPAGE;
345     alias LPPROPSHEETPAGEW         LPPROPSHEETPAGE;
346     alias LPCPROPSHEETPAGEW        LPCPROPSHEETPAGE;
347     alias PROPSHEETHEADERW         PROPSHEETHEADER;
348     alias LPPROPSHEETHEADERW       LPPROPSHEETHEADER;
349     alias LPCPROPSHEETHEADERW      LPCPROPSHEETHEADER;
350     alias PSM_SETTITLEW            PSM_SETTITLE;
351     alias PSM_SETFINISHTEXTW       PSM_SETFINISHTEXT;
352     alias CreatePropertySheetPageW CreatePropertySheetPage;
353     alias PropertySheetW           PropertySheet;
354 } else {
355     alias LPFNPSPCALLBACKA         LPFNPSPCALLBACK;
356     alias PROPSHEETPAGEA           PROPSHEETPAGE;
357     alias LPPROPSHEETPAGEA         LPPROPSHEETPAGE;
358     alias LPCPROPSHEETPAGEA        LPCPROPSHEETPAGE;
359     alias PROPSHEETHEADERA         PROPSHEETHEADER;
360     alias LPPROPSHEETHEADERA       LPPROPSHEETHEADER;
361     alias LPCPROPSHEETHEADERA      LPCPROPSHEETHEADER;
362     alias PSM_SETTITLEA            PSM_SETTITLE;
363     alias PSM_SETFINISHTEXTA       PSM_SETFINISHTEXT;
364     alias CreatePropertySheetPageA CreatePropertySheetPage;
365     alias PropertySheetA           PropertySheet;
366 }
367 
368 BOOL PropSheet_SetCurSel(HWND hPropSheetDlg, HPROPSHEETPAGE hpage,
369       HPROPSHEETPAGE index) {
370     return cast(BOOL) SendMessage(hPropSheetDlg, PSM_SETCURSEL,
371       cast(WPARAM) index, cast(LPARAM) hpage);
372 }
373 
374 VOID PropSheet_RemovePage(HWND hPropSheetDlg, int index, HPROPSHEETPAGE hpage) {
375     SendMessage(hPropSheetDlg, PSM_REMOVEPAGE, index, cast(LPARAM) hpage);
376 }
377 
378 BOOL PropSheet_AddPage(HWND hPropSheetDlg, HPROPSHEETPAGE hpage) {
379         return cast(BOOL) SendMessage(hPropSheetDlg, PSM_ADDPAGE,
380           0, cast(LPARAM) hpage);
381 }
382 
383 VOID PropSheet_Changed(HWND hPropSheetDlg, HWND hwndPage) {
384     SendMessage(hPropSheetDlg, PSM_CHANGED, cast(WPARAM) hwndPage, 0);
385 }
386 
387 VOID PropSheet_RestartWindows(HWND hPropSheetDlg) {
388     SendMessage(hPropSheetDlg, PSM_RESTARTWINDOWS, 0, 0);
389 }
390 
391 VOID PropSheet_RebootSystem(HWND hPropSheetDlg) {
392     SendMessage(hPropSheetDlg, PSM_REBOOTSYSTEM, 0, 0);
393 }
394 
395 VOID PropSheet_CancelToClose(HWND hPropSheetDlg) {
396     SendMessage(hPropSheetDlg, PSM_CANCELTOCLOSE, 0, 0);
397 }
398 
399 int PropSheet_QuerySiblings(HWND hPropSheetDlg, WPARAM param1, LPARAM param2) {
400     return cast(int) SendMessage(hPropSheetDlg, PSM_QUERYSIBLINGS, param1, param2);
401 }
402 
403 VOID PropSheet_UnChanged(HWND hPropSheetDlg, HWND hwndPage) {
404     SendMessage(hPropSheetDlg, PSM_UNCHANGED, cast(WPARAM) hwndPage, 0);
405 }
406 
407 BOOL PropSheet_Apply(HWND hPropSheetDlg) {
408     return cast(BOOL) SendMessage(hPropSheetDlg, PSM_APPLY, 0, 0);
409 }
410 
411 VOID PropSheet_SetTitle(HWND hPropSheetDlg, DWORD wStyle, LPTSTR lpszText) {
412     SendMessage(hPropSheetDlg, PSM_SETTITLE, wStyle, cast(LPARAM) lpszText);
413 }
414 
415 VOID PropSheet_SetWizButtons(HWND hPropSheetDlg, DWORD dwFlags) {
416     PostMessage(hPropSheetDlg, PSM_SETWIZBUTTONS, 0, cast(LPARAM) dwFlags);
417 }
418 
419 BOOL PropSheet_PressButton(HWND hPropSheetDlg, int iButton) {
420     return cast(BOOL) SendMessage(hPropSheetDlg, PSM_PRESSBUTTON, iButton, 0);
421 }
422 
423 BOOL PropSheet_SetCurSelByID(HWND hPropSheetDlg, int id) {
424     return cast(BOOL) SendMessage(hPropSheetDlg, PSM_SETCURSELID, 0, id);
425 }
426 
427 VOID PropSheet_SetFinishText(HWND hPropSheetDlg, LPTSTR lpszText) {
428     SendMessage(hPropSheetDlg, PSM_SETFINISHTEXT, 0, cast(LPARAM) lpszText);
429 }
430 
431 HWND PropSheet_GetTabControl(HWND hPropSheetDlg) {
432     return cast(HWND) SendMessage(hPropSheetDlg, PSM_GETTABCONTROL, 0, 0);
433 }
434 
435 BOOL PropSheet_IsDialogMessage(HWND hDlg, LPMSG pMsg) {
436     return cast(BOOL) SendMessage(hDlg, PSM_ISDIALOGMESSAGE,
437       0, cast(LPARAM) pMsg);
438 }
439 
440 HWND PropSheet_GetCurrentPageHwnd(HWND hDlg) {
441     return cast(HWND) SendMessage(hDlg, PSM_GETCURRENTPAGEHWND, 0, 0);
442 }
443 
444 BOOL PropSheet_InsertPage(HWND hPropSheetDlg, WPARAM wInsertAfter,
445       HPROPSHEETPAGE hpage) {
446     return cast(BOOL) SendMessage(hPropSheetDlg, PSM_INSERTPAGE,
447       wInsertAfter, cast(LPARAM) hpage);
448 }