How do I make an event handler for a button in the MessageBox?

I know how to make buttons with event handlers, and I somewhat know how to do this. What I do is this:

1
2
3
4
5
6
MessageBox(hwnd, "Do you really want to leave?", "Leaving?", MB_YESNO);

if("YES")
    PostQuitMessage(0);
else if("NO")
    //whatever I will put here... 


So, anyway, I put that but if I click No, it will do what I prompted 'yes' to do. How do I make 'no' to do a separate action?

1
2
3
4
5
6
7
8
9
10
11
12
int msg = MessageBox(NULL, L"Do you really want to leave?", L"Leaving?", MB_YESNO);

switch (msg)
{
case IDYES:
	MessageBox(NULL, L"Yes", NULL, MB_OK);
	break;

case IDNO:
	MessageBox(NULL, L"No", NULL, MB_OK);
	break;
}


MessageBox returns and int so you can get a value depending on the button.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505%28v=vs.85%29.aspx
Alright thanks for the link and answer. Both were Extremely helpful.
Topic archived. No new replies allowed.