Board index » cppbuilder » Using CloseQuery() method in TCustomForm

Using CloseQuery() method in TCustomForm

I want to use the TCustomForm CloseQuery() method to determine if I can
close and free a form. However, if I issue a Close() method afterwards, the
CloseQuery() method is called again within the form object. Is there an
alternate method I can use that does what Close() does, but doesn't call the
CloseQuery() method?

Thanks in advance,

Dan

 

Re:Using CloseQuery() method in TCustomForm


Dan,

I'm not sure that I understand your question. When Close() is called
it will call CloseQuery() to see if it is allowed to close. That's
the way it works. If CloseQuery indicates that closure is allowed
then Close() will close the form. If CloseQuery indicates that
closure is not allowed Close() does nothing and that's the end of
that.

Quote
> However, if I issue a Close() method afterwards

Of course if your CloseQuery indicates that closure is not currently
allowed you will need to call Close() again eventually in response to
whatever future event requires it but that is not a continuation of
the previous closure attempt it is a fresh attempt and the call to
CloseQuery will occur again.

So think of Close and CloseQuery as being bound together into the
same thing.

You ask a form to close. If CloseQuery says 'no' then that's that.
You'll have to ask again. And again. And Again. Until CloseQuery
indicates 'yes'.

Andrue Cope
[Bicester, UK]

Re:Using CloseQuery() method in TCustomForm


Perhaps I was not precise enough.

I have building an app that embeds multiple forms into a single parent form
(not using MDI). The parent form is in control of freeing the forms that
become its children. What I want to do is have the parent form issue a
Close() method, but be able to determine if child form has not been closed
or not. I tried issuing a CloseQuery() method to get this value, but then
when I issue a Close() afterwards, the CloseQuery() method gets called
again.

Is there a way to know if a form has been closed after its Close() method
has been issued?

Dan

Re:Using CloseQuery() method in TCustomForm


Dan,

The solution I would probably adopt is for the parent to tell the child to
prepare for closure (just call a method that sets a flag) then modify the
child's OnCloseQuery() handler so that if this flag is set it always allows
the close to proceed.

One way to do this would be to have the child execute:

  OnCloseQuery=NULL;

Which will disable the handler and means that the next call to Close() will
initiate a close.

Andrue Cope
[Bicester, UK]

Re:Using CloseQuery() method in TCustomForm


Thanks for the assistance.

Dan

Quote
"Andrue Cope" <not.a.va...@email.address.sorry> wrote in message

news:VA.000009cd.01b65382@email.address.sorry...
Quote
> Dan,

> The solution I would probably adopt is for the parent to tell the child to
> prepare for closure (just call a method that sets a flag) then modify the
> child's OnCloseQuery() handler so that if this flag is set it always
allows
> the close to proceed.

> One way to do this would be to have the child execute:

>   OnCloseQuery=NULL;

> Which will disable the handler and means that the next call to Close()
will
> initiate a close.

> Andrue Cope
> [Bicester, UK]

Other Threads