Board index » cppbuilder » Exit form -> exit program

Exit form -> exit program

Hi,
how can I tell the program, that when pressing the exit x on the upper
right corner of a form the program stops with a message
"Do you really want to stop bahbah.exe??"
Thanks in advance!
Martin
 

Re:Exit form -> exit program


Martin, try the: "OnExit"  Event of your Form...Place there:

AnsiString Message = "Want to quit...?";
Application->MessageBox(Message.c_str()  , "Application Title...",
MB_OKCANCEL + MB_ICONINFORMATION);

if(mbOK)
{
   //...do something...

Quote
}

if(mbcancel)
{
   //...do something else...

Quote
}

Hope it helps.....

Oren

Re:Exit form -> exit program


Quote
O...@bzffm.de wrote:
> Martin, try the: "OnExit"  Event of your Form...Place there:

> AnsiString Message = "Want to quit...?";
> Application->MessageBox(Message.c_str()  , "Application Title...",
> MB_OKCANCEL + MB_ICONINFORMATION);

> if(mbOK)
> {
>    //...do something...
> }
> if(mbcancel)
> {
>    //...do something else...
> }

> Hope it helps.....

> Oren

Thanks Oren,

but I cannot find an OnExit event. There is an OnHide, OnClose or
OnQueryClose event. Which one is linked with the exit button?

Martin

Re:Exit form -> exit program


Use OnCloseQuery, and set the CanClose parameter to true or false based on
the user's response

Gambit

Quote
mappie <map...@gmx.de> wrote in message news:39D4BCD2.85D53C48@gmx.de...
> but I cannot find an OnExit event. There is an OnHide, OnClose or
> OnQueryClose event. Which one is linked with the exit button?

Re:Exit form -> exit program


Use the OnQueryClose event.  It has a parameter called CanClose passed as a
reference.  If you don't want the from to close, just set this to false.
Quote
"mappie" <map...@gmx.de> wrote in message news:39D4BCD2.85D53C48@gmx.de...

> O...@bzffm.de wrote:

> > Martin, try the: "OnExit"  Event of your Form...Place there:

> > AnsiString Message = "Want to quit...?";
> > Application->MessageBox(Message.c_str()  , "Application Title...",
> > MB_OKCANCEL + MB_ICONINFORMATION);

> > if(mbOK)
> > {
> >    //...do something...
> > }
> > if(mbcancel)
> > {
> >    //...do something else...
> > }

> > Hope it helps.....

> > Oren

> Thanks Oren,

> but I cannot find an OnExit event. There is an OnHide, OnClose or
> OnQueryClose event. Which one is linked with the exit button?

> Martin

Other Threads