Wrong MessageDlg icon with DlgType mtConfirmation constant?
Asked Answered
A

1

7

In Delphi 10.1.2 Berlin, in a Vcl.Dialogs.MessageDlg function, the DlgType constants mtInformation and mtConfirmation create the same dialog icon. For example:

if Vcl.Dialogs.MessageDlg('Do you really want to remove the selected item?',  mtConfirmation, mbOKCancel, 0) = mrOk then
begin
  RemoveTheSelectedItem;
end;

enter image description here

if Vcl.Dialogs.MessageDlg('Do you really want to remove the selected item?',  mtInformation, mbOKCancel, 0) = mrOk then
begin
  RemoveTheSelectedItem;
end;

enter image description here

But shouldn't the DlgType constant mtConfirmation display a question mark icon, (as the other DlgType constants mtWarning and mtError create each a different icon)?

How can I get a question mark icon with the DlgType constant mtConfirmation?

Aristotelianism answered 13/10, 2017 at 7:43 Comment(1)
I had exactly this issue today!.. thanks for asking, and thanks to Tom for the answerKnowable
J
12

It is said in the help:

Having mtConfirmation Show a Question Mark

Dialog boxes of TMsgDlgType.mtConfirmation type show an information icon.

In the past, they used to show a question mark instead, but Microsoft removed the question mark symbol from the Windows API function that the VCL uses to display TMsgDlgType.mtConfirmation dialog boxes. Quoting Microsoft: "The question-mark message icon is no longer recommended because it does not clearly represent a specific type of message and because the phrasing of a message as a question could apply to any message type. In addition, users can confuse the message symbol question mark with Help information." To use the previous dialog box appearance, you must set the UseLatestCommonDialogs variable of the Vcl.Dialogs unit to False.

So this code:

  Vcl.Dialogs.UseLatestCommonDialogs := False;
  if Vcl.Dialogs.MessageDlg('Do you really want to remove the selected item?',  mtConfirmation, mbOKCancel, 0) = mrOk then
  begin
    RemoveTheSelectedItem;
  end;

produces this result:

enter image description here

Journey answered 13/10, 2017 at 9:28 Comment(1)
I really can't follow the logic of Microsoft. A symbol's meaning is always defined by its context. Which means: When a control on which I can act upon (e.g. a button) has a question mark symbol then I can use it to get information. But the question mark in the dialog cannot be acted upon and so it gives the dialog the meaning of BEING information.Aristotelianism

© 2022 - 2024 — McMap. All rights reserved.