getting decission from message box?

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

Join Date: Dec 2007
Posts: 15
Reputation: cruisx is an unknown quantity at this point 
Solved Threads: 0
cruisx cruisx is offline Offline
Newbie Poster

getting decission from message box?

 
0
  #1
May 13th, 2009
hi guys, new to c++ here. So we have a school project due tomorrow, a hangman game of sort and i just wanted to go a bit above the required so i thought i would put in a message box. Now i got the working and all but the thing is, i would like to figure out that if the user clicks NO then the program exits? how can i do this?

  1. LPCTSTR Cap = L"HOW TO PLAY HANGMAN";
  2. MessageBox(NULL, L"sample",Cap, MB_YESNOCANCEL );

as you can see, my msg box has 3 click able buttons, YES NO and CANCLE. How can i make my program do something is say NO is pressed?

like
if NO is pressed
exit


thank you!
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 960
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: getting decission from message box?

 
0
  #2
May 13th, 2009
It's in the return value. Read the MSDN page.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 360
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: getting decission from message box?

 
0
  #3
May 14th, 2009
It's the same as for AfxMessageBox: http://msdn.microsoft.com/en-us/libr...cb(VS.71).aspx
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: getting decission from message box?

 
-1
  #4
May 14th, 2009
  1. int DisplayMessageBox()
  2. {
  3. int msgboxID = MessageBox(
  4. NULL,
  5. (LPCWSTR)L"Sample",
  6. Cap,
  7. MB_YESNOCANCEL
  8. );
  9.  
  10. switch (msgboxID)
  11. {
  12. case IDCANCEL:
  13. // TODO: add code
  14. break;
  15. case IDYES:
  16. // TODO: add code
  17. break;
  18. case IDNO:
  19. // TODO: add code
  20. break;
  21. }
  22.  
  23. return msgboxID;
  24. }
Last edited by Narue; May 14th, 2009 at 3:54 pm. Reason: added code tags
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC