MessageBox

I have some problems making messageboxes the way I want to.. If I just put the code
MessageBox(hwnd, sometext, caption, NULL) it workes, but when I try specifying buttons with MessageBoxButton it does't work. Does anyone know what the problem might be? Do I need to include something to be able to make it work?
closed account (z05DSL3A)
How are you trying it and in what way does it not work?
To create a message box with an 'OK' button, you do:
MessageBox(hwnd, sometext, caption, MB_OK);
Are you saying this doesn't work?
It didn't work when I tried to do it this way
MessageBoxButton button = MessageBoxButton.YesNoCancel;
MessageBox.Show(messageBoxText, caption, button, icon);

but MessageBox(hwnd, sometext, caption, MB_OK); worked so thank you!

(I'm quite new to this gui thing, so I might have a lot of stupid questions=P)


closed account (z05DSL3A)
MessageBox.Show() is for Windows forms (CLR).

If your project is not a Windows Forms one, that would explain why it failed and using MessageBox(hwnd...) is the correct way to go.

If the project is a Windows Forms one then MessageBox.Show() is the correct way to go rather than MessageBox(hwnd...).


Some code in how to get a response back:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int response = MessageBox( NULL, _T("A MessageBox question.\nDo you want to try again?"),
                                              _T("MessageBox Caption"),
                                             MB_ICONQUESTION | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2 );
switch(response)
{
  case IDCANCEL:
              // TODO: 
              break;
  case IDTRYAGAIN:
              // TODO: 
              break;
  case IDCONTINUE:
              // TODO: 
              break;
}
Topic archived. No new replies allowed.