Hide a 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 7 years and 2 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
C3PO_R2D2
Posts: 22
Last visit: Thu Jul 29, 2021 3:55 am

Hide a form

Post by C3PO_R2D2 »

Product, version and build:

32 or 64 bit version of product: 64 bit
Operating system:
32 or 64 bit OS: 64 bit
PowerShell Version: 5.4.134

Hello,
I am trying to create a form that when I minimize it, it should minimize to the system tray, so nothing is visible in the task bar (I'm using the NotifyIcon tool).
I tried to use the commands:
  1. $formTest.ShowInTaskbar = $false
  2. $formTest.WindowState = 'Minimized'
But this doesn't completely hide the window:
HideForm.png
HideForm.png (5.44 KiB) Viewed 2521 times
When I use the code
  1. $formTest.Visible = $false
Then the program crashes.

Does anyone has experience with minimizing forms?
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Hide a form

Post by DevinL »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Hide a form

Post by DevinL »

Unfortunately, since PowerShell dialogs are modal, you can't achieve exactly what you're asking for but you can do something similar.

You can get a script to stay hidden and run with a NotifyIcon, but you can't have a GUI. Here's an article with some more information: https://technet.microsoft.com/en-us/lib ... 30952.aspx
DevinL
SAPIEN Technologies, Inc.
This topic is 7 years and 2 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