Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-04

Bug 15390 and Showmodal

23 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

patspiper

This is related to bug #15390:

My understanding is that Showmodal blocks until the form is closed. Hiding the form should have no effect.

   try
     Self.Hide;
     Form2.ShowModal; //<- this should block until Form2 is closed
   finally
     Self.Show; // <- this should not be reached until Form2 is closed
     Form2.Free;
   end;

What is happening is that Showmodal is exiting when the modal form is hidden.

Stephano

Reply by email

zeljko
to patspiper
patspiper wrote 8 lines
This is related to bug #15390: My understanding is that Showmodal blocks until the form is closed. Hiding the form should have no effect. try Self.Hide; Form2.ShowModal; //<- this should block until Form2 is closed

So, with your explanation: when you hide modal form it should stay in modal loop and application is completelly unresponsive ?

finally Self.Show; // <- this should not be reached until Form2 is closed

no, it will be reached as soon as form leaves *modal loop* for any reason (closing, hiding).

Show quoted text 5 lines
Form2.Free; end; What is happening is that Showmodal is exiting when the modal form is hidden.

No, FormClose() isn't called when modal form is hidden via Hide(); , so form still exists and it can be called with ShowModal() or Show() again.

zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120417/09cf7013/attachment.html>

Reply by email

patspiper
to zeljko
zeljko wrote 23 lines
On Tuesday 17 of April 2012 17:41:54 patspiper wrote: > This is related to bug #15390: > > My understanding is that Showmodal blocks until the form is closed. > Hiding the form should have no effect. > > try > Self.Hide; > Form2.ShowModal; //<- this should block until Form2 is closed So, with your explanation: when you hide modal form it should stay in modal loop and application is completelly unresponsive ?

Yes. The same situation occurs when a form in a single form project hides itself. The application will be running, but no form is displayed and the application is completely unresponsive (I have just checked that in Lazarus).

It is up to the programmer to make use of that fact. For example, a modal form can hide itself to show another modal form:

   try
     Self.Hide; // form1 hides itself
     Form2.ShowModal; // and displays form2
   finally
     Self.Show; // form1 shows itself after form2 is closed
     Form2.Free; // form2 is freed (it was already closed)
   end;
Show quoted text 10 lines
> finally > Self.Show; // <- this should not be reached until Form2 is closed no, it will be reached as soon as form leaves *modal loop* for any reason (closing, hiding).

According to Embarcadero: "ShowModal does not return until the form closes"

Show quoted text 15 lines
> Form2.Free; > end; > > What is happening is that Showmodal is exiting when the modal form is > hidden. No, FormClose() isn't called when modal form is hidden via Hide();

Correct

, so form still exists and it can be called with ShowModal() or Show() again.

I beg to differ here as Showmodal should not exit unless the modal form is closed.

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120417/8c3ca623/attachment.html>

Reply by email

Hans-Peter Diettrich
to patspiper
Show quoted text 9 lines
> No, FormClose() isn't called when modal form is hidden via Hide(); > Correct > > , so form still exists and it can be called with ShowModal() or Show() > again. > I beg to differ here as Showmodal should not exit unless the modal form is closed.

A modal form (dialog) can be used to accept multiple user entries (filename...). Then the form object must stay alife until the application has read all entries. That's why a modal form only hides itself on exit.

DoDi

Reply by email

Martin
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 17 lines
patspiper schrieb: >> No, FormClose() isn't called when modal form is hidden via Hide(); >> > Correct >> >> , so form still exists and it can be called with ShowModal() or >> Show() again. >> > I beg to differ here as Showmodal should not exit unless the modal > form is closed. A modal form (dialog) can be used to accept multiple user entries (filename...). Then the form object must stay alife until the application has read all entries. That's why a modal form only hides itself on exit.

closed destroy

