[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

What is the best way to terminate an application without getting runtime error messages (at application startup)

Posted on 2004-04-19
5
Medium Priority
?
425 Views
Last Modified: 2010-05-18
Im trying to use a splash/login screen at the beginning of my application.
If they press the cancel button though, i.e. they dont want to login, they started the app by accident, I just want the program to stop

I presumed it was  >Application.Terminate<  but I get error messages.
What lines of code am I missing so that I close the application correctly

Thanks in advance
0
Comment
Question by:mikelittlewood
[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
5 Comments
 
LVL 4

Expert Comment

by:mbprogrammer
ID: 10858747
you can use Application terminate in your splash form and then place the following lines in your project pas file after calling the splash if its a showmodal otherwise place it before Application.Run if it (splash form) isn't  a ShowModal form;

var
  P:Pointer;
begin

  //----- Your code showing splash
       if(Application.Terminated) then
       begin
           P := @Application.Mainform;
           Pointer(P^) := SplashForm;
          //  In C++Builder
          //*(&(Application->MainForm)) = (TForm *)SplashForm;
           Application.Run();
           exit;
      end;
  //----- Your code
end;


or you can use ExitProcess instead of all above . but sometimes it raises an exception which could not be handled by normal try catch .
0
 
LVL 20

Accepted Solution

by:
Madshi earned 200 total points
ID: 10860311
ExitProcess almost always works without any errors.
0
 

Expert Comment

by:ckiraly
ID: 10860347
I've used the following in several programs without problems:

TfrmSplash.btCancel;
begin

end;
0
 

Expert Comment

by:ckiraly
ID: 10860443
Sorry - that submitted before I was finished typing it out...

TfrmSplash.btCancelClick(Sender: TObject);
begin

application.Terminate;
exit;

end;   //cancel button

HOWEVER...

If your splash screen normally loads from other forms, you can do this:

on your loading form (such as Datamod1) set up a global variable:

flgCancel:  Boolean;

then in your formcreate:

procedure TDM1.DataModuleCreate(Sender: TObject);
begin
flgCancel := False;

if SplashScreen = nil then
   Application.CreateForm (TSplashScreen, SplashScreen);

SplashScreen.showmodal();

if flgCancel then
   begin
   application.terminate;
   exit;
   end;

end;   //datamod create

Then, on the splashscreen form have your cancel button:

TSplashScreen.btnCancelClick(Sender: TObject);
begin

flgCancel := True;
close;

end;   //cancel button

That should close your application without errors.  
0
 
LVL 15

Author Comment

by:mikelittlewood
ID: 10863075
Thanks for all help.

The exitprocess worked fine though I have taken note of the others for future reference
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

656 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