On Win 7, MessageDlg shows information icon instead of confirmation icon (question mark).
Here is the code:
MessageDlg('Are you sure you want to delete this file?'+ CRLF+ FileName, mtConfirmation, [mbYes, mbNo], 0)= mrYes
What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First, notice that a simple workaround is to use the Windows API
MessageBoxfunction instead:But why doesn’t
MessageDlgwork? Well,MessageDlgdoes one of two possible things. It uses the Windows Vista+ Task Dialog, if possible, that is, it the OS is Windows Vista or laterandthemes are enabledandtheUseLatestCommonDialogsglobal variable istrue(the default). If not, the VCL actually creates a customTFormand adds all buttons, labels, and icons manually (which is a bit odd if you ask me — why not simply useMessageBox?).The last approach supports the question-mark icon. Indeed, try
But this looks so ugly! Please don’t do this! It is stupid to create a custom message dialog instead of using the native OS dialogs!
Unfortunately, however, the Task Dialog does not support the question-mark icon (as a pre-defined icon). This is not a restriction of the
TTaskDialogwrapper, but a limitation of the Windows Task Dialog API. See the official documentation, for instance. There areTD_ERROR_ICON,TD_WARNING_ICON, andTD_INFORMATION_ICON, but no question-mark icon.Of course, the Task Dialog can use any icon. For instance, you can do
Notice that I fall back on the old
MessageBoxshould the Task Dialog API not be available.In principle, the
MessageDlgfunction could use additional logic to handle the question-mark case separately, in a way that differs from the information, warning, and error cases. This would have made themtConfirmationgive the right icon even with the Task Dialog, at the expence of slightly more complicated, and less elegant, VCL code. Apparently, however, Embarcadero chose the simpler alternative of simply pretending that you asked for the information icon.Still, I wonder why Microsoft chose not to include a TD_QUESTION_ICON constant in the API. Perhaps this icon is discouraged in their latest UI guidelines?