AfxMessageBox to quit the Application

Posted on 2005-04-23
Last Modified: 2013-11-20
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);
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
Question by:samroyc
    LVL 55

    Expert Comment

    by:Jaime Olivares
    Appears to be ok, but I think your problem is in another portion of your code, maybe you can post a little more.
    LVL 30

    Expert Comment

    Hi samroyc,
    >>      quit!
    What is quit! ???

    David Maisonave :-)
    LVL 55

    Expert Comment

    by:Jaime Olivares
    I sincerly hope the asker has not written quit! directly in the source code   ;)
    LVL 14

    Accepted Solution

    For the 'quit' part you have options:

    sledgehammer approach:


    A better Windows way:



    Author Comment

    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
    LVL 55

    Expert Comment

    by:Jaime Olivares
    Please post some more code around the problem
    LVL 30

    Expert Comment

    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.
    LVL 14

    Expert Comment

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now