AfxMessageBox to quit the Application

I am tryig to use the int returned from AfxMessageBox .If the user chooses Abort,I'd like to exit from the application

int nres=AfxMessageBox("wrong ",MB_ABORTRETRYIGNORE|MB_ICONSTOP);
if(nres==IDABORT)
{
     quit!
}
I get a compiler error saying "nres undeclared identifier",butt I have nres as an int just the prev line.Is there something
wrong with my declaration?
Thanks for any help
samroycAsked:
Who is Participating?
 
waysideCommented:
For the 'quit' part you have options:

sledgehammer approach:

  exit(0);


A better Windows way:

  PostQuitMessage(0);

0
 
Jaime OlivaresSoftware ArchitectCommented:
Appears to be ok, but I think your problem is in another portion of your code, maybe you can post a little more.
0
 
AxterCommented:
Hi samroyc,
>>      quit!
What is quit! ???

David Maisonave :-)
Cheers!
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Jaime OlivaresSoftware ArchitectCommented:
I sincerly hope the asker has not written quit! directly in the source code   ;)
0
 
samroycAuthor Commented:
No,the user has not written "quit",into source code!!
I guess I should have made it clearer,but the bottleneck is before the code gets to the
different commands I tried for" quit",including exit(0).My code doesnot enter the if loop as it cannot identify the integer
nres which I defined just the prev line.hence I substituted "quit" for anything that I wrote inside that loop.
My question is why does my code have a problem with the integer nres.I have checked for typos and case etc..
Thank you for the interest and help
0
 
Jaime OlivaresSoftware ArchitectCommented:
Please post some more code around the problem
0
 
AxterCommented:
What type of file do you have this code in?
Is it a *.cpp file or a *.c file?
Makre sure it's a *.cpp file, and not a *.c file.
0
 
waysideCommented:
This is quite strange...

Can you cut and paste 8 or 10 lines around this error, and paste in the *exact* error message that you are getting?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.