plz let me know how to store the respond and take some logical actions upon it in visual STUDIO windows form application
wht's the code for it;
note that msdn suggest that it should be
MessageBox::Show(" text here ", ,MessageBoxButtons::YesNo )==DialogResult::Yes

but it's not working;
DialogResult only has get() and set() methods

try putting two colons in front as shown in this example.

nop i have tried it b4.....plz let me know another method

You can store the result in a variable. An integer would work fine ;)

Then use and if statement to check what the result was and do what ever you want form there :D

this is the usual method i use for a message box

if ( MessageBox::Show("Some Message", 
"Some Title", 
MessageBoxButtons::YesNo, 
MessageBoxIcon::Information) == DialogResult::Yes) {
//write the code to do what i need
}

hello out there, the methods u submitted, are they ever worked in ur computer.......
becz i have tried those methods eairlier......
plz tell me whether u have used it b4 or not

Here are two working methods to store your return from a message box, using the C++ API version and the .NET Version

/* WINDOWS API VERSION
MessageBox (
HWND Owner,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType);
*/
int messageResult = MessageBox( NULL, L"SOME MESSGE", L"Some Title", MB_OK);
 
if (messageResult == MB_OK) {
  //what to do with our result
}
 
/*.NET VERSION
MessageBox::Show(
string Message,
string Caption,
MessageBoxButtons Buttons,
MessageBoxIcons Icon);
*/
DialogResult myResult = MessageBox::Show("SOME MESSAGE", "SOME TITLE", MessageBoxButtons::YesNo, MessageBoxIcon::Information);
 
if (myResult = DialogResult::Yes) {
   //should work
}

i've tested the C++ API version and is working, the .NET Version works fine in C# (i dont have a project open right now in C++ using the .NET namespaces) but following the same logic it should work.

if not shame on me lol

Sorry for the bumb, didn't think i should open a new thread because this discribes exactly my problem.

My code:

System::Windows::Forms::DialogResult mbResult = MessageBox::Show(this, "text", "Title", 
MessageBoxButtons::YesNo, MessageBoxIcon::Warning);

if(myResult == ::DialogResult::Yes )
{ 
       this->Close();
}

It returns the following error:
error C2039: 'yes' : is not a member of 'System::Windows::Forms::Form::DialogResult'
see Declaration of 'System::Windows::Forms::Form::DialogResult'
error C2065: 'Yes' : Undeclared identifier.

Anybody a suggestion?

thnx in advanced

Nevermind i solved it by doing the following:


My code:

System::Windows::Forms::DialogResult mbResult = MessageBox::Show(this, "text", "Title", 
MessageBoxButtons::YesNo, MessageBoxIcon::Warning);

if(System::Windows::Forms::DialogResult::Yes == result)
{ 
       this->Close();
}
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.