Recent

Author Topic: ShowModal disables form minimise  (Read 4083 times)

llion

  • Newbie
  • Posts: 3
ShowModal disables form minimise
« on: May 06, 2021, 05:29:37 pm »
I am using Lazarus vn 2.0.6 on XUbuntu 18.04.

I have a problem which can be demonstrated easily using a project with just 3 forms : formA, formB, formC. FormA is the main form for the project. With formA visible I execute the following code

formB.show ;
application.processmessages ; // this ensures that formB is displayed in front of formA
{do other stuff not related to forms} ;
formC.showmodal ; // for example to display a  message relating to the "other stuff" above

In the course of displaying formC the Minimise button in the title bar of formB, & the corresponding Minimise menu option, become disabled, and remain so until the application is terminated.

This would appear to be a bug with showmodal, since if "formC.showmodal" above is replaced with "formC.show" the problem does not appear. Can anyone suggest a fix or work-around please?

mercurhyo

  • Full Member
  • ***
  • Posts: 201
Re: ShowModal disables form minimise
« Reply #1 on: May 06, 2021, 06:08:42 pm »
BorderStyle property should be set to bsDialog on each form using ShowModal, isn't it?
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geoforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7153
  • Debugger - SynEdit - and more
    • wiki
Re: ShowModal disables form minimise
« Reply #2 on: May 06, 2021, 06:15:43 pm »
Afaik, While the modal form is open, the minimize on all the other form (formA, formB) should be disabled.

But, when the modal form is closed, the minimize (of formA, formB) should be restored to whatever it's state was before the modal form was opened.

If it is not restored, then that would be a bug.

mercurhyo

  • Full Member
  • ***
  • Posts: 201
Re: ShowModal disables form minimise
« Reply #3 on: May 06, 2021, 06:21:15 pm »
Afaik, While the modal form is open, the minimize on all the other form (formA, formB) should be disabled.

But, when the modal form is closed, the minimize (of formA, formB) should be restored to whatever it's state was before the modal form was opened.

If it is not restored, then that would be a bug.

 I didn't know OS buttons enable/disable concept and maybe it has issues depending the Widgetset/Platform, but I do remember I was used to set bsDialog style on all my projects while using ShowModal. Then it worked fine
« Last Edit: May 06, 2021, 06:25:02 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geoforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7153
  • Debugger - SynEdit - and more
    • wiki
Re: ShowModal disables form minimise
« Reply #4 on: May 06, 2021, 06:35:44 pm »
I didn't know OS buttons enable/disable concept and maybe it has issues depending the Widgetset/Platform, but I do remember I was used to set bsDialog style on all my projects while using ShowModal. Then it worked fine

You mean you set your main form to bsDialog, if you show some modal form?

Modalforms themself should probably be bsDialog. I do not know if it is strictly required. I also do not know what happens otherwise, maybe its enforced.  But that should not affect the main form.

From memory, the code in ShowModal runs through all the other (none modal) forms, and prepares them for being "behind" the modal form. And all those changes should be reverted when the modal form exits.

dseligo

  • Sr. Member
  • ****
  • Posts: 276
Re: ShowModal disables form minimise
« Reply #5 on: May 06, 2021, 07:11:35 pm »
Modalforms themself should probably be bsDialog. I do not know if it is strictly required. I also do not know what happens otherwise, maybe its enforced.  But that should not affect the main form.

Why BorderStyle should be bsDialog? I think BorderStyle has nothing to do with ShowModal.

dseligo

  • Sr. Member
  • ****
  • Posts: 276
Re: ShowModal disables form minimise
« Reply #6 on: May 06, 2021, 07:13:25 pm »
I am using Lazarus vn 2.0.6 on XUbuntu 18.04.

I have a problem which can be demonstrated easily using a project with just 3 forms : formA, formB, formC. FormA is the main form for the project. With formA visible I execute the following code

formB.show ;
application.processmessages ; // this ensures that formB is displayed in front of formA
{do other stuff not related to forms} ;
formC.showmodal ; // for example to display a  message relating to the "other stuff" above

In the course of displaying formC the Minimise button in the title bar of formB, & the corresponding Minimise menu option, become disabled, and remain so until the application is terminated.

This would appear to be a bug with showmodal, since if "formC.showmodal" above is replaced with "formC.show" the problem does not appear. Can anyone suggest a fix or work-around please?

Are you saying that when you close formC, you can't minimize formB? Then that is a bug. Please prepare test project showing this.
If you don't close formC then it is expected behaviour (not to be able to minimize other forms).

lucamar

  • Hero Member
  • *****
  • Posts: 4010
Re: ShowModal disables form minimise
« Reply #7 on: May 06, 2021, 07:17:05 pm »
Modalforms themself should probably be bsDialog. I do not know if it is strictly required. I also do not know what happens otherwise, maybe its enforced.  But that should not affect the main form.
Why BorderStyle should be bsDialog? I think BorderStyle has nothing to do with ShowModal.

Indeed, it has nothing to do; you can show any form modally, whatever its border style or what not. That the "minimize" (and other) button(s) is disabled for the non-modal forms is just a gimmick of the GTK2 widgetset.

