0

hi guys, new to c++ here. So we have a school project due tomorrow, a hangman game of sort and i just wanted to go a bit above the required so i thought i would put in a message box. Now i got the working and all but the thing is, i would like to figure out that if the user clicks NO then the program exits? how can i do this?

LPCTSTR Cap = L"HOW TO PLAY HANGMAN";
	MessageBox(NULL, L"sample",Cap, MB_YESNOCANCEL );

as you can see, my msg box has 3 click able buttons, YES NO and CANCLE. How can i make my program do something is say NO is pressed?

like
if NO is pressed
exit


thank you!

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by dubeyprateek
-1
int DisplayMessageBox()
{
    int msgboxID = MessageBox(
        NULL,
        (LPCWSTR)L"Sample",
        Cap,
        MB_YESNOCANCEL 
    );

    switch (msgboxID)
    {
    case IDCANCEL:
        // TODO: add code
        break;
    case IDYES:
        // TODO: add code
        break;
    case IDNO:
        // TODO: add code
        break;
    }

    return msgboxID;
}
Votes + Comments
phear da bears u feed!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.