| | |
how do you store the respond to a MessageBox
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2007
Posts: 13
Reputation:
Solved Threads: 0
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
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
Last edited by Ancient Dragon; Jul 1st, 2007 at 1:22 pm. Reason: disable smiles in text
try putting two colons in front as shown in this example.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: May 2007
Posts: 31
Reputation:
Solved Threads: 0
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

Then use and if statement to check what the result was and do what ever you want form there
My New Site: http://ultimatecode.net
Visual Basic 6!!
Visual Basic 6!!
this is the usual method i use for a message box
C++ Syntax (Toggle Plain Text)
if ( MessageBox::Show("Some Message", "Some Title", MessageBoxButtons::YesNo, MessageBoxIcon::Information) == DialogResult::Yes) { //write the code to do what i need }
Last edited by Killer_Typo; Jul 2nd, 2007 at 7:37 am.
Dont forget to spread the reputation to those that deserve!
Here are two working methods to store your return from a message box, using the C++ API version and the .NET Version
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
C++ Syntax (Toggle Plain Text)
/* 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
Dont forget to spread the reputation to those that deserve!
•
•
Join Date: Jan 2009
Posts: 7
Reputation:
Solved Threads: 0
Sorry for the bumb, didn't think i should open a new thread because this discribes exactly my problem.
My code:
It returns the following error:
error C2039: 'yes' : is not a member of 'System::Windows::Forms::Form:
ialogResult'
see Declaration of 'System::Windows::Forms::Form:
ialogResult'
error C2065: 'Yes' : Undeclared identifier.
Anybody a suggestion?
thnx in advanced
My code:
c++ Syntax (Toggle Plain Text)
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:
ialogResult'see Declaration of 'System::Windows::Forms::Form:
ialogResult' error C2065: 'Yes' : Undeclared identifier.
Anybody a suggestion?
thnx in advanced
Last edited by Nicklorion; Jun 8th, 2009 at 6:22 am.
•
•
Join Date: Jan 2009
Posts: 7
Reputation:
Solved Threads: 0
Nevermind i solved it by doing the following:
My code:
My code:
c++ Syntax (Toggle Plain Text)
System::Windows::Forms::DialogResult mbResult = MessageBox::Show(this, "text", "Title", MessageBoxButtons::YesNo, MessageBoxIcon::Warning); if(System::Windows::Forms::DialogResult::Yes == result) { this->Close(); }
![]() |
Similar Threads
- PLZ let me know how to store a respond of a MSG BOX (VB.NET)
- Pop3 Mail Watcher (Part 1) (Visual Basic 4 / 5 / 6)
- Were can I store an avitar. (Geeks' Lounge)
Other Threads in the C++ Forum
- Previous Thread: build output path
- Next Thread: A little RTTI help
Views: 2008 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






