I'm trying to use Myform C++ MessageBox to have buttons with text, which could do functions like Close or Yes and No, but I'm getting errors when I try to add buttons to MessageBox itself.
Errors:
'MessageBox' : ambiguous symbol IntelliSense: no instance of overloaded function
IntelliSense: no instance of overloaded function "System::Windows::Forms::MessageBox::Show" matches the argument list argument types are: (const char [12], System::Windows::Forms::MessageBoxButtons, System::Windows::Forms::MessageBoxIcon)
I have also used #include <windows.h>
code:
private: System::Void autoriusToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Close:\n"
"Program?", MessageBoxButtons::OK);
}
private: System::Void apieProgramaToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Choose your answer", MessageBoxButtons::YesNoCancel, MessageBoxIcon::Exclamation);
}
MessageBox::Show("Close:\nProgram?", MessageBoxButtons::OK);
MessageBox::Show("Choose your answer", MessageBoxButtons::YesNoCancel, MessageBoxIcon::Exclamation);
OK, your two method calls are looking for overloads that take (String^, MessageBoxButtons)
and (String^, MessageBoxButtons, MessageBoxIcon)
.
MSDN lists the overloads of MessageBox::Show
, and neither of those overloads is included. The closest overloads are (String^, String^, MessageBoxButtons)
and (String^, String^, MessageBoxButtons, MessageBoxIcon)
. In each of those, the second string is the message box caption, the text that will be displayed in the title bar of the message box.
Also, you do not need to #include <windows.h>
in order to call these .Net methods.
Something like this should do the trick for you:
MessageBox::Show("Close:\nProgram?", "My Fancy App", MessageBoxButtons::OK);
MessageBox::Show("Choose your answer", "My Fancy App", MessageBoxButtons::YesNoCancel, MessageBoxIcon::Exclamation);