Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the Windows Task Dialog #1133

Merged
merged 169 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
ce917c5
Implement the Windows Task Dialog.
kpreisser Jun 17, 2019
08135a9
Don't specify SetLastError on TaskDialogIndirect() because we don't r…
kpreisser Jun 17, 2019
f2abf50
Follow-Up: Fix syntax error - sorry about that.
kpreisser Jun 17, 2019
b850098
Instead of using a try-catch block in WndProc() in the task dialog su…
kpreisser Jun 19, 2019
36813a5
PR feedback (code style)
kpreisser Jun 19, 2019
95dba75
PR review: Fix typo.
kpreisser Jun 19, 2019
606c421
PR feedback: Invert ifs/reduce nesting.
kpreisser Jun 19, 2019
e1e31c7
PR review: Apply suggestions
kpreisser Jun 19, 2019
591b6e8
Use discards for unused out parameters.
kpreisser Jun 19, 2019
b5779dc
PR feedback: Migrate gists to documentation.
kpreisser Jun 20, 2019
f3f49bb
PR feedback
kpreisser Jun 20, 2019
0bd8057
PR feedback: Rename event "Help" to "HelpRequest".
kpreisser Jun 20, 2019
a92ae5a
PR feedback: Use Linq for checks (and remove outdated comment).
kpreisser Jun 20, 2019
e7eff58
PR feedback: Use a temporary variable in ApplyInitialization() for co…
kpreisser Jun 20, 2019
7dbc875
Activate a theming scope when showing the task dialog.
kpreisser Jun 22, 2019
c974b6d
Update documentation.
kpreisser Jun 22, 2019
00e01ca
Improve documentation.
kpreisser Jun 23, 2019
a80f268
Verify that the enum value is valid.
kpreisser Jun 23, 2019
3056001
Update comment because the internal Marshal.SetLastWin32Error() doesn…
kpreisser Jun 23, 2019
e211c19
Add additional XML documentation.
kpreisser Jun 29, 2019
b999a74
Follow-Up: Fix typo.
kpreisser Jun 29, 2019
fd19292
Extract exception messages into resources.
kpreisser Jun 30, 2019
7c7bb22
Fix documentation.
kpreisser Jul 1, 2019
07b4aeb
Follow-Up: Improve exception message when visual styles (common contr…
kpreisser Jul 1, 2019
e44b4a5
Follow-Up: Use a single placeholder instead of two as it is a single …
kpreisser Jul 2, 2019
90f96b4
PR feedback: Invert property "DoNotSetForeground" to "SetToForeground".
kpreisser Jul 2, 2019
11b907c
Add more XML documentation.
kpreisser Jul 3, 2019
f317d67
Align the callback exception handling logic with the NativeWindow imp…
kpreisser Jul 6, 2019
23f5926
Minor documentation improvement.
kpreisser Jul 7, 2019
e5b2d22
Fix a NRE that can occur when explicitely setting the CheckBox, Expan…
kpreisser Jul 8, 2019
e8007d0
Simplify LINQ expressions.
kpreisser Jul 8, 2019
b0e2841
Minor API and doc tweaks
RussKie Jul 9, 2019
c028179
Call UpdateWindowSize() after updating an icon element, to ensure the…
kpreisser Jul 9, 2019
8eb5c5f
Merge 'master'.
kpreisser Jul 23, 2019
66234e5
Simplify.
kpreisser Jul 26, 2019
4109311
Enable nullable reference types for the TaskDialog classes.
kpreisser Jul 26, 2019
73655a9
Use a switch expression.
kpreisser Jul 26, 2019
48592bf
Follow-Up: Make the return value of the ToString() methods non-nullab…
kpreisser Jul 26, 2019
06e2fc2
Follow-Up: Also make the parameter of the implicit cast operator from…
kpreisser Jul 27, 2019
e1054fa
Improve comments.
kpreisser Jul 27, 2019
b364464
Avoid the CS8602 warning by adding a property "BoundTaskDialog" to th…
kpreisser Jul 28, 2019
b8aecb1
Fix Debug.Assert() call.
kpreisser Jul 30, 2019
1aff293
Shorten the exception message about visual styles not being enabled, …
kpreisser Aug 4, 2019
16fa2ac
Make events nullable.
kpreisser Aug 9, 2019
556c744
Rename method Show() to ShowDialog() to match existing terms.
kpreisser Aug 19, 2019
fac116b
Rename instruction to mainInstruction.
kpreisser Aug 19, 2019
f577d74
Rename title to caption.
kpreisser Aug 19, 2019
23adb26
Remove the TaskDialogButtonClickedEventArgs and instead add a new pro…
kpreisser Aug 22, 2019
0a33163
Refactor to remove the TaskDialogStandardIcon enum and the TaskDialog…
kpreisser Aug 22, 2019
449e3a8
Merge 'master' and resolve conflicts.
kpreisser Aug 25, 2019
4531d73
Follow-Up: Adjust for recent changes.
kpreisser Aug 25, 2019
e25b2f7
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Sep 26, 2019
5b41752
Follow-Up: Adjust for recent Interop changes.
kpreisser Sep 26, 2019
b2115f6
Improve XML documentation.
kpreisser Sep 30, 2019
cc085e6
PR feedback: Refactor the task dialog interop code to align with exis…
kpreisser Oct 1, 2019
21e6dea
PR feedback: Use expression-bodied members where possible.
kpreisser Oct 1, 2019
5f7d8d3
PR feedback: Improve XML documentation and code formatting.
kpreisser Oct 4, 2019
58c143b
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Oct 4, 2019
e4efa8e
Fix formatting.
kpreisser Oct 4, 2019
a7304d9
We don't own the window handle, so there is no need to use a HandleRe…
kpreisser Oct 4, 2019
16a4b56
Follow-Up: SetWindowTextW is not declared with SetLastError=True, so …
kpreisser Oct 5, 2019
302d4f5
Remove the call to SetLastError() as that isn't safe anyway.
kpreisser Oct 8, 2019
b02aca1
Apply suggestions from code review
kpreisser Oct 8, 2019
89c9fb3
PR feedback: Improve XML documentation.
kpreisser Oct 8, 2019
480ad28
Apply suggestions from code review
kpreisser Oct 9, 2019
4b6899f
Apply suggestions from code review (follow-up)
kpreisser Oct 9, 2019
d01a052
Apply further suggestions from code review.
kpreisser Oct 9, 2019
7ef21bd
PR review: Improve interop signatures.
kpreisser Oct 9, 2019
8b23f15
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Oct 28, 2019
c7357e4
Adjust return type as #1981 has been fixed.
kpreisser Oct 28, 2019
52b4bd4
Follow-Up: Fix empty if statement.
kpreisser Oct 29, 2019
058adf5
When updating the dialog caption with an empty or null string, use th…
kpreisser Nov 3, 2019
54d5fbb
Simplify.
kpreisser Nov 17, 2019
59f4ac8
Fix typo.
kpreisser Nov 17, 2019
5d3014d
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Nov 17, 2019
80161ca
Add an indexer to TaskDialogStandardButtonCollection which hides the …
kpreisser Nov 24, 2019
7f89ec2
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Nov 24, 2019
de7f6d9
Adapt to changes in class ThemingScope.
kpreisser Nov 24, 2019
57b7a16
Use TASKDIALOGCONFIG* rather than IntPtr as parameter type for TaskDi…
kpreisser Dec 8, 2019
4d6db76
Rename `CanBeMinimized` -> `AllowMinimize`
RussKie Dec 10, 2019
52f831d
Rename `ShouldCloseDialog` -> `AllowCloseDialog`
RussKie Dec 10, 2019
0d419fa
Streamlime footer control (#1)
RussKie Dec 10, 2019
5b5c973
Fix typo and indentation.
kpreisser Dec 10, 2019
4985159
Add overloads for `defaultButton`, `enabled`, `allowCloseDialog`
RussKie Dec 10, 2019
fedf26a
Improve comment.
kpreisser Dec 17, 2019
d5dac3d
Improve documentation (the setting applies to all custom buttons, not…
kpreisser Dec 17, 2019
bb0b966
Switch boolean property TaskDialogExpander.ExpandFooterArea into an e…
kpreisser Dec 17, 2019
cc5f2e2
Explicitely specify values of the enum members.
kpreisser Dec 17, 2019
7262879
Improve documentation.
kpreisser Dec 17, 2019
065a5c2
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Dec 17, 2019
c5d72cb
Avoid marshalling/copying a string when updating a task dialog text e…
kpreisser Dec 25, 2019
9ecf2ca
Add public properties TaskDialogPage.BoundDialog and TaskDialogContro…
kpreisser Dec 30, 2019
8c8456b
Improve documentation.
kpreisser Dec 30, 2019
d3d4cb7
Rename standard icons to not include the term "security" for shield i…
kpreisser Dec 30, 2019
9a0a9e0
Merge branch 'taskdialog' into Tweak_API
kpreisser Dec 30, 2019
5bf0c1a
Simplify EventHandler<EventArgs> to EventHandler.
kpreisser Dec 30, 2019
20ddf88
Don't apply the initialization in the TDN_NAVIGATED notification if t…
kpreisser Jan 1, 2020
949835d
Remove the additional check (which is also done by SendTaskDialogMess…
kpreisser Jan 2, 2020
1db3804
Buffer changes to TaskDialogPage.MainInstruction, TaskDialogPage.Text…
kpreisser Jan 4, 2020
c4bb63c
Refactor.
kpreisser Jan 4, 2020
e781130
Always set the progress bar position a second time to work reliably w…
kpreisser Jan 4, 2020
c40d770
Simplify.
kpreisser Jan 4, 2020
7c686c1
Don't allow to navigate the dialog if we already received the TDN_DES…
kpreisser Jan 5, 2020
2b55b28
Buffer changes to the TaskDialogProgressBar properties that are done …
kpreisser Jan 5, 2020
6f625b6
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Jan 5, 2020
46ed83f
Update for changes in #2518.
kpreisser Jan 5, 2020
d45605d
Use a separate static method rather than a lambda expression for the …
kpreisser Jan 7, 2020
bd9063d
Follow-Up: Also use a separate method rather than a lambda expression…
kpreisser Jan 7, 2020
535e47f
Simplify, as there is no need to store the function pointer (Marshal.…
kpreisser Jan 7, 2020
5adb97b
Fix trailing whitespace.
kpreisser Jan 7, 2020
6b28789
Follow-Up: Fix trailing whitespace.
kpreisser Jan 7, 2020
c293f6f
Use actual pointer types in structs to align with other interop decla…
kpreisser Jan 21, 2020
74e5804
Use an assert to avoid one instance of the null-forgiving operator.
kpreisser Jan 21, 2020
9c45dd1
Remove outdated comment.
kpreisser Jan 21, 2020
0799e08
PR feedback: Validate enum arguments.
kpreisser Jan 21, 2020
8893f15
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Jan 21, 2020
512e891
Update for changes in #2744.
kpreisser Jan 21, 2020
0ca364e
Fix XML documentation warnings.
kpreisser Jan 21, 2020
b01b98c
Update public API surface.
kpreisser Jan 21, 2020
79a2803
Suppress RS0026 for static TaskDialog.ShowDialog() overloads.
kpreisser Jan 21, 2020
b28955e
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Jan 23, 2020
22aecc6
Update for changes in #2702 (NRT for System.Windows.Forms).
kpreisser Jan 23, 2020
ff6d07a
PR feedback: Use a separate struct for the icon unions.
kpreisser Jan 26, 2020
82e178c
Use Interop.PARAM where applicable, and simplify.
kpreisser Jan 26, 2020
187bdb4
Remove hyperlink functionality for the time being.
kpreisser Feb 9, 2020
22cec90
Follow-Up: Update public API surface.
kpreisser Feb 9, 2020
75af3ae
Fix typo.
kpreisser Mar 9, 2020
b3ebec7
Rework task dialog button API (#12)
kpreisser Mar 9, 2020
d665616
Correctly set the default button ID for standard buttons when the use…
kpreisser Mar 9, 2020
e5ef037
Don't throw an exception in the middle of Page.Validate().
kpreisser Mar 9, 2020
72a8285
PR review: Change flags enums to uint.
kpreisser Mar 9, 2020
02de400
Streamline single/multipage API (kpreisser/winforms#14)
RussKie Mar 23, 2020
55c17d4
Fix NRT warning.
kpreisser Mar 23, 2020
febb140
Remove code which is no longer necessary.
kpreisser Mar 23, 2020
22b1bfa
Fix incorrect check for IntPtr.Zero.
kpreisser Mar 23, 2020
61de9f4
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Mar 23, 2020
5453a65
Follow-Up: Remove the check for IntPtr.Zero to allow to show a modele…
kpreisser Mar 23, 2020
dd3b7de
Set dialog properties via `ShowDialog` (kpreisser/winforms#16)
RussKie Apr 2, 2020
73b29b4
Clean up (kpreisser/winforms#17)
RussKie Apr 2, 2020
bf609cc
Remove dialog box command ID constants in favor of the existing ID enum.
kpreisser Apr 2, 2020
1adb46d
PR review: Inline properties.
kpreisser Apr 2, 2020
a5a9a04
Clean up.
kpreisser Apr 2, 2020
486da46
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Apr 2, 2020
bed1611
Follow-Up: Fix merge issue.
kpreisser Apr 2, 2020
b3abdc6
Remove unnecessary 'unsafe' modifier.
kpreisser Apr 4, 2020
faf868d
Improve wording.
kpreisser Apr 4, 2020
245651f
Simplify setting dialog icon from bitmaps (kpreisser/winforms#15)
RussKie Apr 8, 2020
c2c5a9d
Merge branch 'taskdialog' of https://github.com/kpreisser/winforms in…
kpreisser Apr 8, 2020
f00f2ae
Rename property TaskDialogPage.MainInstruction to Heading.
kpreisser Apr 8, 2020
977a0bd
Rename term 'Footer' to 'Footnote'.
kpreisser Apr 8, 2020
4d12a2d
Changes to public API as proposed in dotnet/winforms#1133:
kpreisser Apr 12, 2020
9cdd007
Don't store the function pointer as can be retrieved with Marshal.Get…
kpreisser Apr 12, 2020
03f3372
Remove unnecessary cast.
kpreisser Apr 12, 2020
ac3eb3b
Follow-Up: Remove TaskDialogCheckBox.Focus() from public API.
kpreisser Apr 12, 2020
9b98691
Streamlime verification control (kpreisser/winforms#18)
RussKie Apr 13, 2020
9186dd3
PR feedback: Add tests verifying size and layout of interop structs.
kpreisser Apr 13, 2020
d8f8fc2
Merge branch 'taskdialog' of https://github.com/kpreisser/winforms in…
kpreisser Apr 13, 2020
8b3a981
PR review: Add exception documentation.
kpreisser Apr 13, 2020
4891a21
Remove property TaskDialogPage.Width as proposed in dotnet/winforms#1…
kpreisser Apr 16, 2020
0e1bd00
PR review:
kpreisser Apr 16, 2020
833687b
Rename operator parameter confirmationText to verificationText to mat…
kpreisser Apr 16, 2020
2615aee
Merge remote-tracking branch 'dotnet/master' into taskdialog
kpreisser Apr 16, 2020
f7063e3
Add remarks about updateability of the dialog directly after starting…
kpreisser Apr 17, 2020
ad3428e
Remove outdated comment which referred to the TaskDialog.Closing even…
kpreisser Apr 17, 2020
859d0d9
Remove unnecessary field.
kpreisser Apr 17, 2020
96f9149
PR feedback: Move static local functions to the bottom of the contain…
kpreisser Apr 17, 2020
6159bc4
Revert the change of not storing the function pointer in WindowSubcla…
kpreisser Apr 17, 2020
b6012e3
PR feedback: Move exception messages to resources.
kpreisser Apr 17, 2020
f586a5f
Remove unused parameter and improve code and comments.
kpreisser Apr 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Common/src/Interop/Interop.HRESULT.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
RussKie marked this conversation as resolved.
Show resolved Hide resolved
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand All @@ -7,5 +7,7 @@ internal static partial class Interop
public static class HRESULT
{
public const int S_OK = 0;

public const int S_FALSE = 1;
}
}
3 changes: 2 additions & 1 deletion src/Common/src/Interop/Interop.Libraries.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand All @@ -11,5 +11,6 @@ public static partial class Libraries
public const string User32 = "user32.dll";
public const string UxTheme = "uxtheme.dll";
public const string Shell32 = "shell32.dll";
public const string ComCtl32 = "comctl32.dll";
}
}
363 changes: 363 additions & 0 deletions src/Common/src/Interop/Interop.TaskDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,363 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
public static class TaskDialog
{
// Progress Bar states (taken from CommCtrl.h)

public const int PBST_NORMAL = 0x0001;

public const int PBST_ERROR = 0x0002;

public const int PBST_PAUSED = 0x0003;

// Dialog Box Command IDs (taken from WinUser.h)

public const int IDOK = 1;

public const int IDCANCEL = 2;

public const int IDABORT = 3;

public const int IDRETRY = 4;

public const int IDIGNORE = 5;

public const int IDYES = 6;

public const int IDNO = 7;

public const int IDCLOSE = 8;

public const int IDHELP = 9;

public const int IDTRYAGAIN = 10;

public const int IDCONTINUE = 11;

// Note: The TaskDialog declarations (including quoted comments)
// were taken from CommCtrl.h.

[Flags]
public enum TASKDIALOG_FLAGS : int
kpreisser marked this conversation as resolved.
Show resolved Hide resolved
{
TDF_ENABLE_HYPERLINKS = 0x0001,

TDF_USE_HICON_MAIN = 0x0002,

TDF_USE_HICON_FOOTER = 0x0004,

TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,

TDF_USE_COMMAND_LINKS = 0x0010,

TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,

TDF_EXPAND_FOOTER_AREA = 0x0040,

TDF_EXPANDED_BY_DEFAULT = 0x0080,

TDF_VERIFICATION_FLAG_CHECKED = 0x0100,

TDF_SHOW_PROGRESS_BAR = 0x0200,

TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400,

TDF_CALLBACK_TIMER = 0x0800,

TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,

TDF_RTL_LAYOUT = 0x2000,

TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000,

TDF_CAN_BE_MINIMIZED = 0x8000,

/// <summary>
/// "Don't call SetForegroundWindow() when activating the dialog"
/// </summary>
/// <remarks>
/// This flag is available on Windows NT 6.2 ("Windows 8") and higher.
/// </remarks>
TDF_NO_SET_FOREGROUND = 0x00010000,

/// <summary>
/// "used by ShellMessageBox to emulate MessageBox sizing behavior"
/// </summary>
TDF_SIZE_TO_CONTENT = 0x01000000
}

public enum TASKDIALOG_MESSAGES : int
{
TDM_NAVIGATE_PAGE = WindowMessages.WM_USER + 101,

/// <summary>
/// "wParam = Button ID"
/// </summary>
TDM_CLICK_BUTTON = WindowMessages.WM_USER + 102,

/// <summary>
/// "wParam = 0 (nonMarque) wParam != 0 (Marquee)"
/// </summary>
TDM_SET_MARQUEE_PROGRESS_BAR = WindowMessages.WM_USER + 103,

/// <summary>
/// "wParam = new progress state"
/// </summary>
TDM_SET_PROGRESS_BAR_STATE = WindowMessages.WM_USER + 104,

/// <summary>
/// "lParam = MAKELPARAM(nMinRange, nMaxRange)"
/// </summary>
TDM_SET_PROGRESS_BAR_RANGE = WindowMessages.WM_USER + 105,

/// <summary>
/// "wParam = new position"
/// </summary>
TDM_SET_PROGRESS_BAR_POS = WindowMessages.WM_USER + 106,

/// <summary>
/// "wParam = 0 (stop marquee), wParam != 0 (start marquee),
/// lparam = speed (milliseconds between repaints)"
/// </summary>
TDM_SET_PROGRESS_BAR_MARQUEE = WindowMessages.WM_USER + 107,

/// <summary>
/// "wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)"
/// </summary>
TDM_SET_ELEMENT_TEXT = WindowMessages.WM_USER + 108,

/// <summary>
/// "wParam = Radio Button ID"
/// </summary>
TDM_CLICK_RADIO_BUTTON = WindowMessages.WM_USER + 110,

/// <summary>
/// "lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID"
/// </summary>
TDM_ENABLE_BUTTON = WindowMessages.WM_USER + 111,

/// <summary>
/// "lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID"
/// </summary>
TDM_ENABLE_RADIO_BUTTON = WindowMessages.WM_USER + 112,

/// <summary>
/// "wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)"
/// </summary>
TDM_CLICK_VERIFICATION = WindowMessages.WM_USER + 113,

/// <summary>
/// "wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)"
/// </summary>
TDM_UPDATE_ELEMENT_TEXT = WindowMessages.WM_USER + 114,

/// <summary>
/// "wParam = Button ID, lParam = 0 (elevation not required),
/// lParam != 0 (elevation required)"
/// </summary>
TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WindowMessages.WM_USER + 115,

/// <summary>
/// "wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon
/// (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)"
/// </summary>
TDM_UPDATE_ICON = WindowMessages.WM_USER + 116
}

public enum TASKDIALOG_NOTIFICATIONS : int
{
TDN_CREATED = 0,

TDN_NAVIGATED = 1,

/// <summary>
/// "wParam = Button ID"
/// </summary>
TDN_BUTTON_CLICKED = 2,

/// <summary>
/// "lParam = (LPCWSTR)pszHREF"
/// </summary>
TDN_HYPERLINK_CLICKED = 3,

/// <summary>
/// "wParam = Milliseconds since dialog created or timer reset"
/// </summary>
TDN_TIMER = 4,

TDN_DESTROYED = 5,

/// <summary>
/// "wParam = Radio Button ID"
/// </summary>
TDN_RADIO_BUTTON_CLICKED = 6,

TDN_DIALOG_CONSTRUCTED = 7,

/// <summary>
/// "wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0"
/// </summary>
TDN_VERIFICATION_CLICKED = 8,

TDN_HELP = 9,

/// <summary>
/// "wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)"
/// </summary>
TDN_EXPANDO_BUTTON_CLICKED = 10
}

public enum TASKDIALOG_ELEMENTS : int
{
TDE_CONTENT,

TDE_EXPANDED_INFORMATION,

TDE_FOOTER,

TDE_MAIN_INSTRUCTION
}

public enum TASKDIALOG_ICON_ELEMENTS : int
{
TDIE_ICON_MAIN,

TDIE_ICON_FOOTER
}

[Flags]
public enum TASKDIALOG_COMMON_BUTTON_FLAGS : int
{
/// <summary>
/// "selected control return value IDOK"
/// </summary>
TDCBF_OK_BUTTON = 0x00000001,

/// <summary>
/// "selected control return value IDYES"
/// </summary>
TDCBF_YES_BUTTON = 0x00000002,

/// <summary>
/// "selected control return value IDNO"
/// </summary>
TDCBF_NO_BUTTON = 0x00000004,

/// <summary>
/// "selected control return value IDCANCEL"
/// </summary>
TDCBF_CANCEL_BUTTON = 0x00000008,

/// <summary>
/// "selected control return value IDRETRY"
/// </summary>
TDCBF_RETRY_BUTTON = 0x00000010,

/// <summary>
/// "selected control return value IDCLOSE"
/// </summary>
TDCBF_CLOSE_BUTTON = 0x00000020,

// Note: The following values are not documented, but have been tested
// to work correctly on every version of Windows that supports the
// Task Dialog.

/// <summary>
/// "selected control return value IDABORT"
/// </summary>
TDCBF_ABORT_BUTTON = 0x00010000,

/// <summary>
/// "selected control return value IDIGNORE"
/// </summary>
TDCBF_IGNORE_BUTTON = 0x00020000,

/// <summary>
/// "selected control return value IDTRYAGAIN"
/// </summary>
TDCBF_TRYAGAIN_BUTTON = 0x00040000,

/// <summary>
/// "selected control return value IDCONTINUE"
/// </summary>
TDCBF_CONTINUE_BUTTON = 0x00080000,

/// <summary>
/// "selected control return value IDHELP"
/// </summary>
TDCBF_HELP_BUTTON = 0x00100000
}

// Packing is defined as 1 in CommCtrl.h ("pack(1)").
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TASKDIALOGCONFIG
{
public uint cbSize;
/// <summary>
/// "incorrectly named, this is the owner window, not a parent."
/// </summary>
public IntPtr hwndParent;
/// <summary>
/// "used for MAKEINTRESOURCE() strings"
/// </summary>
public IntPtr hInstance;
public TASKDIALOG_FLAGS dwFlags;
public TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons;
public IntPtr pszWindowTitle;
public IntPtr mainIconUnion;
public IntPtr pszMainInstruction;
public IntPtr pszContent;
public uint cButtons;
public IntPtr pButtons;
public int nDefaultButton;
public uint cRadioButtons;
public IntPtr pRadioButtons;
public int nDefaultRadioButton;
public IntPtr pszVerificationText;
public IntPtr pszExpandedInformation;
public IntPtr pszExpandedControlText;
public IntPtr pszCollapsedControlText;
public IntPtr footerIconUnion;
public IntPtr pszFooter;
public IntPtr pfCallback;
public IntPtr lpCallbackData;
/// <summary>
/// "width of the Task Dialog's client area in DLU's. If 0, Task Dialog
/// will calculate the ideal width."
/// </summary>
public uint cxWidth;
}

// Packing is defined as 1 in CommCtrl.h ("pack(1)").
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TASKDIALOG_BUTTON
{
public int nButtonID;
public IntPtr pszButtonText;
}

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int PFTASKDIALOGCALLBACK(
IntPtr hwnd,
TASKDIALOG_NOTIFICATIONS msg,
IntPtr wParam,
IntPtr lParam,
IntPtr lpRefData);

[DllImport(Libraries.ComCtl32,
EntryPoint = "TaskDialogIndirect",
kpreisser marked this conversation as resolved.
Show resolved Hide resolved
ExactSpelling = true)]
public static extern int TaskDialogIndirect(
IntPtr pTaskConfig,
[Out] out int pnButton,
[Out] out int pnRadioButton,
[MarshalAs(UnmanagedType.Bool), Out] out bool pfVerificationFlagChecked);
}
}
Loading