Close() depends on close action, which include free and hide. Close() on a modal Form in LCL ignores close action and always hides (by setting ModalResult = mrCancel.

Hide() or Visible:=False does not set ModalResult

In fact if in Delphi you hide a modalform, then ShowModal does not return. I don't know, if this is intended or accidental behaviour. While of course you can use this, there is a real danger of such a modal form become hidden, with no means of ever getting it back or exiting it.

Using a hidden modal form, to block all other forms (even if intended) appears to me an abuse of the modal concept. If an application wants to do this, it should do this explicitly. (But that is my personal opinion)

In LCL there is
Screen.DisableForms()

Reply by email

zeljko
to Martin
Martin wrote 36 lines
On 18/04/2012 11:53, Hans-Peter Diettrich wrote: > patspiper schrieb: >>> No, FormClose() isn't called when modal form is hidden via Hide(); >> >> Correct >> >>> , so form still exists and it can be called with ShowModal() or >>> Show() again. >> >> I beg to differ here as Showmodal should not exit unless the modal >> form is closed. > > A modal form (dialog) can be used to accept multiple user entries > (filename...). Then the form object must stay alife until the > application has read all entries. That's why a modal form only hides > itself on exit. closed destroy Close() depends on close action, which include free and hide. Close() on a modal Form in LCL ignores close action and always hides (by setting ModalResult = mrCancel. Hide() or Visible:=False does not set ModalResult In fact if in Delphi you hide a modalform, then ShowModal does not return. I don't know, if this is intended or accidental behaviour. While of course you can use this, there is a real danger of such a modal form become hidden, with no means of ever getting it back or exiting it. Using a hidden modal form, to block all other forms (even if intended) appears to me an abuse of the modal concept. If an application wants to do this, it should do this explicitly. (But that is my personal opinion) In LCL there is Screen.DisableForms()

+1 , that's why I implemented hiding of modal form as it is - it simply works on all platforms, and Delphi behaviour looks pretty unlogical to me (but even that can work - see my today patches attached at issue).

zeljko

Show quoted text 7 lines
-- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/0823421e/attachment-0001.html>

Reply by email

Martin
to zeljko
zeljko wrote 14 lines
> > In LCL there is > Screen.DisableForms() +1 , that's why I implemented hiding of modal form as it is - it simply works on all platforms, and Delphi behaviour looks pretty unlogical to me (but even that can work - see my today patches attached at issue).

Well IMHO the problem is not to find a way to change it (though that might be on some platforms...)

The problem is:
There may be LCL apps out there relying on the current behaviour of Hide()

That raises the question: Is this issue important enough to risk breaking them.

If this was 100% clearly a bug. Or 100% clearly a break of compatibility to documented Delphi features, then maybe

But this is not a bug.
And Delphi docs, IMHO are not making a 100% clear statement about this.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/0d68ebb5/attachment.html>

Reply by email

William Oliveira Ferreira
to zeljko: So, with your explanation: when you hide modal form it should stay in modal loop and…

2012/4/17 zeljko

Show quoted text 27 lines
** On Tuesday 17 of April 2012 17:41:54 patspiper wrote: > This is related to bug #15390: > > My understanding is that Showmodal blocks until the form is closed. > Hiding the form should have no effect. > > try > Self.Hide; > Form2.ShowModal; //<- this should block until Form2 is closed So, with your explanation: when you hide modal form it should stay in modal loop and application is completelly unresponsive ?

should do this or raise a exception 'Can't hide a modal form', no? (i really don't know, it's a suggestion...)

Show quoted text 7 lines
-- ________________________________ William de Oliveira Ferreira Bacharel em Sistemas de Informa??o

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/94de73d9/attachment.html>

Reply by email

patspiper
to Martin: closed destroy Close() depends on close action, which include free and hide. Close() on…
Martin wrote 28 lines
On 18/04/2012 11:53, Hans-Peter Diettrich wrote: > patspiper schrieb: > >>> No, FormClose() isn't called when modal form is hidden via Hide(); >>> >> Correct >>> >>> , so form still exists and it can be called with ShowModal() or >>> Show() again. >>> >> I beg to differ here as Showmodal should not exit unless the modal >> form is closed. > > A modal form (dialog) can be used to accept multiple user entries > (filename...). Then the form object must stay alife until the > application has read all entries. That's why a modal form only hides > itself on exit. > closed destroy Close() depends on close action, which include free and hide. Close() on a modal Form in LCL ignores close action and always hides (by setting ModalResult = mrCancel. Hide() or Visible:=False does not set ModalResult In fact if in Delphi you hide a modalform, then ShowModal does not return.

Correct

I don't know, if this is intended or accidental behaviour.

It is intended behaviour. Embarcadero docs clearly state: "ShowModal does not return until the form closes"

Lazarus docs:
"Show this form as modal - ie control cannot be resumed by another form until the current form is closed"

While of course you can use this, there is a real danger of such a modal form become hidden, with no means of ever getting it back or exiting it.

This is fine especially that the same situation arises when the main form is hidden -> no means of ever getting it back or exiting it. It is up to the programmer to decide if he opts to hide it.

Stephano

Reply by email

patspiper
to zeljko: +1 , that's why I implemented hiding of modal form as it is - it simply works on all…
zeljko wrote 81 lines
On Wednesday 18 of April 2012 15:22:27 Martin wrote: > On 18/04/2012 11:53, Hans-Peter Diettrich wrote: > > patspiper schrieb: > >>> No, FormClose() isn't called when modal form is hidden via Hide(); > >> > >> Correct > >> > >>> , so form still exists and it can be called with ShowModal() or > >>> Show() again. > >> > >> I beg to differ here as Showmodal should not exit unless the modal > >> form is closed. > > > > A modal form (dialog) can be used to accept multiple user entries > > (filename...). Then the form object must stay alife until the > > application has read all entries. That's why a modal form only hides > > itself on exit. > > closed destroy > > Close() depends on close action, which include free and hide. > Close() on a modal Form in LCL ignores close action and always hides (by > setting ModalResult = mrCancel. > > Hide() or Visible:=False does not set ModalResult > > In fact if in Delphi you hide a modalform, then ShowModal does not > return. I don't know, if this is intended or accidental behaviour. > While of course you can use this, there is a real danger of such a modal > form become hidden, with no means of ever getting it back or exiting it. > > Using a hidden modal form, to block all other forms (even if intended) > appears to me an abuse of the modal concept. If an application wants to > do this, it should do this explicitly. (But that is my personal opinion) > > In LCL there is > Screen.DisableForms() +1 , that's why I implemented hiding of modal form as it is - it simply works on all platforms, and Delphi behaviour looks pretty unlogical to me (but even that can work - see my today patches attached at issue).

Patch is good but has one bug (Pls check bug report)

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/7e919d52/attachment.html>

Reply by email

patspiper
to Martin: Well IMHO the problem is not to find a way to change it (though that might be on some…
Martin wrote 23 lines
On 18/04/2012 15:27, zeljko wrote: > > > > > > In LCL there is > > > Screen.DisableForms() > > > > +1 , that's why I implemented hiding of modal > form as it is - it simply works on all platforms, and Delphi > behaviour looks pretty unlogical to me (but even that can work - > see my today patches attached at issue). > > Well IMHO the problem is not to find a way to change it (though that might be on some platforms...) The problem is: There may be LCL apps out there relying on the current behaviour of Hide()

I reported that behaviour as a bug in 2009.

That raises the question: Is this issue important enough to risk breaking them.

IMHO, it is.

Show quoted text 6 lines
If this was 100% clearly a bug. Or 100% clearly a break of compatibility to documented Delphi features, then maybe But this is not a bug. And Delphi docs, IMHO are not making a 100% clear statement about this.

It is a bug considering that both Delphi and Lazarus docs are clear about it: ShowModal does not return until the form is closed.

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/53271cff/attachment-0001.html>

Reply by email

Martin
to patspiper
patspiper wrote 7 lines
On 18/04/12 17:39, Martin wrote: > > > But this is not a bug. > And Delphi docs, IMHO are not making a 100% clear statement about this. It is a bug considering that both Delphi and Lazarus docs are clear about it: ShowModal does not return until the form is closed.

That's not the point

The point is: Close Destroy
In fact, with modal active close does hide the form (and sets modal result)

In anyway it does not say "until the method close is called". It says "form is closed" never mind how it is closed

"closing a form" is not the same as "calling close()"

"calling close()" is only one of many ways to "close a form". e.g during Modal, you can set ModalResult.

Depending on close the property CloseAction = caHide, a call to Close(), does in the end actually call Hide (or set Visible=False). The call to Close can (optional) destroy the form. But the actual closing is done by making it invisible.

So who says, that calling Hide() is not a way of closing the form? It does the same thing. (the 2 calls have different additional side effects, but that is a different story)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/cb14b87b/attachment.html>

Reply by email

patspiper
to Martin
Martin wrote 14 lines
On 18/04/2012 17:53, patspiper wrote: > On 18/04/12 17:39, Martin wrote: >> >> >> But this is not a bug. >> And Delphi docs, IMHO are not making a 100% clear statement about this. > It is a bug considering that both Delphi and Lazarus docs are clear > about it: ShowModal does not return until the form is closed. That's not the point The point is: Close Destroy In fact, with modal active close does hide the form (and sets modal result)

Closing a modal form hides it indeed, sets ModalResult, and makes ShowModal exit. Hiding is just one step of modal form closing.

In anyway it does not say "until the method close is called". It says "form is closed" never mind how it is closed

Correct

Show quoted text 5 lines
"closing a form" is not the same as "calling close()" "calling close()" is only one of many ways to "close a form". e.g during Modal, you can set ModalResult.

OK

Show quoted text 7 lines
Depending on close the property CloseAction = caHide, a call to Close(), does in the end actually call Hide (or set Visible=False). The call to Close can (optional) destroy the form. But the actual closing is done by making it invisible. So who says, that calling Hide() is not a way of closing the form?

Try applying the same logic with CloseAction = caNone ;)

Furthermore, Hide() does not trigger the OnCloseQuery and OnClose events.

It does the same thing. (the 2 calls have different additional side effects, but that is a different story)

<joking mode on> Pulling off the computer's power plug is yet another way of closing a form with different side effects<joking mode off>

Finally, the force (Delphi) is not on your side :D

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/9a07d011/attachment.html>

Reply by email

zeljko
to Martin: Well IMHO the problem is not to find a way to change it (though that might be on some…
Martin wrote 16 lines
On 18/04/2012 15:27, zeljko wrote: > > In LCL there is > > > > Screen.DisableForms() > > +1 , that's why I implemented hiding of modal form as it is - it > simply works on all platforms, and Delphi behaviour looks pretty > unlogical to me (but even that can work - see my today patches > attached at issue). Well IMHO the problem is not to find a way to change it (though that might be on some platforms...) The problem is: There may be LCL apps out there relying on the current behaviour of Hide()

Are you sure ? Current behaviour is implemented in 35525,35533 (trunk only) , I'm not sure that it's merged into 0.9.30.4.
1st bug was that Hide() was totally wrong for modal form, and 2nd problem inside that bug was that modal form released it's handle after leaving modal loop.

Show quoted text 9 lines
That raises the question: Is this issue important enough to risk breaking them. If this was 100% clearly a bug. Or 100% clearly a break of compatibility to documented Delphi features, then maybe But this is not a bug. And Delphi docs, IMHO are not making a 100% clear statement about this.

As I said (my opinion): if Delphi behaviour is to leave app stucked into modal loop when form is hidden - it's wrong. Current implementation is fine and works fine on all platforms I can test.

zeljko

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/b146a14a/attachment-0001.html>

Reply by email

zeljko
to William Oliveira Ferreira: 2012/4/17 zeljko should do this or raise a exception 'Can't hide a modal form', no? (i…
William Oliveira Ferreira wrote 26 lines
2012/4/17 zeljko > ** > > On Tuesday 17 of April 2012 17:41:54 patspiper wrote: > > This is related to bug #15390: > > > > > > > > My understanding is that Showmodal blocks until the form is closed. > > > > Hiding the form should have no effect. > > > > > > > > try > > > > Self.Hide; > > > > Form2.ShowModal; //<- this should block until Form2 is closed > > So, with your explanation: when you hide modal form it should stay in > modal loop and application is completelly unresponsive ? should do this or raise a exception 'Can't hide a modal form', no? (i really don't know, it's a suggestion...)

No need for that. Current solution works perfect, and those guys are arguing about incompability with Delphi implementation.

zeljko

Show quoted text 5 lines
> -- > ________________________________ > William de Oliveira Ferreira > Bacharel em Sistemas de Informa??o

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/8949152e/attachment.html>

Reply by email

zeljko
to patspiper: Closing a modal form hides it indeed, sets ModalResult, and makes ShowModal exit. Hiding…
patspiper wrote 48 lines
On 18/04/12 20:09, Martin wrote: > On 18/04/2012 17:53, patspiper wrote: >> On 18/04/12 17:39, Martin wrote: >>> But this is not a bug. >>> And Delphi docs, IMHO are not making a 100% clear statement about this. >> >> It is a bug considering that both Delphi and Lazarus docs are clear >> about it: ShowModal does not return until the form is closed. > > That's not the point > > The point is: Close Destroy > In fact, with modal active close does hide the form (and sets modal > result) Closing a modal form hides it indeed, sets ModalResult, and makes ShowModal exit. Hiding is just one step of modal form closing. > In anyway it does not say "until the method close is called". > It says "form is closed" never mind how it is closed Correct > "closing a form" is not the same as "calling close()" > > "calling close()" is only one of many ways to "close a form". > e.g during Modal, you can set ModalResult. OK > Depending on close the property CloseAction = caHide, a call to > Close(), does in the end actually call Hide (or set Visible=False). > The call to Close can (optional) destroy the form. But the actual > closing is done by making it invisible. > > So who says, that calling Hide() is not a way of closing the form? Try applying the same logic with CloseAction = caNone ;) Furthermore, Hide() does not trigger the OnCloseQuery and OnClose events. > It does the same thing. (the 2 calls have different additional side > effects, but that is a different story) <joking mode on> Pulling off the computer's power plug is yet another way of closing a form with different side effects<joking mode off> Finally, the force (Delphi) is not on your side :D

Maybe I will implement it to be delphi compat but first must test it on all platforms. Also I would like to have property inside TCustomForm which can change behaviour of ShowModal() when Hide() is called. 1.I like current implementation because you can have "alive" form to show again and again.
2.Delphi implementation just hides form but stays in modal loop, and other forms are accessible - I don't like this solution but I respect other ppl needs.

So what property name could be goodfor such behaviour ? HideModalBehaviour = hmbLazarus (default), hmbDelphi( Delphi compatibile) ?

zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/729fffb9/attachment-0001.html>

Reply by email

Martin
to patspiper: Closing a modal form hides it indeed, sets ModalResult, and makes ShowModal exit. Hiding…
patspiper wrote
Furthermore, Hide() does not trigger the OnCloseQuery and OnClose events.

Yes. But that are side effects.

The actual action on the widget / handle (the window as known by the win-api or gtk) are the same: The form (window widget) is taken of the screen

> It does the same thing. (the 2 calls have different additional side > effects, but that is a different story) <joking mode on> Pulling off the computer's power plug is yet another way of closing a form with different side effects<joking mode off>

True.
But that one works for you: It does not return from the ShowModal call ;)

Finally, the force (Delphi) is not on your side :D

I am on my Side....

Besides: I have no problem if some one (from the developers) wants to make the call, and take responsibility for potentially breaking other apps.

I did want to:
- point out the risk
- point out that the documentation leaves room for interpretation.

I've done that. (actually the 2nd appears to be ongoing) -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/df051c46/attachment.html>

Reply by email

Martin
to zeljko: Maybe I will implement it to be delphi compat but first must test it on all platforms.…
zeljko wrote 123 lines
On Wednesday 18 of April 2012 20:05:35 patspiper wrote: > On 18/04/12 20:09, Martin wrote: > > On 18/04/2012 17:53, patspiper wrote: > >> On 18/04/12 17:39, Martin wrote: > >>> But this is not a bug. > >>> And Delphi docs, IMHO are not making a 100% clear statement about this. > >> > >> It is a bug considering that both Delphi and Lazarus docs are clear > >> about it: ShowModal does not return until the form is closed. > > > > That's not the point > > > > The point is: Close Destroy > > In fact, with modal active close does hide the form (and sets modal > > result) > > Closing a modal form hides it indeed, sets ModalResult, and makes > ShowModal exit. Hiding is just one step of modal form closing. > > > In anyway it does not say "until the method close is called". > > It says "form is closed" never mind how it is closed > > Correct > > > "closing a form" is not the same as "calling close()" > > > > "calling close()" is only one of many ways to "close a form". > > e.g during Modal, you can set ModalResult. > > OK > > > Depending on close the property CloseAction = caHide, a call to > > Close(), does in the end actually call Hide (or set Visible=False). > > The call to Close can (optional) destroy the form. But the actual > > closing is done by making it invisible. > > > > So who says, that calling Hide() is not a way of closing the form? > > Try applying the same logic with CloseAction = caNone ;) > > Furthermore, Hide() does not trigger the OnCloseQuery and OnClose events. > > > It does the same thing. (the 2 calls have different additional side > > effects, but that is a different story) > > <joking mode on> Pulling off the computer's power plug is yet another > way of closing a form with different side effects<joking mode off> > > Finally, the force (Delphi) is not on your side :D Maybe I will implement it to be delphi compat but first must test it on all platforms. Also I would like to have property inside TCustomForm which can change behaviour of ShowModal() when Hide() is called. 1.I like current implementation because you can have "alive" form to show again and again. 2.Delphi implementation just hides form but stays in modal loop, and other forms are accessible - I don't like this solution but I respect other ppl needs. So what property name could be goodfor such behaviour ? HideModalBehaviour = hmbLazarus (default), hmbDelphi( Delphi compatibile) ?

I don't thing it's worth a property.

1) Close can always be used for current behaviour.
2) Hide and the setting ModalResult can be used too -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/6bdbfc75/attachment-0001.html>

Reply by email

patspiper
to zeljko: Maybe I will implement it to be delphi compat but first must test it on all platforms.…
zeljko wrote 10 lines
Maybe I will implement it to be delphi compat but first must test it on all platforms. Also I would like to have property inside TCustomForm which can change behaviour of ShowModal() when Hide() is called. 1.I like current implementation because you can have "alive" form to show again and again.

Isn't that the Delphi behaviour as well? If you close a modal form by setting its ModalResult or calling its close method, I guess you can reuse it with ShowModal again provided you do not explicitly destroy it.

Show quoted text 5 lines
2.Delphi implementation just hides form but stays in modal loop, and other forms are accessible - I don't like this solution but I respect other ppl needs.

If what I said above is correct, then you can use close instead of hide to get the functionality you need. There would be no need for any additional property.

Show quoted text 7 lines
So what property name could be goodfor such behaviour ? HideModalBehaviour = hmbLazarus (default), hmbDelphi( Delphi compatibile) ?

The default you chose matches well your desire to fight for (your) current compatibility ;)

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/0b3c800c/attachment.html>

Reply by email

patspiper
to Martin: Yes. But that are side effects. The actual action on the widget / handle (the window as…
Martin wrote 16 lines
On 18/04/2012 19:05, patspiper wrote: > > Furthermore, Hide() does not trigger the OnCloseQuery and OnClose events. Yes. But that are side effects. The actual action on the widget / handle (the window as known by the win-api or gtk) are the same: The form (window widget) is taken of the screen >> It does the same thing. (the 2 calls have different additional side >> effects, but that is a different story) > <joking mode on> Pulling off the computer's power plug is yet another > way of closing a form with different side effects<joking mode off> True. But that one works for you: It does not return from the ShowModal call ;)

It is just different side effects ;)

Show quoted text 15 lines
> > Finally, the force (Delphi) is not on your side :D I am on my Side.... Besides: I have no problem if some one (from the developers) wants to make the call, and take responsibility for potentially breaking other apps. I did want to: - point out the risk - point out that the documentation leaves room for interpretation. I've done that. (actually the 2nd appears to be ongoing)

Our interpretations of "form closing" are different. Fine :) I would have liked though to get feedback from others.

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/4752f3c5/attachment.html>

