Board index » delphi » Easy question, I dare you to answer... (GRIN)

Easy question, I dare you to answer... (GRIN)

I have a data aware dialog form that contains code on the
'Close' button that asks if the data should be saved (if the
dataset is in Insert/Edit mode).  I provide a CANCEL button
to abort "Close" process.

Question: This works fine with a standard button, but using a
BitBtn will close the window anyway.  How can I prevent this
(ie, don't close unless I explicitly say "Close;")???

Andrew
--
------------------------------------------------------
 Some people just dream about possibilities...
   ... others stay up too late and make them happen.

 

Re:Easy question, I dare you to answer... (GRIN)


It's a cinch, change the ModalResult property to mrNone.

--
Paul Motyer  21:54 Sat, 14th September, 1996 EST
pa...@linuxserver.pccity.com.au
SoftStuff, Croydon, Vic,  Australia, 3136.

Andrew Hollands <andr...@cnw.com> wrote in article
<3239E405....@cnw.com>...

Quote
> I have a data aware dialog form that contains code on the
> 'Close' button that asks if the data should be saved (if the
> dataset is in Insert/Edit mode).  I provide a CANCEL button
> to abort "Close" process.

> Question: This works fine with a standard button, but using a
> BitBtn will close the window anyway.  How can I prevent this
> (ie, don't close unless I explicitly say "Close;")???

> Andrew
> --
> ------------------------------------------------------
>  Some people just dream about possibilities...
>    ... others stay up too late and make them happen.

Re:Easy question, I dare you to answer... (GRIN)


Quote
Andrew Hollands <andr...@cnw.com> wrote:
>I have a data aware dialog form that contains code on the
>'Close' button that asks if the data should be saved (if the
>dataset is in Insert/Edit mode).  I provide a CANCEL button
>to abort "Close" process.

>Question: This works fine with a standard button, but using a
>BitBtn will close the window anyway.  How can I prevent this
>(ie, don't close unless I explicitly say "Close;")???

Sounds like your form is being shown modally. TBitBtn has a property
called ModalResult which is the value which is placed in the
ModalResult property of TForm when you click the button. If you create
a BitBtn and set its Kind to bkCancel, when it is clicked it puts
mrCancel in the ModalResult of your form which closes it. Simply
change the value of ModalResult on the button to mrNone and this will
not happen.

***************************************************************************
* Time is an illusion, lunchtime doubly so... * Glenn Davies              *
* Drink up, the world's about to end !        * Gl...@home-pc.demon.co.uk *
***************************************************************************

Re:Easy question, I dare you to answer... (GRIN)


Try moving the code that asks if the data should be saved to the
OnCloseQuery event.

Quote
Andrew Hollands wrote:

> I have a data aware dialog form that contains code on the
> 'Close' button that asks if the data should be saved (if the
> dataset is in Insert/Edit mode).  I provide a CANCEL button
> to abort "Close" process.

> Question: This works fine with a standard button, but using a
> BitBtn will close the window anyway.  How can I prevent this
> (ie, don't close unless I explicitly say "Close;")???

> Andrew
> --
> ------------------------------------------------------
>  Some people just dream about possibilities...
>    ... others stay up too late and make them happen.

Re:Easy question, I dare you to answer... (GRIN)


On 17/09/1996 22:10, in message <323F05BB.4...@earthlink.net>, Dave Friend

Quote
<dafri...@earthlink.net> wrote:
> Try moving the code that asks if the data should be saved to the
> OnCloseQuery event.

THAT is not necessary. I do it a lot!

Quote
> > Question: This works fine with a standard button, but using a
> > BitBtn will close the window anyway.  How can I prevent this
> > (ie, don't close unless I explicitly say "Close;")???

Set the Cancel button's button type to btCustom.

The Form closes if the ModalResult of any button (that is pressed) is not equal
to zero.

Hope this helps!

Stefan

Other Threads