In the software I maintain I plan to replace the old MessageBox
by TaskDialog
as suggested by Microsoft UI guidlines already quite some time ago.
The main issue I need to resolve is following:
The old message box invoked via MessageBox(... ,MB_OK)
(thus containing only an OK button) can be dismissed by pressing the Esc key.
But a TaskDialog
containing only an OK button cannot be dismissed by pressing Esc. This might have a negative impact on the user experience.
I tried to use TaskDialogIndirect
using the pfCallback
field, but if the there is no Cancel button in the task dialog, the callback function doesn't even get called.
Any ideas what can be done so Esc will dismiss such a task dialog?
The MSDN documentation for the TASKDIALOGCONFIG
structure says the following about the TDF_ALLOW_DIALOG_CANCELLATION
flag (the dwFlags
member):
Indicates that the dialog should be able to be closed using Alt-F4, Escape, and the title bar's close button even if no cancel button is specified in either the dwCommonButtons or pButtons members.
This flag also gives the dialog box a system menu (Alt+Space), so you can also close it by pressing Alt+Space and the underlined character in the system menu's "Close" item.