Note also that only the main form has a minimize button/menu item: no matter how the others are shown they only have the roll-up, maximize and close options.  Oops! No, no, I was wrong in this, sorry; I was thinking of another completely different thing :-[
« Last Edit: May 06, 2021, 07:41:33 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7153
  • Debugger - SynEdit - and more
    • wiki
Re: ShowModal disables form minimise
« Reply #8 on: May 06, 2021, 07:38:19 pm »
Modalforms themself should probably be bsDialog. I do not know if it is strictly required. I also do not know what happens otherwise, maybe its enforced.  But that should not affect the main form.

Why BorderStyle should be bsDialog? I think BorderStyle has nothing to do with ShowModal.
As, I said: "I don't know, if".

I just wonder what a modal dialog, with a minimize button on the actual modal form would do?
- Minimize the entire app, IMHO unexpected, since that minimize button belongs to the modal form only?
- Minimize the modal dialog, and leave the "frozen" app on the screen?

I haven't tried. I have no idea what will be displayed and/or happen in such a case.
Are there any apps (Lazarus or other) out there that have a mimize-able modal form?


---EDIT:
I mixed that up. I meant the BorderIcons, not the BorderStyle.
« Last Edit: May 06, 2021, 07:44:10 pm by Martin_fr »

dseligo

  • Sr. Member
  • ****
  • Posts: 276
Re: ShowModal disables form minimise
« Reply #9 on: May 06, 2021, 09:09:08 pm »
I just wonder what a modal dialog, with a minimize button on the actual modal form would do?
- Minimize the entire app, IMHO unexpected, since that minimize button belongs to the modal form only?
- Minimize the modal dialog, and leave the "frozen" app on the screen?

I haven't tried. I have no idea what will be displayed and/or happen in such a case.
Are there any apps (Lazarus or other) out there that have a mimize-able modal form?


---EDIT:
I mixed that up. I meant the BorderIcons, not the BorderStyle.

When you click minimize button in Windows 10 the whole app is minimized to the lower left of desktop. If you click on program icon in the taskbar then whole app is minimized normally - nothing is in the lower left of desktop (same is if you minimize of windows, i.e. with Windows key + D).
I don't bother removing minimize icons from my modal forms.
Oh, and I think it's less confusing for user when the whole app is minimized. If I remember correctly, on some version of Windows (or Lazarus), if you minimized modal form the rest of app stayed, but it was (of course) unresponsive. Users sometimes wasn't aware that they minimized modal form and just keep clicking on rest of the forms.

lucamar

  • Hero Member
  • *****
  • Posts: 4010
Re: ShowModal disables form minimise
« Reply #10 on: May 06, 2021, 09:22:31 pm »
I just wonder what a modal dialog, with a minimize button on the actual modal form would do?

Test it yourself! ;)
In Linux (Xubuntu 18.04), the second option is taken: it minimizes the modal form, and leaves the "frozen" app on the screen.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

mercurhyo

  • Full Member
  • ***
  • Posts: 201
Re: ShowModal disables form minimise
« Reply #11 on: May 06, 2021, 10:10:19 pm »
I didn't know OS buttons enable/disable concept and maybe it has issues depending the Widgetset/Platform, but I do remember I was used to set bsDialog style on all my projects while using ShowModal. Then it worked fine

You mean you set your main form to bsDialog, if you show some modal form?

Modalforms themself should probably be bsDialog. I do not know if it is strictly required. I also do not know what happens otherwise, maybe its enforced.  But that should not affect the main form.

From memory, the code in ShowModal runs through all the other (none modal) forms, and prepares them for being "behind" the modal form. And all those changes should be reverted when the modal form exits.

where the hell did you read that i use showmodal on mainform? LOOOL i said on each form where i use showmodal thats a BIG difference.

NOW I can explain you HOW it works :
when an application enters a modal mode it recursively calls the "processmessages" of itself incrementing reference counter of the deepness of modal and giving the Handle of the desired form ... meaning a modal form can open a modal form that can open a mo... and so on.
When all modal forms are closed the processmessages func of the application object is switched back to mainform
ENJOY

and remember "debugger is your friend" LOOOL!!!
« Last Edit: May 06, 2021, 10:12:32 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geoforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

llion

  • Newbie
  • Posts: 3
Re: ShowModal disables form minimise
« Reply #12 on: May 11, 2021, 12:34:01 pm »
Thank you for your replies.

I confirm that setting formC.borderstyle to bsDialog does not make the problem go away.

If I use the debugger then the minimise capability on formB is disabled when formC is closed; if I do not use the debugger then this is disabled earlier, when formC is displayed. I confirm that this remains disabled once formC is closed. I have also seen instances where it is formA that loses its minimise button, but I cannot yet recreate this although I suspect that it is related.

A further unexpected behaviour is that when formC is closed it is formA which receives focus, where I would expect this to be formB.

I'm afraid that my limited Lazarus skills have taken me as far as I can get with debugging this problem. I am now working in my various apps to add code to identify explicitly which form has focus whenever a ShowModal is executed (ie formB in my example), and to explicitly re-enable the minimise function on this form when the modal form is closed.

winni

  • Hero Member
  • *****
  • Posts: 2412
Re: ShowModal disables form minimise
« Reply #13 on: May 11, 2021, 02:58:03 pm »
Hi!

For FormC:

Set the property "ShowInTaskBar" to "stalways".

If you now minimize FormC you got 2 Icons in the Taskbar. One is FormC.

Winni

llion

  • Newbie
  • Posts: 3
Re: ShowModal disables form minimise
« Reply #14 on: May 15, 2021, 04:07:25 pm »
as a postscript :

In my example, if formA has 2 buttons, one button to show formB, and then a second button to showmodal formC, then it is formA that loses its minimize button/menu option. This is more serious - I can no longer minimize my app. Sigh. I wonder whether this is why Lazarus itself cannot be minimized?

And the only way of restoring this lost minimize button is to close & reopen the app. It seems not possible to change programmatically the Tform.BorderIcons property at runtime, although that is exactly what this bug in ?Lazarus appears to be doing successfully. Sigh again.

I wondered about reporting  these (sic) bugs but I found the bugtracker pages impenetrable.

 

TinyPortal © 2005-2018