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.
User avatar
Ravi Lobo
Posts: 38
Joined: Tue Jul 12, 2016 6:17 am

Form to the front

Post by Ravi Lobo » Wed Jul 20, 2016 8:45 am

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: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Form to the front

Post by jvierra » Wed Jul 20, 2016 10:53 am

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
Joined: Tue Jul 12, 2016 6:17 am

Re: Form to the front

Post by Ravi Lobo » Wed Jul 20, 2016 2:13 pm

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: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Form to the front

Post by jvierra » Wed Jul 20, 2016 3:01 pm

Are we talking about a PowerShell Studio form or a hand built form?

User avatar
Ravi Lobo
Posts: 38
Joined: Tue Jul 12, 2016 6:17 am

Re: Form to the front

Post by Ravi Lobo » Thu Jul 21, 2016 6:24 am

jvierra wrote:Are we talking about a PowerShell Studio form or a hand built form?
PowerShellStudio form.

jvierra
Posts: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Form to the front

Post by jvierra » Thu Jul 21, 2016 6:31 am

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: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Form to the front

Post by jvierra » Thu Jul 21, 2016 6:32 am

The best you can do is $form1.Topmost = $true

jvierra
Posts: 14019
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Form to the front

Post by jvierra » Thu Jul 21, 2016 6:34 am

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
Joined: Tue Jul 12, 2016 6:17 am

Re: Form to the front

Post by Ravi Lobo » Thu Jul 21, 2016 6:45 am

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
kerbob
Posts: 25
Joined: Sun Mar 03, 2013 12:39 pm

Re: Form to the front

Post by kerbob » Tue Aug 16, 2016 7:23 am

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?

Locked