How to create child form without locking parent form

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
therider
Posts: 6
Last visit: Tue Jul 03, 2018 9:43 am

How to create child form without locking parent form

Post by therider »

Hello,

I need to create a child form in SAPIEN PowerShell but without locking the parent form. The current behavior is I'll load the child form, and it acts like a popup such that you cannot click or interact with the parent until the child is closed. What I need is for a user to click a button to open a separate window, and move that window aside to continue working.

The code I have:

Code: Select all

# Button on parent form
  $openNewForm_Click = {
  Show-NewForm_psf
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to create child form without locking parent form

Post by jvierra »

In PowerShell we can only create modal forms. This will always lock the main form.

You can create a separate form in a runspace that will not lock the main form but it will not be able to update the main form.

Search for examples of PowerShell runspaces.
User avatar
therider
Posts: 6
Last visit: Tue Jul 03, 2018 9:43 am

Re: How to create child form without locking parent form

Post by therider »

Thanks for the fast response (within 3 minutes!) I'll play around with Runspaces later.

You mention that the main form will lock. Is it a parent will always lock or just the primary first form?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to create child form without locking parent form

Post by jvierra »

All ancestor forms will lock.
This topic is 5 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked