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!

It's in the return value. Read the MSDN page.

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;
}
commented: phear da bears u feed! -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.