How to check user selection(yes/no) on a Message Box

tnjgraham (26)
Hey,
I have a question. How can you tell what button(yes/no) on a message box is clicked? Below is what I have right now but I am getting errors.
1
2
3
if (MessageBox(NULL,"The Message", "The Title", MB_YESNO) == IDYES){
do somthing
}


Any help will be greatly appreciated.

Tiffanie
Disch (8615)
Aside from the mismatching tchar business, that code looks right to me. What errors are you getting?
tnjgraham (26)
Disch,
It says that I have too many inputs for MessageBox(). What way would you write code to achieve this?
Disch (8615)
Are you sure you posted the actual code that's giving you the error? Because that code works fine for me (after fixing the tchar thing, but that's likely not your problem) and does what you'd expect.

To clarify... this code works just fine:

1
2
3
4
5
6
7
8
    if (MessageBoxA(NULL,"The Message", "The Title", MB_YESNO) == IDYES)
    {
        MessageBoxA(NULL,"YES pressed","",MB_OK);
    }
    else
    {
        MessageBoxA(NULL,"NO pressed","",MB_OK);
    }
Last edited on
Registered users can post here. Sign in or register to post.