Recent

Author Topic: How to control subform: Show vs ShowModal et al  (Read 1867 times)

Wilko500

  • Full Member
  • ***
  • Posts: 180
How to control subform: Show vs ShowModal et al
« on: July 13, 2025, 11:21:38 pm »
MacOs Sequoia Laz 4.1 FPC 2.3.3
Scenario: Main form contains active component eg TTimer.  Button on main form runs a process but first requires user input of two dates.

I created a small subform, added two DateTimePickers, user can select date.  It would be desirable to prevent user selecting items on main form until date selection completed along with secondary process.

If I call subform with .ShowModal main form timer process is stopped.
If I call subform with .Show main form timer process continuers but main form can be selected by user

Setting FormStyle to "StayOnTop" looked like a solution but it is not.  Two things, it still allows access to main form  and the DateTimePicker calendar is hidden under the subform.  This may be by design  but I would have expected that the form stays on top but behaves in the standard way ie any clicks on it are still visible.

I would like suggestions as how to prevent user interaction with main form while subform is in operation. Secondly is it right that calendar dialog on DateTimePicker is behind form when StayOnTop is the chosen form style.






MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

jamie

  • Hero Member
  • *****
  • Posts: 7702
Re: How to control subform: Show vs ShowModal et al
« Reply #1 on: July 13, 2025, 11:30:39 pm »
I think the timer should remain running while there is a model mode. It must be something different on the target?

Anyways, you can try setting the Enable property to false, that should reject mouse and keyboard input.

The only true wisdom is knowing you know nothing

madref

  • Hero Member
  • *****
  • Posts: 1116
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: How to control subform: Show vs ShowModal et al
« Reply #2 on: July 13, 2025, 11:35:23 pm »
Take a look at this post. Because I had the same problem.


It also has an example in it.
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Tahoe 26.2
Lazarus 4.99 (rev main_4_99-3149-g7867f6275c) FPC 3.3.1 x86_64-darwin-cocoa

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: How to control subform: Show vs ShowModal et al
« Reply #3 on: July 16, 2025, 12:09:23 am »
Thank you for responding and sorry for delay answering.

@jamie I have done some more checking and you are correct. Timer does indeed continue during Modal mode.  My program did have ShowModal and then it was changed to Show.  My new understanding is that ShowModal freezes the main thread but the timers running from the main form are in their own threads so they continue running.  Also any code called by the Timer fire event also runs in Modal mode.  I think there must have been something else on the main form that froze when I used ShowModal.  I cannot duplicate that now

@madref Thank you for ref to your post.  An interesting solution.  Looks like my post was referring to a problem that didn't exist, or at least I can't recreate it now, so for now ShowModal is working for me.  I have bookmarked your post and will go through it in more detail when I have more time.  I really enjoy learning new stuff from posts like yours.  Thank you

MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

 

TinyPortal © 2005-2018