I know its possible to do something like this with Windows:
MessageBox(hWnd, "Yes, No, or Cancel?", "YNCB_YESNOCANCEL);
But how do I react to what the user pressed (like closing the window if they clicked "yes")?
I know its possible to do something like this with Windows:
MessageBox(hWnd, "Yes, No, or Cancel?", "YNCB_YESNOCANCEL);
But how do I react to what the user pressed (like closing the window if they clicked "yes")?
MessageBox
will return a integer referring to the button pressed. From the previous link:
Return Value
IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDCONTINUE Continue button was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDTRYAGAIN Try Again button was selected.
IDYES Yes button was selected.
So something like:
int result = MessageBox(hWnd, "Save work?", MB_YESNOCANCEL);
if (result == IDOK)
{
// ...
}
else if (result == IDNO)
{
// ...
}
else // cancel
{
// ...
}