1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5   This software is provided 'as-is', without any express or implied
6   warranty.  In no event will the authors be held liable for any damages
7   arising from the use of this software.
8 
9   Permission is granted to anyone to use this software for any purpose,
10   including commercial applications, and to alter it and redistribute it
11   freely, subject to the following restrictions:
12 
13   1. The origin of this software must not be misrepresented; you must not
14      claim that you wrote the original software. If you use this software
15      in a product, an acknowledgment in the product documentation would be
16      appreciated but is not required.
17   2. Altered source versions must be plainly marked as such, and must not be
18      misrepresented as being the original software.
19   3. This notice may not be removed or altered from any source distribution.
20 */
21 #include <pshpack1.h>
22 
23 typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData);
24 
25 enum _TASKDIALOG_FLAGS
26 {
27     TDF_ENABLE_HYPERLINKS = 0x0001,
28     TDF_USE_HICON_MAIN = 0x0002,
29     TDF_USE_HICON_FOOTER = 0x0004,
30     TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,
31     TDF_USE_COMMAND_LINKS = 0x0010,
32     TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,
33     TDF_EXPAND_FOOTER_AREA = 0x0040,
34     TDF_EXPANDED_BY_DEFAULT = 0x0080,
35     TDF_VERIFICATION_FLAG_CHECKED = 0x0100,
36     TDF_SHOW_PROGRESS_BAR = 0x0200,
37     TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400,
38     TDF_CALLBACK_TIMER = 0x0800,
39     TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,
40     TDF_RTL_LAYOUT = 0x2000,
41     TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000,
42     TDF_CAN_BE_MINIMIZED = 0x8000,
43     //#if (NTDDI_VERSION >= NTDDI_WIN8)
44     TDF_NO_SET_FOREGROUND = 0x00010000, // Don't call SetForegroundWindow() when activating the dialog
45                                         //#endif // (NTDDI_VERSION >= NTDDI_WIN8)
46                                         TDF_SIZE_TO_CONTENT = 0x01000000  // used by ShellMessageBox to emulate MessageBox sizing behavior
47 };
48 typedef int TASKDIALOG_FLAGS;                         // Note: _TASKDIALOG_FLAGS is an int
49 
50 typedef enum _TASKDIALOG_MESSAGES
51 {
52     TDM_NAVIGATE_PAGE = WM_USER + 101,
53     TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID
54     TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee)
55     TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state
56     TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange)
57     TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position
58     TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
59     TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
60     TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID
61     TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
62     TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
63     TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
64     TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
65     TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
66     TDM_UPDATE_ICON = WM_USER + 116  // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
67 } TASKDIALOG_MESSAGES;
68 
69 typedef enum _TASKDIALOG_NOTIFICATIONS
70 {
71     TDN_CREATED = 0,
72     TDN_NAVIGATED = 1,
73     TDN_BUTTON_CLICKED = 2,            // wParam = Button ID
74     TDN_HYPERLINK_CLICKED = 3,            // lParam = (LPCWSTR)pszHREF
75     TDN_TIMER = 4,            // wParam = Milliseconds since dialog created or timer reset
76     TDN_DESTROYED = 5,
77     TDN_RADIO_BUTTON_CLICKED = 6,            // wParam = Radio Button ID
78     TDN_DIALOG_CONSTRUCTED = 7,
79     TDN_VERIFICATION_CLICKED = 8,             // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
80     TDN_HELP = 9,
81     TDN_EXPANDO_BUTTON_CLICKED = 10            // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
82 } TASKDIALOG_NOTIFICATIONS;
83 
84 typedef struct _TASKDIALOG_BUTTON
85 {
86     int     nButtonID;
87     PCWSTR  pszButtonText;
88 } TASKDIALOG_BUTTON;
89 
90 typedef enum _TASKDIALOG_ELEMENTS
91 {
92     TDE_CONTENT,
93     TDE_EXPANDED_INFORMATION,
94     TDE_FOOTER,
95     TDE_MAIN_INSTRUCTION
96 } TASKDIALOG_ELEMENTS;
97 
98 typedef enum _TASKDIALOG_ICON_ELEMENTS
99 {
100     TDIE_ICON_MAIN,
101     TDIE_ICON_FOOTER
102 } TASKDIALOG_ICON_ELEMENTS;
103 
104 #define TD_WARNING_ICON         MAKEINTRESOURCEW(-1)
105 #define TD_ERROR_ICON           MAKEINTRESOURCEW(-2)
106 #define TD_INFORMATION_ICON     MAKEINTRESOURCEW(-3)
107 #define TD_SHIELD_ICON          MAKEINTRESOURCEW(-4)
108 
109 enum _TASKDIALOG_COMMON_BUTTON_FLAGS
110 {
111     TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK
112     TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES
113     TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO
114     TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL
115     TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY
116     TDCBF_CLOSE_BUTTON = 0x0020  // selected control return value IDCLOSE
117 };
118 typedef int TASKDIALOG_COMMON_BUTTON_FLAGS;           // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
119 
120 typedef struct _TASKDIALOGCONFIG
121 {
122     UINT        cbSize;
123     HWND        hwndParent;                             // incorrectly named, this is the owner window, not a parent.
124     HINSTANCE   hInstance;                              // used for MAKEINTRESOURCE() strings
125     TASKDIALOG_FLAGS                dwFlags;            // TASKDIALOG_FLAGS (TDF_XXX) flags
126     TASKDIALOG_COMMON_BUTTON_FLAGS  dwCommonButtons;    // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
127     PCWSTR      pszWindowTitle;                         // string or MAKEINTRESOURCE()
128     union
129     {
130         HICON   hMainIcon;
131         PCWSTR  pszMainIcon;
132     } /*DUMMYUNIONNAME*/;
133     PCWSTR      pszMainInstruction;
134     PCWSTR      pszContent;
135     UINT        cButtons;
136     const TASKDIALOG_BUTTON  *pButtons;
137     int         nDefaultButton;
138     UINT        cRadioButtons;
139     const TASKDIALOG_BUTTON  *pRadioButtons;
140     int         nDefaultRadioButton;
141     PCWSTR      pszVerificationText;
142     PCWSTR      pszExpandedInformation;
143     PCWSTR      pszExpandedControlText;
144     PCWSTR      pszCollapsedControlText;
145     union
146     {
147         HICON   hFooterIcon;
148         PCWSTR  pszFooterIcon;
149     } /*DUMMYUNIONNAME2*/;
150     PCWSTR      pszFooter;
151     PFTASKDIALOGCALLBACK pfCallback;
152     LONG_PTR    lpCallbackData;
153     UINT        cxWidth;                                // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
154 } TASKDIALOGCONFIG;
155 
156 #include <poppack.h>
157