using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using Vanara.Extensions; using static Vanara.PInvoke.User32; namespace Vanara.PInvoke { public static partial class ComCtl32 { /// The signature of the callback that receives messages from the Task Dialog when various events occur. /// The window handle of the /// The message being passed. /// wParam which is interpreted differently depending on the message. /// wParam which is interpreted differently depending on the message. /// The reference data that was set to TaskDialog.CallbackData. /// A HRESULT value. The return value is specific to the message being processed. [PInvokeData("Commctrl.h", MSDNShortId = "bb760542")] [UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate HRESULT TaskDialogCallbackProc([In] HWND hwnd, [In] TaskDialogNotification msg, [In] IntPtr wParam, [In] IntPtr lParam, [In] IntPtr refData); /// /// Specifies the push buttons displayed in the task dialog. If no common buttons are specified and no custom buttons are specified /// using the cButtons and pButtons members, the task dialog will contain the OK button by default. This parameter may be a /// combination of flags /// [PInvokeData("Commctrl.h", MSDNShortId = "bb760540")] [Flags] public enum TASKDIALOG_COMMON_BUTTON_FLAGS { /// The task dialog contains the push button: OK. TDCBF_OK_BUTTON = 0x0001, /// The task dialog contains the push button: Yes. TDCBF_YES_BUTTON = 0x0002, /// The task dialog contains the push button: No. TDCBF_NO_BUTTON = 0x0004, /// /// The task dialog contains the push button: Cancel. If this button is specified, the task dialog will respond to typical cancel /// actions (Alt-F4 and Escape). /// TDCBF_CANCEL_BUTTON = 0x0008, /// The task dialog contains the push button: Retry. TDCBF_RETRY_BUTTON = 0x0010, /// The task dialog contains the push button: Close. TDCBF_CLOSE_BUTTON = 0x0020, } /// Indicates element to update for the TDM_UPDATE_ELEMENT_TEXT message. [PInvokeData("Commctrl.h", MSDNShortId = "bb760536")] public enum TASKDIALOG_ELEMENTS { /// The content element. TDE_CONTENT, /// Expanded Information. TDE_EXPANDED_INFORMATION, /// Footer. TDE_FOOTER, /// Main Instructions TDE_MAIN_INSTRUCTION } /// Specifies the behavior of the task dialog. [PInvokeData("Commctrl.h", MSDNShortId = "bb787473")] [Flags] public enum TASKDIALOG_FLAGS { /// /// Enables hyperlink processing for the strings specified in the pszContent, pszExpandedInformation and pszFooter members. When /// enabled, these members may point to strings that contain hyperlinks in the following form: /// /// Hyperlink Text]]> /// /// Enabling hyperlinks when using content from an unsafe source may cause security /// vulnerabilities.Task Dialogs will not actually execute any hyperlinks.Hyperlink execution must be handled in the /// callback function specified by pfCallback.For more details, see TaskDialogCallbackProc. /// TDF_ENABLE_HYPERLINKS = 0x0001, /// /// Indicates that the dialog should use the icon referenced by the handle in the hMainIcon member as the primary icon in the /// task dialog. If this flag is specified, the pszMainIcon member is ignored. /// TDF_USE_HICON_MAIN = 0x0002, /// /// Indicates that the dialog should use the icon referenced by the handle in the hFooterIcon member as the footer icon in the /// task dialog. If this flag is specified, the pszFooterIcon member is ignored. /// TDF_USE_HICON_FOOTER = 0x0004, /// /// Indicates that the dialog should be able to be closed using Alt-F4, Escape, and the title bar's close button even if no /// cancel button is specified in either the dwCommonButtons or pButtons members. /// TDF_ALLOW_DIALOG_CANCELLATION = 0x0008, /// /// Indicates that the buttons specified in the pButtons member are to be displayed as command links (using a standard task /// dialog glyph) instead of push buttons. When using command links, all characters up to the first new line character in the /// pszButtonText member will be treated as the command link's main text, and the remainder will be treated as the command link's /// note. This flag is ignored if the cButtons member is zero. /// TDF_USE_COMMAND_LINKS = 0x0010, /// /// Indicates that the buttons specified in the pButtons member are to be displayed as command links (without a glyph) instead of /// push buttons. When using command links, all characters up to the first new line character in the pszButtonText member will be /// treated as the command link's main text, and the remainder will be treated as the command link's note. This flag is ignored /// if the cButtons member is zero. /// TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020, /// /// Indicates that the string specified by the pszExpandedInformation member is displayed at the bottom of the dialog's footer /// area instead of immediately after the dialog's content. This flag is ignored if the pszExpandedInformation member is NULL. /// TDF_EXPAND_FOOTER_AREA = 0x0040, /// /// Indicates that the string specified by the pszExpandedInformation member is displayed when the dialog is initially displayed. /// This flag is ignored if the pszExpandedInformation member is NULL. /// TDF_EXPANDED_BY_DEFAULT = 0x0080, /// /// Indicates that the verification checkbox in the dialog is checked when the dialog is initially displayed. This flag is /// ignored if the pszVerificationText parameter is NULL. /// TDF_VERIFICATION_FLAG_CHECKED = 0x0100, /// Indicates that a Progress Bar is to be displayed. TDF_SHOW_PROGRESS_BAR = 0x0200, /// Indicates that an Marquee Progress Bar is to be displayed. TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400, /// Indicates that the task dialog's callback is to be called approximately every 200 milliseconds. TDF_CALLBACK_TIMER = 0x0800, /// /// Indicates that the task dialog is positioned (centered) relative to the window specified by hwndParent. If the flag is not /// supplied (or no hwndParent member is specified), the task dialog is positioned (centered) relative to the monitor. /// TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000, /// Indicates that text is displayed reading right to left. TDF_RTL_LAYOUT = 0x2000, /// Indicates that no default item will be selected. TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000, /// Indicates that the task dialog can be minimized. TDF_CAN_BE_MINIMIZED = 0x8000, /// Don't call SetForegroundWindow() when activating the dialog. TDF_NO_SET_FOREGROUND = 0x00010000, /// /// Indicates that the width of the task dialog is determined by the width of its content area. This flag is ignored if cxWidth /// is not set to 0. /// TDF_SIZE_TO_CONTENT = 0x01000000 } /// Indicates which icon element to update for the TDM_UPDATE_ICON message. [PInvokeData("Commctrl.h", MSDNShortId = "bb760538")] public enum TASKDIALOG_ICON_ELEMENTS { /// Main instruction icon. TDIE_ICON_MAIN, /// Footer icon. TDIE_ICON_FOOTER } /// The System icons the TaskDialog supports for and . [PInvokeData("Commctrl.h", MSDNShortId = "bb787473")] [SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] // Type comes from CommCtrl.h public enum TaskDialogIcon : uint { /// An exclamation-point icon appears in the task dialog. TD_WARNING_ICON = 0xFFFF, // MAKEINTRESOURCEW(-1) /// A stop-sign icon appears in the task dialog. TD_ERROR_ICON = 0xFFFE, // MAKEINTRESOURCEW(-2) /// An icon consisting of a lowercase letter i in a circle appears in the task dialog. TD_INFORMATION_ICON = 0xFFFD, // MAKEINTRESOURCEW(-3) /// A shield icon appears in the task dialog. TD_SHIELD_ICON = 0xFFFC, // MAKEINTRESOURCEW(-4) /// Shield icon on a blue background. Only available on Windows 8 and later. TD_SHIELDBLUE_ICON = 0xFFFB, // MAKEINTRESOURCEW(-5) /// Warning Shield icon on a yellow background. Only available on Windows 8 and later. TD_SECURITYWARNING_ICON = 0xFFFA, // MAKEINTRESOURCEW(-6) /// Error Shield icon on a red background. Only available on Windows 8 and later. TD_SECURITYERROR_ICON = 0xFFF9, // MAKEINTRESOURCEW(-7) /// Success Shield icon on a green background. Only available on Windows 8 and later. TD_SECURITYSUCCESS_ICON = 0xFFF8, // MAKEINTRESOURCEW(-8) /// Shield icon on a gray background. Only available on Windows 8 and later. TD_SHIELDGRAY_ICON = 0xFFF7, // MAKEINTRESOURCEW(-9) } /// TaskDialogMessage taken from CommCtrl.h. [PInvokeData("Commctrl.h", MSDNShortId = "bb787473")] public enum TaskDialogMessage : uint { /// Navigate page. TDM_NAVIGATE_PAGE = WindowMessage.WM_USER + 101, /// Click button. TDM_CLICK_BUTTON = WindowMessage.WM_USER + 102, // wParam = Button ID /// Set Progress bar to be marquee mode. TDM_SET_MARQUEE_PROGRESS_BAR = WindowMessage.WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee) /// Set Progress bar state. TDM_SET_PROGRESS_BAR_STATE = WindowMessage.WM_USER + 104, // wParam = new progress state /// Set progress bar range. TDM_SET_PROGRESS_BAR_RANGE = WindowMessage.WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange) /// Set progress bar position. TDM_SET_PROGRESS_BAR_POS = WindowMessage.WM_USER + 106, // wParam = new position /// Set progress bar marquee (animation). TDM_SET_PROGRESS_BAR_MARQUEE = WindowMessage.WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints) /// Set a text element of the Task Dialog. TDM_SET_ELEMENT_TEXT = WindowMessage.WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) /// Click a radio button. TDM_CLICK_RADIO_BUTTON = WindowMessage.WM_USER + 110, // wParam = Radio Button ID /// Enable or disable a button. TDM_ENABLE_BUTTON = WindowMessage.WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID /// Enable or disable a radio button. TDM_ENABLE_RADIO_BUTTON = WindowMessage.WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID /// Check or uncheck the verification checkbox. TDM_CLICK_VERIFICATION = WindowMessage.WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus) /// Update the text of an element (no effect if originally set as null). TDM_UPDATE_ELEMENT_TEXT = WindowMessage.WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) /// /// Designate whether a given Task Dialog button or command link should have a User Account Control (UAC) shield icon. /// TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WindowMessage.WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required) /// Refreshes the icon of the task dialog. TDM_UPDATE_ICON = WindowMessage.WM_USER + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise) } /// Task Dialog callback notifications. [PInvokeData("Commctrl.h", MSDNShortId = "bb787473")] public enum TaskDialogNotification : uint { /// /// Sent by the task dialog after the dialog has been created and before it is displayed. This notification code is received only /// through the task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_CREATED = 0, /// /// Sent by a task dialog when navigation has occurred. This notification code is received only through the task dialog callback /// function, which can be registered using the TaskDialogIndirect method. /// TDN_NAVIGATED = 1, /// /// Sent by a task dialog when the user selects a button or command link in the task dialog. This notification code is received /// only through the task dialog callback function, which can be registered using the TaskDialogIndirect method. To prevent the /// task dialog from closing, the application must return S_FALSE, otherwise the task dialog is closed and the button ID is /// returned via the original application call. /// TDN_BUTTON_CLICKED = 2, /// /// Sent by a task dialog when the user clicks a hyperlink in the task dialog content. This notification code is received only /// through the task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_HYPERLINK_CLICKED = 3, /// /// Sent by a task dialog approximately every 200 milliseconds. This notification code is sent when the TDF_CALLBACK_TIMER flag /// has been set in the dwFlags member of the TASKDIALOGCONFIG structure that was passed to the TaskDialogIndirect function. This /// notification code is received only through the task dialog callback function, which can be registered using the /// TaskDialogIndirect method. /// TDN_TIMER = 4, /// /// Sent by a task dialog when it is destroyed and its window handle is no longer valid. This notification code is received only /// through the task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_DESTROYED = 5, /// /// Sent by a task dialog when the user selects a radio button or command link in the task dialog. This notification code is /// received only through the task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_RADIO_BUTTON_CLICKED = 6, /// /// Sent by a task dialog after the dialog has been created and before it is displayed. This notification code is received only /// through the task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_DIALOG_CONSTRUCTED = 7, /// /// Sent by a task dialog when the user clicks the task dialog verification check box. This notification code is received only /// through the task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_VERIFICATION_CLICKED = 8, /// /// Sent by a task dialog when the user presses F1 on the keyboard while the dialog has focus. This notification code is received /// only through the task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_HELP = 9, /// /// Sent by the task dialog when the user clicks on the dialog's expando button. This notification is received only through the /// task dialog callback function, which can be registered using the TaskDialogIndirect method. /// TDN_EXPANDO_BUTTON_CLICKED = 10 } /// /// The TaskDialog function creates, displays, and operates a task dialog. The task dialog contains application-defined message text /// and title, icons, and any combination of predefined push buttons. This function does not support the registration of a callback /// function to receive notifications. /// /// /// Handle to the owner window of the task dialog to be created. If this parameter is NULL, the task dialog has no owner window. /// /// /// Handle to the module that contains the icon resource identified by the pszIcon member, and the string resources identified by the /// pszWindowTitle and pszMainInstruction members. If this parameter is NULL, pszIcon must be NULL or a pointer to a null-terminated, /// Unicode string that contains a system resource identifier, for example, TD_ERROR_ICON. /// /// /// Pointer to the string to be used for the task dialog title. This parameter is a null-terminated, Unicode string that contains /// either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. If this parameter is NULL, the filename /// of the executable program is used. /// /// /// Pointer to the string to be used for the main instruction. This parameter is a null-terminated, Unicode string that contains /// either text, or an integer resource identifier passed through the MAKEINTRESOURCE macro. This parameter can be NULL if no main /// instruction is wanted. /// /// /// Pointer to a string used for additional text that appears below the main instruction, in a smaller font. This parameter is a /// null-terminated, Unicode string that contains either text, or an integer resource identifier passed through the MAKEINTRESOURCE /// macro. Can be NULL if no additional text is wanted. /// /// /// Specifies the push buttons displayed in the dialog box. This parameter may be a combination of flags from the following group. /// /// /// Pointer to a string that identifies the icon to display in the task dialog. This parameter must be an integer resource identifier /// passed to the MAKEINTRESOURCE macro or one of the following predefined values. If this parameter is NULL, no icon will be /// displayed. If the hInstance parameter is NULL and one of the predefined values is not used, the TaskDialog function fails. /// /// /// When this function returns, contains a pointer to an integer location that receives one of the standard button result values. /// /// /// This function can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// The operation completed successfully. /// /// /// E_OUTOFMEMORY /// There is insufficient memory to complete the operation. /// /// /// E_INVALIDARG /// One or more arguments are not valid. /// /// /// E_FAIL /// The operation failed. /// /// /// [PInvokeData("Commctrl.h", MSDNShortId = "bb760540")] [DllImport(Lib.ComCtl32, CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern HRESULT TaskDialog(HWND hwndParent, HINSTANCE hInstance, string pszWindowTitle, string pszMainInstruction, string pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, SafeResourceId pszIcon, out int pnButton); /// /// The TaskDialogIndirect function creates, displays, and operates a task dialog. The task dialog contains application-defined /// icons, messages, title, verification check box, command links, push buttons, and radio buttons. This function can register a /// callback function to receive notification messages. /// /// Pointer to a TASKDIALOGCONFIG structure that contains information used to display the task dialog. /// /// Address of a variable that receives one of the button IDs specified in the pButtons member of the pTaskConfig parameter or a /// standard button ID value. /// /// /// Address of a variable that receives one of the button IDs specified in the pRadioButtons member of the pTaskConfig parameter. If /// this parameter is NULL, no value is returned. /// /// /// Address of a variable that receives a value indicating if the verification checkbox was checked when the dialog was dismissed. /// /// /// This function can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// The operation completed successfully. /// /// /// E_OUTOFMEMORY /// There is insufficient memory to complete the operation. /// /// /// E_INVALIDARG /// One or more arguments are not valid. /// /// /// E_FAIL /// The operation failed. /// /// /// [PInvokeData("Commctrl.h", MSDNShortId = "bb760544")] [DllImport(Lib.ComCtl32, CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern HRESULT TaskDialogIndirect([In] TASKDIALOGCONFIG pTaskConfig, out int pnButton, out int pnRadioButton, [MarshalAs(UnmanagedType.Bool)] out bool pfVerificationFlagChecked); /// /// The TASKDIALOG_BUTTON structure contains information used to display a button in a task dialog. The TASKDIALOGCONFIG structure /// uses this structure. /// [PInvokeData("Commctrl.h", MSDNShortId = "bb787475")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct TASKDIALOG_BUTTON { /// Indicates the value to be returned when this button is selected. public int nButtonID; /// /// Pointer that references the string to be used to label the button. This parameter can be either a null-terminated string or /// an integer resource identifier passed to the MAKEINTRESOURCE macro. When using Command Links, you delineate the command from /// the note by placing a new line character in the string. /// public IntPtr pszButtonText; } /// /// The TASKDIALOGCONFIG structure contains information used to display a task dialog. The TaskDialogIndirect function uses /// this structure. /// // https://docs.microsoft.com/en-us/windows/desktop/api/commctrl/ns-commctrl-_taskdialogconfig [PInvokeData("commctrl.h", MSDNShortId = "bb787473")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)] public class TASKDIALOGCONFIG : IDisposable { /// Specifies the structure size, in bytes. public uint cbSize; /// Handle to the parent window. This member can be NULL. public HWND hwndParent; /// /// Handle to the module that contains the icon resource identified by the pszMainIcon or pszFooterIcon members, and the string /// resources identified by the pszWindowTitle, pszMainInstruction, pszContent, pszVerificationText, pszExpandedInformation, /// pszExpandedControlText, pszCollapsedControlText or pszFooter members. /// public HINSTANCE hInstance; /// Specifies the behavior of the task dialog. This parameter can be a combination of flags. public TASKDIALOG_FLAGS dwFlags; /// /// Specifies the push buttons displayed in the task dialog. If no common buttons are specified and no custom buttons are /// specified using the cButtons and pButtons members, the task dialog will contain the OK button by default. This parameter may /// be a combination of flags. /// public TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons; /// /// Pointer that references the string to be used for the task dialog title. This parameter can be either a null-terminated /// string or an integer resource identifier passed to the MAKEINTRESOURCE macro. If this parameter is NULL, the filename of the /// executable program is used. /// public IntPtr pszWindowTitle; /// /// A handle to an Icon that is to be displayed in the task dialog. This member is ignored unless the TDF_USE_HICON_MAIN flag is /// specified. If this member is NULL and the TDF_USE_HICON_MAIN is specified, no icon will be displayed. /// OR /// /// Pointer that references the icon to be displayed in the task dialog. This parameter is ignored if the USE_HICON_MAIN flag is /// specified. Otherwise, if this parameter is NULL or the hInstance parameter is NULL, no icon will be displayed. This parameter /// must be an integer resource identifier passed to the MAKEINTRESOURCE macro. /// /// public IntPtr mainIcon; /// /// Pointer that references the string to be used for the main instruction. This parameter can be either a null-terminated string /// or an integer resource identifier passed to the MAKEINTRESOURCE macro. /// public IntPtr pszMainInstruction; /// /// Pointer that references the string to be used for the dialog's primary content. This parameter can be either a /// null-terminated string or an integer resource identifier passed to the MAKEINTRESOURCE macro. If the ENABLE_HYPERLINKS flag /// is specified for the dwFlags member, then this string may contain hyperlinks in the form: Hyperlink Text. WARNING: Enabling hyperlinks when using content from an unsafe source may cause /// security vulnerabilities. /// public IntPtr pszContent; /// /// The number of entries in the pButtons array that is used to create buttons or command links in the task dialog. If this /// member is zero and no common buttons have been specified using the dwCommonButtons member, then the task dialog will have a /// single OK button displayed. /// public uint cButtons; /// /// Pointer to an array of TASKDIALOG_BUTTON structures containing the definition of the custom buttons that are to be displayed /// in the task dialog. This array must contain at least the number of entries that are specified by the cButtons member. /// public IntPtr pButtons; /// /// The default button for the task dialog. This may be any of the values specified in nButtonID members of one of the /// TASKDIALOG_BUTTON structures in the pButtons array, or one of the IDs corresponding to the buttons specified in the /// dwCommonButtons member. If this member is zero or its value does not correspond to any button ID in the dialog, then the /// first button in the dialog will be the default. /// public int nDefaultButton; /// The number of entries in the pRadioButtons array that is used to create radio buttons in the task dialog. public uint cRadioButtons; /// /// Pointer to an array of TASKDIALOG_BUTTON structures containing the definition of the radio buttons that are to be displayed /// in the task dialog. This array must contain at least the number of entries that are specified by the cRadioButtons member. /// This parameter can be NULL. /// public IntPtr pRadioButtons; /// /// The button ID of the radio button that is selected by default. If this value does not correspond to a button ID, the first /// button in the array is selected by default. /// public int nDefaultRadioButton; /// /// Pointer that references the string to be used to label the verification checkbox. This parameter can be either a /// null-terminated string or an integer resource identifier passed to the MAKEINTRESOURCE macro. If this parameter is NULL, the /// verification checkbox is not displayed in the task dialog. If the pfVerificationFlagChecked parameter of TaskDialogIndirect /// is NULL, the checkbox is not enabled. /// public IntPtr pszVerificationText; /// /// Pointer that references the string to be used for displaying additional information. This parameter can be either a /// null-terminated string or an integer resource identifier passed to the MAKEINTRESOURCE macro. The additional information is /// displayed either immediately below the content or below the footer text depending on whether the TDF_EXPAND_FOOTER_AREA flag /// is specified. If the TDF_ENABLE_HYPERLINKS flag is specified for the dwFlags member, then this string may contain hyperlinks /// in the form: Hyperlink Text. WARNING: Enabling hyperlinks when using content from an unsafe /// source may cause security vulnerabilities. /// public IntPtr pszExpandedInformation; /// /// Pointer that references the string to be used to label the button for collapsing the expandable information. This parameter /// can be either a null-terminated string or an integer resource identifier passed to the MAKEINTRESOURCE macro. This member is /// ignored when the pszExpandedInformation member is NULL. If this member is NULL and the pszCollapsedControlText is specified, /// then the pszCollapsedControlText value will be used for this member as well. /// public IntPtr pszExpandedControlText; /// /// Pointer that references the string to be used to label the button for expanding the expandable information. This parameter /// can be either a null-terminated string or an integer resource identifier passed to the MAKEINTRESOURCE macro. This member is /// ignored when the pszExpandedInformation member is NULL. If this member is NULL and the pszCollapsedControlText is specified, /// then the pszCollapsedControlText value will be used for this member as well. /// public IntPtr pszCollapsedControlText; /// /// A handle to an Icon that is to be displayed in the footer of the task dialog. This member is ignored unless the /// TDF_USE_HICON_FOOTER flag is specified and the pszFooterIcon is not. If this member is NULL and the TDF_USE_HICON_FOOTER is /// specified, no icon is displayed. /// OR /// /// Pointer that references the icon to be displayed in the footer area of the task dialog. This parameter is ignored if the /// TDF_USE_HICON_FOOTER flag is specified, or if pszFooter is NULL. Otherwise, if this parameter is NULL or the hInstance /// parameter is NULL, no icon is displayed. This parameter must be an integer resource identifier passed to the MAKEINTRESOURCE /// macro or one of the predefined values listed for pszMainIcon. /// /// public IntPtr footerIcon; /// /// Pointer to the string to be used in the footer area of the task dialog. This parameter can be either a null-terminated string /// or an integer resource identifier passed to the MAKEINTRESOURCE macro. If the TDF_ENABLE_HYPERLINKS flag is specified for the /// dwFlags member, then this string may contain hyperlinks in this form. /// <A HREF="executablestring">Hyperlink Text</A> /// Enabling hyperlinks when using content from an unsafe source may cause security vulnerabilities. /// public IntPtr pszFooter; /// Pointer to an application-defined callback function. For more information see TaskDialogCallbackProc. [MarshalAs(UnmanagedType.FunctionPtr)] public TaskDialogCallbackProc pfCallbackProc; /// A pointer to application-defined reference data. This value is defined by the caller. public IntPtr lpCallbackData; /// /// The width of the task dialog's client area, in dialog units. If 0, the task dialog manager will calculate the ideal width. /// public uint cxWidth; /// /// Initializes a new instance of the class setting the field properly. /// public TASKDIALOGCONFIG() { cbSize = (uint)Marshal.SizeOf(typeof(TASKDIALOGCONFIG)); } /// /// The string to be used for the task dialog title. If this parameter is NULL, the filename of the executable program is used. /// public string WindowTitle { get => SafeResourceId.GetString(pszWindowTitle, CharSet.Unicode); set => StringHelper.RefreshString(ref pszWindowTitle, out var _, value, CharSet.Unicode); } /// The string to be used for the main instruction. public string MainInstruction { get => SafeResourceId.GetString(pszMainInstruction, CharSet.Unicode); set => StringHelper.RefreshString(ref pszMainInstruction, out var _, value, CharSet.Unicode); } /// /// The string to be used for the dialog's primary content. If the ENABLE_HYPERLINKS flag is specified for the dwFlags member, /// then this string may contain hyperlinks in the form: <A HREF="executablestring">Hyperlink Text</A>. WARNING: /// Enabling hyperlinks when using content from an unsafe source may cause security vulnerabilities. /// public string Content { get => SafeResourceId.GetString(pszContent, CharSet.Unicode); set => StringHelper.RefreshString(ref pszContent, out var _, value, CharSet.Unicode); } /// /// The string to be used to label the verification checkbox. If this parameter is NULL, the verification checkbox is not /// displayed in the task dialog. If the pfVerificationFlagChecked parameter of TaskDialogIndirect is NULL, the checkbox is not enabled. /// public string VerificationText { get => SafeResourceId.GetString(pszVerificationText, CharSet.Unicode); set => StringHelper.RefreshString(ref pszVerificationText, out var _, value, CharSet.Unicode); } /// /// The string to be used for displaying additional information. The additional information is displayed either immediately below /// the content or below the footer text depending on whether the TDF_EXPAND_FOOTER_AREA flag is specified. If the /// TDF_ENABLE_HYPERLINKS flag is specified for the dwFlags member, then this string may contain hyperlinks in the form: <A /// HREF="executablestring">Hyperlink Text</A>. WARNING: Enabling hyperlinks when using content from an unsafe source /// may cause security vulnerabilities. /// public string ExpandedInformation { get => SafeResourceId.GetString(pszExpandedInformation, CharSet.Unicode); set => StringHelper.RefreshString(ref pszExpandedInformation, out var _, value, CharSet.Unicode); } /// /// The string to be used to label the button for collapsing the expandable information. This member is ignored when the /// pszExpandedInformation member is NULL. If this member is NULL and the pszCollapsedControlText is specified, then the /// pszCollapsedControlText value will be used for this member as well. /// public string ExpandedControlText { get => SafeResourceId.GetString(pszExpandedControlText, CharSet.Unicode); set => StringHelper.RefreshString(ref pszExpandedControlText, out var _, value, CharSet.Unicode); } /// /// The string to be used to label the button for expanding the expandable information. This member is ignored when the /// pszExpandedInformation member is NULL. If this member is NULL and the pszCollapsedControlText is specified, then the /// pszCollapsedControlText value will be used for this member as well. /// public string CollapsedControlText { get => SafeResourceId.GetString(pszCollapsedControlText, CharSet.Unicode); set => StringHelper.RefreshString(ref pszCollapsedControlText, out var _, value, CharSet.Unicode); } /// /// The string to be used in the footer area of the task dialog. If the TDF_ENABLE_HYPERLINKS flag is specified for the dwFlags /// member, then this string may contain hyperlinks in this form. /// <A HREF="executablestring">Hyperlink Text</A> /// Enabling hyperlinks when using content from an unsafe source may cause security vulnerabilities. /// public string Footer { get => SafeResourceId.GetString(pszFooter, CharSet.Unicode); set => StringHelper.RefreshString(ref pszFooter, out var _, value, CharSet.Unicode); } /// void IDisposable.Dispose() { FreeResource(ref pszWindowTitle); FreeResource(ref pszMainInstruction); FreeResource(ref pszContent); FreeResource(ref pszVerificationText); FreeResource(ref pszExpandedInformation); FreeResource(ref pszExpandedControlText); FreeResource(ref pszCollapsedControlText); FreeResource(ref pszFooter); } private static void FreeResource(ref IntPtr ptr) { StringHelper.FreeString(ptr, CharSet.Unicode); ptr = IntPtr.Zero; } } } }