Jump to content
stacker_liew

MessageDlg, mtConfirmation Wrong After Delphi 10.4

Recommended Posts

From Delphi 10.4, while using MessageDlg with mtConfirmation, the Icon change from Confirm to Info. Here are examples demo.

Delphi 10.3.png

Delphi 10.4+.png

Edited by stacker_liew

Share this post


Link to post

It's not a Delphi thing, it's a Windows thing.  I created a small test app that displays messages boxes and can be compiled in multiple versions of Delphi. I tried Delphi 11, 10.4, 10.1, XE2, and XE and on Windows 10 and 11, they all show the same "i" icon for confirmation.  Then I pulled up an old virtual machine with Windows 8.1 and recompiled it in Delphi XE (the only version of Delphi I had on that machine) and it showed the good old question mark.

Share this post


Link to post

It is even documented:

Quote

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.

 

  • Like 3

Share this post


Link to post
1 hour ago, Uwe Raabe said:

Seems that Microsoft has just closed that loophole.

But how come my Delphi 10.3.3 still can use in Windows 11?

Share this post


Link to post
30 minutes ago, stacker_liew said:

But how come my Delphi 10.3.3 still can use in Windows 11?

Show us the code that calls this dialog box. Perhaps there's something else we're not understanding about what you're doing.

Share this post


Link to post
1 hour ago, corneliusdavid said:

Show us the code that calls this dialog box. Perhaps there's something else we're not understanding about what you're doing.

procedure TFireDACDemoForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  case MessageDlg('Ready To Quit?', mtConfirmation, [mbYes, mbNo], 0) of
    mrYes:
      CanClose := True;
    mrNo:
      CanClose := False;
  end;
end;

That's my code.

Share this post


Link to post

You know, I never asked whether this was VCL or FireMonkey--I just assumed VCL.  I just added a FireMonkey app to my simple demo on GitHub and its Confirmation is still a question mark with both Delphi 10.4 and 11. I've attached a screenshot.

 

DelphiMessageDlgBoxesFMX.png

Share this post


Link to post

In the later versions Delphi checks for Windows 8+ and uses the MS approach. So the docwiki is outdated and has to be corrected.

Share this post


Link to post
6 hours ago, Uwe Raabe said:

In the later versions Delphi checks for Windows 8+ and uses the MS approach. So the docwiki is outdated and has to be corrected.

I see. Thanks.

Share this post


Link to post
9 hours ago, corneliusdavid said:

You know, I never asked whether this was VCL or FireMonkey--I just assumed VCL.  I just added a FireMonkey app to my simple demo on GitHub and its Confirmation is still a question mark with both Delphi 10.4 and 11. I've attached a screenshot.

 

DelphiMessageDlgBoxesFMX.png

I haven't try with FMX, but I guess FMX is using different approach compare to VCL.

Share this post


Link to post

Hi...😉

 

How about using a own TForm as a MessageDlg?

...own design, formatted texts (TStringlist etc.), own icons? 😎

Share this post


Link to post

Looking at the current VCL implementation it would be little work to show the question mark icon for mtConfirmation.

The current behavior is a deliberate decision and probably targeted to match the Windows design.

Imagine a user having different icons for confirmation messages depending on the IDE used to compile the program.

So I think the message anyone should ask itself: Do I want a look and feel different to the standard Windows one?

Share this post


Link to post

Noting the comments above, if I'm asking the user a question that needs an answer, I want a question mark. My fix is to create a descendant of TTaskDialog, put the question mark in a resource file and load it immediately after creating the dialog

     

CustomMainIcon.LoadFromResourceName(HInstance, 'QUESTION_BLUE');
      Flags := Flags + [tfUseHIconMain];

 

See https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Dialogs.TTaskDialog.CustomMainIcon

 

Tony Bryer, Greentram Software Pty Ltd

Edited by TonyB

Share this post


Link to post

Hence I use CreateMessageDialog perhaps you can change Icon it self like this:

 

var
  Dlg: TForm;
  ...
begin
  Dlg:=CreateMessageDialog('My Message', mtConfirmation, [mbOk, mbCancel]);
  //change icon
  TImage(Dlg.FindComponent('Image')).Picture.Icon.Handle := LoadIcon( 0, IDI_QUESTION);
  try
    Result:=Dlg.ShowModal;
  finally
    Dlg.Free;
  end;
end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×