When calling:
AfxMessageBox(strMsg, MB_YESNO);
A messagebox with the buttons "Yes" and "No" is displayed. But the "X" (close button) in the upper right corner is disabled, and pressing ESC has no effect.
This is because the only valid results would be IDYES and IDNO, and not IDCANCEL.
Is there a quick way of getting this behavior enabled? What I would like to avoid:
In vista, when deleting a file, the dialog asking for confirmation has only "Yes" and "No" and can also be canceled with the close button or with ESC. I'm guessing it's a custom dialog.
AfxMessageBox() just calls MessageBox() internally. So, no, you can't get the behavior you want here without using MB_YESNOCANCEL which adds a button...
Not sre if does that but Hans Dietrich's free XMessageBox is a very feature-rich extension of the standard message box. You may want yo check it out.
Also, I don't quite understand why you don't want a Cancel button yet want a UI element that does the same but is not quite as explicit.
Edit: Answering your comment:
If 'No' is interchangeable with 'Cancel' then I think 'No' is a bad labelling choice. e.g.: Q asked by a DeleteFolder() function:
"Should I also empty the subfolders?". Obviously, no and Cancel/Escape do not have the same meaning.
OTOH, "Delete files?" looks like the buttons should be Yes/No. But I prefer OK/Cancel. Because you ask for user confirmation, not for more information from user. In such a case, having the Escape key/red cross to work is certainly a plus.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With