Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Application->Terminate() ???

Posted on 2000-04-08
5
Medium Priority
?
319 Views
Last Modified: 2010-04-10
Hello i am using Borland Builder 4 and have a problem with 'Application->Terminate()'

I have written some code (i have shown an excerp below). I am trying to terminate the application when a count is equal to 15. At the moment it doesn't work, i have debugged the code, and i have SEEN it perform the Application->Terminate() function, when i have stepped through it, but the program just continues on.

How can this be ? - What am i doing wrong.

Please help

thanx


if (RoadSign[i] == HotSpotNum)
{
sndPlaySound(String("Correct"+String(  Response)+String(".wav")).c_str(),SND_SYNC);

HotSpotList->HotSpot[HotSpotNum->MakeCold();

if (i == 8)
{
HotSpotList = new THotSpotList(this,String("2ndroad.bmp"),3);

Canvas->Draw(0,0,HotSpotList->bmpBackground);
}
else if (i == 15) //Terminate
{
Application->Terminate();
}

//Next sign to guess
sndPlaySound(String(HotSpotList->HotSpot[RoadSign[++i]]->GetText()+
String(".wav")).c_str(),SND_SYNC);
}
0
Comment
Question by:AntBon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2695908
I would guess that teh Terminate() function simply calls PostQuitMessage().  this will post a WM_QUIT to your message queue.  This will cause the application to termiante its message loop and then proceeed tot eh end of  WinMain() in order to terminate the application.  But the termination happens later, when this message is read from the queue.  You need to return to the message loop in order for this to occur.   There are ways to termiante the application immediately, like by callign TerminateProcess(), but that is usually not a good idea.  If possible, you should terminate by ending the message loop and ending main.
0
 

Author Comment

by:AntBon
ID: 2696039
Can you possible show me what you mean. I think i understand, after the Terminate() function, i used to have a
Application->ProcessMessages(), but this made no difference.

How can i return to the message loop then, so i can terminate from there.

thanks
0
 
LVL 22

Expert Comment

by:nietod
ID: 2696088
The code that is calling

Application->Terminate()

is probably called from the message loop or from something that is called from the message loop.  (Right?  this code is probably (ultimately) called from a message, like a mouse press or a command, right) So you just need to return (and return and return if needed)  to the message loop.

Note I am assuming that this is what Termiante() does, it is a reasonable assumption, but still an assumption.
0
 

Author Comment

by:AntBon
ID: 2696143
Thanks you were correct, i simply added a return statement after the terminate() statement, and it works fine.

I am not used to Windows programming, i am doing a course - and have an assignment to hand it.

So i may be asking more questions later on ...Hope you dont mind

anyway thanks again

0
 
LVL 22

Accepted Solution

by:
nietod earned 75 total points
ID: 2696236
Thanks,

Is this a windows programming course?  If not you probably don't need to be doing any of this.  Most non-windows based courses don't want you to teal with any windows speicifc GUI designs, like this.   Usually you would write a standard text-based (console) program.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

604 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