sorin sorin - 2 months ago 23
C++ Question

How to display a modal message box in C++ on Mac?

CFUserNotificationDisplayAlert and CFUserNotificationDisplayNotice creates a non-modal window and this is bad because it could bring your application UI in a very undesired state if you select the original application window (the message box is hidden but the applicaton does not respond).

The old

SystemAlert
was modal but this one doesn't fully support Unicode strings.

How can i display a message box as a modal window under Mac? I'm looking for someting similar to MessageBox from Windows?

Answer

It looks that CreateStandardAlert is the right solution because this one is modal.


DialogRef theItem;
DialogItemIndex itemIndex;
CreateStandardAlert(kAlertNoteAlert, CFSTR("aaa"), CFSTR("bbb"), NULL, &theItem);
RunStandardAlert(theItem, NULL, &itemIndex);
Comments