-
Notifications
You must be signed in to change notification settings - Fork 0
TDMessageBox function (Version 1.0)
Davide_24 edited this page Aug 26, 2024
·
1 revision
The TDMessageBox function generates a TaskDialogIndirect with your custom appearance. This page will cover what the arguments do and how they should be used. This wiki is not finished and there will be changed here at some point.
- The HWND value is the parent window of the message box. This functions in the exact same way as the HWND parameter inside of the standard win32 MessageBox() function. Generally, this value should be 0 or NULL.
- This defines the HINSTANCE which is given to the Dialog. This value can be set to 0 or NULL if you do not use custom icons. Otherwise, you must set this to your application's HINSTANCE in order for the custom icons to work.
- This directly sets the _TASKDIALOG_FLAGS of the TaskDialogIndirect.
- The documentation of these different flags can be found at https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-taskdialogconfig under the TASKDIALOG_FLAGS section.
- It is crucial to note, that you should not use TDF_USE_HICON_*, because it is already being set automatically by the wrapper.
- Another thing to note is that the TDF_ENABLE_HYPERLINKS flag actually opens hyperlinks inside your web browser. The wrapper added this functionality.
- This value gets changed to the user's pressed button when the dialog closes. This gets adjusted to the button's ID.
- These two variables function just like their MessageBox() counterparts. "title" corresponds to the dialog's title, while "text" corresponds to its content text.
- This value is purely optional. When this parameter is set to a non-default value, it creates a big blue header text above the normal text. This header text can give the dialog more depth. It is recommended to use this to display the cause of the dialog, instead of offloading that into the dialog's title.
- When this parameter is set to a non-default value, it creates a "footer" at the bottom of the dialog which holds the footer text.
- When this parameter is set to a non-default value, it creates a checkbox near your button. The state of the checkbox can be read by the next parameter. This property sets the text which is displayed next to the checkbox.
- This parameter exists to read the state of the checkbox when the dialog has been closed.
- When this parameter is set to a non-default value, it creates an expand button, which hides the checkbox. The text corresponds to the "text" of the expand button. A good example would be "See more."
- Setting these values adds icons to the messagebox. The "MainIcon" is the big messagebox icon. The "FooterIcon" is the icon displayed next to the footer text.
- Not setting this parameter will result in no buttons showing up inside of the dialog. These are all of the default buttons:
Button Flag | Button ID |
---|---|
TDCBF_OK_BUTTON | 1 |
TDCBF_YES_BUTTON | 2 |
TDCBF_NO_BUTTON | 4 |
TDCBF_CANCEL_BUTTON | 8 |
TDCBF_RETRY_BUTTON | 10 |
TDCBF_CLOSE_BUTTON | 20 |
- This parameter can be used to add custom buttons with custom IDs with a vector. Here is an example on how to make this construct. The first value corresponds to the button's ID while the second value is the text of the button. Please note that it is not recommended to use the same ID as the default buttons.
std::vector<_TASKDIALOG_BUTTON> Buttons = {
{ 100, L"Button 1" },
{ 101, L"Button 2" }
};
- If this value is set to a button's ID, then that button will get highlighted in blue. This is also called the default / preferred button.
- This is a vector of button IDs. Buttons inside of this vector will have an administrator shield icon next to them. These are used to signal that an action requires elevated privileges.
- This parameter acts the same as CustomButtons_opt. The only difference is that this will display radio buttons instead. There are no default radio buttons. Radio buttons can use the same ID as normal buttons because their selection is processed somewhere else.
- This value will be set to the selected radio button when the dialog is closed.