944,088 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3120
  • C++ RSS
Jul 1st, 2007
0

how do you store the respond to a MessageBox

Expand Post »
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
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
nadith_cs is offline Offline
13 posts
since Feb 2007
Jul 1st, 2007
0

Re: how do you store the respond to a MessageBox

try putting two colons in front as shown in this example.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Jul 1st, 2007
0

Re: how do you store the respond to a MessageBox

nop i have tried it b4.....plz let me know another method
Reputation Points: 11
Solved Threads: 0
Newbie Poster
nadith_cs is offline Offline
13 posts
since Feb 2007
Jul 1st, 2007
0

Re: how do you store the respond to a MessageBox

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
Reputation Points: 35
Solved Threads: 0
Light Poster
~Paul~ is offline Offline
31 posts
since May 2007
Jul 2nd, 2007
0

Re: how do you store the respond to a MessageBox

this is the usual method i use for a message box

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Jul 2nd, 2007
0

Re: how do you store the respond to a MessageBox

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
Reputation Points: 11
Solved Threads: 0
Newbie Poster
nadith_cs is offline Offline
13 posts
since Feb 2007
Jul 2nd, 2007
0

Re: how do you store the respond to a MessageBox

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

C++ Syntax (Toggle Plain Text)
  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
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Jun 8th, 2009
0

Re: how do you store the respond to a MessageBox

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

My code:
c++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nicklorion is offline Offline
7 posts
since Jan 2009
Jun 8th, 2009
0

Re: how do you store the respond to a MessageBox

Nevermind i solved it by doing the following:


My code:
c++ Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Nicklorion is offline Offline
7 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: build output path
Next Thread in C++ Forum Timeline: A little RTTI help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC