Exit(0) in "FormActivate" produces exception & error Cannot change Visible in Ohshow or OnHide

I inherited a program that I am now responsible for and in the "TfrmMain::FormActivate" routine there are a few places that check for an instrument alive on the GPIB bus and if its not, an error is displayed and then the code performs an "exit(0)".  When this happens and I'm in the debugger I get the following error message:

"Project RF_CCA_Ttest.exe raised exception class EInvalidOperation with message 'Cannot change Visible in OnShow or OnHide'.  Process stopped.  Use step or Run to Continue."

I am in the FormActivate event procedure not an OnShow or OnHide.  Anyway how can I shut the program down from within the FormActivate event procedure?

Thanks!
stimmisAsked:
Who is Participating?
 
CayceCommented:
Application->Terminate() should do fine.

If it doesn't on your application then you need to close a couple forms before terminating.
0
 
George TokasCommented:
Right Cayce...
Also any exception raised on debug mode will not be showed at release mode.

gtokas.
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.