Form to the front

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 7 years and 7 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
Ravi Lobo
Posts: 38
Last visit: Wed Oct 10, 2018 6:29 am

Form to the front

Post by Ravi Lobo »

When my exe loads the main Form, it is hidden behind the open windows. Is there a way to bring the main form to the front?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form to the front

Post by jvierra »

Depends on how you designed your form and what the other Windows are. Some System Windows will always be on top.
User avatar
Ravi Lobo
Posts: 38
Last visit: Wed Oct 10, 2018 6:29 am

Re: Form to the front

Post by Ravi Lobo »

jvierra wrote:Depends on how you designed your form and what the other Windows are. Some System Windows will always be on top.
Thank you.
I was expecting something like Form.Top = $true or Form.BringToFront = $true. I'm new. The tool is very new for me. Thank you for the help.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form to the front

Post by jvierra »

Are we talking about a PowerShell Studio form or a hand built form?
User avatar
Ravi Lobo
Posts: 38
Last visit: Wed Oct 10, 2018 6:29 am

Re: Form to the front

Post by Ravi Lobo »

jvierra wrote:Are we talking about a PowerShell Studio form or a hand built form?
PowerShellStudio form.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form to the front

Post by jvierra »

By default it will be topmost. If you are trying tolock it at the very front over all forms you will need to make API calls. Not sure if it is passible with PowerShell and a modal dialog.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form to the front

Post by jvierra »

The best you can do is $form1.Topmost = $true
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Form to the front

Post by jvierra »

Ravi Lobo wrote:When my exe loads the main Form, it is hidden behind the open windows. Is there a way to bring the main form to the front?
If you are asking about forms in a multiform project then the answer is no. Modal dialog always display at the top of the stack.

You can use an MDI form to allow multiple forms to be displayed but then you have to hand code the forms.
User avatar
Ravi Lobo
Posts: 38
Last visit: Wed Oct 10, 2018 6:29 am

Re: Form to the front

Post by Ravi Lobo »

jvierra wrote: If you are asking about forms in a multiform project then the answer is no. Modal dialog always display at the top of the stack.

You can use an MDI form to allow multiple forms to be displayed but then you have to hand code the forms.
Okay. That makes sense. Thank you.
User avatar
jpbobrek
Posts: 25
Last visit: Sat Dec 23, 2023 1:52 pm

Re: Form to the front

Post by jpbobrek »

I'm having this problem also. My project is a single form project and my form is set to TopMost = True.
The script runs in the background and waits for an event.
The FIRST time it sees that event, the form launches behind other windows that are open.
All SUBSEQUENT events it sees, it launches On Top as expected.
Any ideas?
This topic is 7 years and 7 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