Modal forms

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 4 years and 5 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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Modal forms

Post by jvierra »

Without you code it is not possible to understand the issue. The child form is clearly NOT a modal form. It is either launched in a separate runspace or launched using a couple of other little known tricks that allow "modeless" forms. These tricks do not work correctly with forms in PowerShell but can be used in limited ways.,
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Modal forms

Post by localpct »

Sorry, it is a runspace

And the code is yours J
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Modal forms

Post by jvierra »

What code is mine?
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Modal forms

Post by localpct »

viewtopic.php?f=21&t=14109&p=74346&hili ... rms#p74346

I just used this in the demo
So yes its a runspace
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Modal forms

Post by jvierra »

Yes - that form is NOT a modal form. It is a form running in a separate runspace. The only way to access the form is to modify variables in the synchash and have to child form detect when the variable is modified.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Modal forms

Post by jvierra »

I modified the example to demonstrate how to communicate with a form via the synchash. It shows two methods for altering the a second main form from the creating form. I use the name "Parent" in the synchash but the form is not a true "Parent" as defined by the form's "Parent" property but it does parent the disconnected form in a way. I suppose "CreatingForm" or "OwningForm" would be a better name to prevent confusion.

Run this demo to see how to manage a disconnected form (A "Child" form is a "connected" form in that it is always attached to the form the creates it even if it does this by calling a function or script. This is because PowerShell is a single thread. A runspace is a new thread so we can get away with much mischief without disturbing the main PowerShell thread. Of course this all requires some advanced programming and systems skills that aer not found in most WIndows techs and even not understaood by many programmers.

See the attached project.
Attachments
Demo-MultFormClientRS.zip
(158.01 KiB) Downloaded 104 times
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Modal forms

Post by localpct »

Thanks.. I'll dig into this tomorrow and post back
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Modal forms

Post by localpct »

jvierra wrote: Thu Oct 17, 2019 12:04 pm I modified the example to demonstrate how to communicate with a form via the synchash. It shows two methods for altering the a second main form from the creating form. I use the name "Parent" in the synchash but the form is not a true "Parent" as defined by the form's "Parent" property but it does parent the disconnected form in a way. I suppose "CreatingForm" or "OwningForm" would be a better name to prevent confusion.

Run this demo to see how to manage a disconnected form (A "Child" form is a "connected" form in that it is always attached to the form the creates it even if it does this by calling a function or script. This is because PowerShell is a single thread. A runspace is a new thread so we can get away with much mischief without disturbing the main PowerShell thread. Of course this all requires some advanced programming and systems skills that aer not found in most WIndows techs and even not understaood by many programmers.

See the attached project.
So I want to be clear, and just need a yes no answer

If on my main form, I change a textbox to reflect the new PC name, can this code you put together, update a textbox on the disconnected childform? I see I can use this code to update the Title of the form, but can't seem to figure out how to change a textbox
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Modal forms

Post by jvierra »

Yes
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Modal forms

Post by jvierra »

Here is the missing piece that you need to understand how to easily access the objects in a remote form.
Attachments
Demo-MultFormClientRS2.zip
(200.57 KiB) Downloaded 109 times
This topic is 4 years and 5 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