Reply by email

patspiper
to Martin: I don't thing it's worth a property. 1) Close can always be used for current behaviour.…
Martin wrote 159 lines
On 18/04/2012 19:26, zeljko wrote: > > On Wednesday 18 of April 2012 20:05:35 > patspiper wrote: > > > On 18/04/12 20:09, Martin wrote: > > > > On 18/04/2012 17:53, patspiper > wrote: > > > >> On 18/04/12 17:39, Martin > wrote: > > > >>> But this is not a bug. > > > >>> And Delphi docs, IMHO are > not making a 100% clear statement about this. > > > >> > > > >> It is a bug considering that > both Delphi and Lazarus docs are clear > > > >> about it: ShowModal does not > return until the form is closed. > > > > > > > > That's not the point > > > > > > > > The point is: Close > Destroy > > > > In fact, with modal active close > does hide the form (and sets modal > > > > result) > > > > > > Closing a modal form hides it indeed, > sets ModalResult, and makes > > > ShowModal exit. Hiding is just one step > of modal form closing. > > > > > > > In anyway it does not say "until > the method close is called". > > > > It says "form is closed" never mind > how it is closed > > > > > > Correct > > > > > > > "closing a form" is not the same as > "calling close()" > > > > > > > > "calling close()" is only one of > many ways to "close a form". > > > > e.g during Modal, you can set > ModalResult. > > > > > > OK > > > > > > > Depending on close the property > CloseAction = caHide, a call to > > > > Close(), does in the end actually > call Hide (or set Visible=False). > > > > The call to Close can (optional) > destroy the form. But the actual > > > > closing is done by making it > invisible. > > > > > > > > So who says, that calling Hide() is > not a way of closing the form? > > > > > > Try applying the same logic with > CloseAction = caNone ;) > > > > > > Furthermore, Hide() does not trigger the > OnCloseQuery and OnClose events. > > > > > > > It does the same thing. (the 2 > calls have different additional side > > > > effects, but that is a different > story) > > > > > > <joking mode on> Pulling off the > computer's power plug is yet another > > > way of closing a form with different > side effects<joking mode off> > > > > > > Finally, the force (Delphi) is not on > your side :D > > > > > > Maybe I will implement it to be delphi compat > but first must test it on all platforms. Also I would like to > have property inside TCustomForm which can > > change behaviour of ShowModal() when Hide() > is called. > > 1.I like current implementation because you > can have "alive" form to show again and again. > > 2.Delphi implementation just hides form but > stays in modal loop, and other forms are accessible - I don't > like this solution but I respect other ppl needs. > > > > So what property name could be goodfor such > behaviour ? > > HideModalBehaviour = hmbLazarus (default), > hmbDelphi( Delphi compatibile) ? > > I don't thing it's worth a property. 1) Close can always be used for current behaviour. 2) Hide and the setting ModalResult can be used too

+1

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120418/581b924e/attachment.html>

Reply by email

zeljko
to Martin: I don't thing it's worth a property. 1) Close can always be used for current behaviour.…
Martin wrote 100 lines
On 18/04/2012 19:26, zeljko wrote: > On Wednesday 18 of April 2012 20:05:35 patspiper wrote: > > On 18/04/12 20:09, Martin wrote: > > > On 18/04/2012 17:53, patspiper wrote: > > >> On 18/04/12 17:39, Martin wrote: > > >>> But this is not a bug. > > >>> > > >>> And Delphi docs, IMHO are not making a 100% clear statement > > about this. > > > >> It is a bug considering that both Delphi and Lazarus docs are clear > > >> > > >> about it: ShowModal does not return until the form is closed. > > > > > > That's not the point > > > > > > > > > > > > The point is: Close Destroy > > > > > > In fact, with modal active close does hide the form (and sets modal > > > > > > result) > > > > Closing a modal form hides it indeed, sets ModalResult, and makes > > > > ShowModal exit. Hiding is just one step of modal form closing. > > > > > In anyway it does not say "until the method close is called". > > > > > > It says "form is closed" never mind how it is closed > > > > Correct > > > > > "closing a form" is not the same as "calling close()" > > > > > > > > > > > > "calling close()" is only one of many ways to "close a form". > > > > > > e.g during Modal, you can set ModalResult. > > > > OK > > > > > Depending on close the property CloseAction = caHide, a call to > > > > > > Close(), does in the end actually call Hide (or set Visible=False). > > > > > > The call to Close can (optional) destroy the form. But the actual > > > > > > closing is done by making it invisible. > > > > > > > > > > > > So who says, that calling Hide() is not a way of closing the form? > > > > Try applying the same logic with CloseAction = caNone ;) > > > > > > > > Furthermore, Hide() does not trigger the OnCloseQuery and OnClose > > events. > > > > It does the same thing. (the 2 calls have different additional side > > > > > > effects, but that is a different story) > > > > <joking mode on> Pulling off the computer's power plug is yet another > > > > way of closing a form with different side effects<joking mode off> > > > > > > > > Finally, the force (Delphi) is not on your side :D > > Maybe I will implement it to be delphi compat but first must test it > on all platforms. Also I would like to have property inside > TCustomForm which can > > change behaviour of ShowModal() when Hide() is called. > > 1.I like current implementation because you can have "alive" form to > show again and again. > > 2.Delphi implementation just hides form but stays in modal loop, and > other forms are accessible - I don't like this solution but I respect > other ppl needs. > > > So what property name could be goodfor such behaviour ? > > HideModalBehaviour = hmbLazarus (default), hmbDelphi( Delphi > compatibile) ? I don't thing it's worth a property. 1) Close can always be used for current behaviour. 2) Hide and the setting ModalResult can be used too

Yes, you're right. New property isn't needed ,so best would be to add new patch so Hide() is Delphi compat, and for scenario I like, Close with CloseAction := caHide can be called and everything works fine.

zeljko

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120419/5710d185/attachment-0001.html>

Reply by email

Felipe Monteiro de Carvalho
to zeljko: Maybe I will implement it to be delphi compat but first must test it on all platforms.…

2012/4/18 zeljko :

As I said (my opinion): if Delphi behaviour is to leave app stucked into modal loop when form is hidden - it's wrong. Current implementation is fine and works fine on all platforms I can test.

.........

Show quoted text 8 lines
Maybe I will implement it to be delphi compat but first must test it on all platforms. Also I would like to have property inside TCustomForm which can change behaviour of ShowModal() when Hide() is called. 1.I like current implementation because you can have "alive" form to show again and again. 2.Delphi implementation just hides form but stays in modal loop, and other forms are accessible - I don't like this solution but I respect other ppl needs.

I wonder how this will be implementated exactly, because depending on how it is done I can see that it would break in Android.

Android does not allow any kind of long (>1 second) loops in the main thread. ProcessMessages is unsupported too.

Felipe Monteiro de Carvalho

Reply by email