how do you store the respond to a MessageBox

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2007
Posts: 13
Reputation: nadith_cs is an unknown quantity at this point 
Solved Threads: 0
nadith_cs nadith_cs is offline Offline
Newbie Poster

how do you store the respond to a MessageBox

 
0
  #1
Jul 1st, 2007
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
Last edited by Ancient Dragon; Jul 1st, 2007 at 1:22 pm. Reason: disable smiles in text
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,639
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1497
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: how do you store the respond to a MessageBox

 
0
  #2
Jul 1st, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 13
Reputation: nadith_cs is an unknown quantity at this point 
Solved Threads: 0
nadith_cs nadith_cs is offline Offline
Newbie Poster

Re: how do you store the respond to a MessageBox

 
0
  #3
Jul 1st, 2007
nop i have tried it b4.....plz let me know another method
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 31
Reputation: ~Paul~ is an unknown quantity at this point 
Solved Threads: 0
~Paul~ ~Paul~ is offline Offline
Light Poster

Re: how do you store the respond to a MessageBox

 
0
  #4
Jul 1st, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: how do you store the respond to a MessageBox

 
0
  #5
Jul 2nd, 2007
this is the usual method i use for a message box

  1. if ( MessageBox::Show("Some Message",
  2. "Some Title",
  3. MessageBoxButtons::YesNo,
  4. MessageBoxIcon::Information) == DialogResult::Yes) {
  5. //write the code to do what i need
  6. }
Last edited by Killer_Typo; Jul 2nd, 2007 at 7:37 am.
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 13
Reputation: nadith_cs is an unknown quantity at this point 
Solved Threads: 0
nadith_cs nadith_cs is offline Offline
Newbie Poster

Re: how do you store the respond to a MessageBox

 
0
  #6
Jul 2nd, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: how do you store the respond to a MessageBox

 
0
  #7
Jul 2nd, 2007
Here are two working methods to store your return from a message box, using the C++ API version and the .NET Version

  1. /* WINDOWS API VERSION
  2. MessageBox (
  3. HWND Owner,
  4. LPCTSTR lpText,
  5. LPCTSTR lpCaption,
  6. UINT uType);
  7. */
  8. int messageResult = MessageBox( NULL, L"SOME MESSGE", L"Some Title", MB_OK);
  9.  
  10. if (messageResult == MB_OK) {
  11. //what to do with our result
  12. }
  13.  
  14. /*.NET VERSION
  15. MessageBox::Show(
  16. string Message,
  17. string Caption,
  18. MessageBoxButtons Buttons,
  19. MessageBoxIcons Icon);
  20. */
  21. DialogResult myResult = MessageBox::Show("SOME MESSAGE", "SOME TITLE", MessageBoxButtons::YesNo, MessageBoxIcon::Information);
  22.  
  23. if (myResult = DialogResult::Yes) {
  24. //should work
  25. }

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!
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 7
Reputation: Nicklorion is an unknown quantity at this point 
Solved Threads: 0
Nicklorion Nicklorion is offline Offline
Newbie Poster

Re: how do you store the respond to a MessageBox

 
0
  #8
Jun 8th, 2009
Sorry for the bumb, didn't think i should open a new thread because this discribes exactly my problem.

My code:
  1. System::Windows::Forms::DialogResult mbResult = MessageBox::Show(this, "text", "Title",
  2. MessageBoxButtons::YesNo, MessageBoxIcon::Warning);
  3.  
  4. if(myResult == ::DialogResult::Yes )
  5. {
  6. this->Close();
  7. }

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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 7
Reputation: Nicklorion is an unknown quantity at this point 
Solved Threads: 0
Nicklorion Nicklorion is offline Offline
Newbie Poster

Re: how do you store the respond to a MessageBox

 
0
  #9
Jun 8th, 2009
Nevermind i solved it by doing the following:


My code:
  1. System::Windows::Forms::DialogResult mbResult = MessageBox::Show(this, "text", "Title",
  2. MessageBoxButtons::YesNo, MessageBoxIcon::Warning);
  3.  
  4. if(System::Windows::Forms::DialogResult::Yes == result)
  5. {
  6. this->Close();
  7. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 2008 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC