3

I display a message box using the AfxMessageBox keyword. Basic stuff.

But, due to the length of the path, it displays like this:

Message Box

Is there any way that I can stop it from word wrapping that way?

Sorry if this is a dumb question. But if I have a single sentence it would normally show wider.

Thank you.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164

2 Answers2

3

AfxMessageBox eventually calls MessageBox. There is no way for an application to (easily) modify, how the system displays the message box.

If you need a custom message box dialog, you will have to implement your own.

Background information on the evolution of the layout algorithm used by the MessageBox was published by Raymond Chen at The Old New Thing: Why doesn’t my MessageBox wrap at the right location?

IInspectable
  • 46,945
  • 8
  • 85
  • 181
1

You can override CWinApp::DoMessageBox on your derived class and supply your own message dialog, customized in the way you want. All AfxMessageBox calls will get your override in the way.

sergiol
  • 4,122
  • 4
  • 47
  • 81
  • 1
    Thanks! I just did a test and managed to get it to use `CTaskDialog` where I can set the width. But it is a bit fiddly to decode the `nType` into the respective buttons and main icon to use. That is my only issue now. – Andrew Truckle Feb 02 '21 at 15:56
  • 1
    Please see: https://stackoverflow.com/questions/66013767/converting-a-afxmessagebox-into-a-ctaskdialog-using-domessagebox – Andrew Truckle Feb 02 '21 at 16:43