Application exits when $frmName.Hide() is called

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 10 years and 6 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
josh.perkins
Posts: 4
Last visit: Mon Jun 26, 2023 2:46 pm

Application exits when $frmName.Hide() is called

Post by josh.perkins »

When I minimize my form using the following Resize event, my form closes (exits, PowerShell Studio debug stops). Any help would be appreciated.
PowerShell Code
Double-click the code block to select all.
$frmMainUI_Resize={
	if ($frmMainUI.WindowState -eq 'Minimized') {
		$frmMainUI.Hide()
	}
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Application exits when $frmName.Hide() is called

Post by jvierra »

That is correct.

In PowerShell we can only launch a form as a Modal Dialog. When a dialog is hidden it is also terminated with a dialogResult of "Cancel".

Hide is the same as Close using the escape key.
User avatar
josh.perkins
Posts: 4
Last visit: Mon Jun 26, 2023 2:46 pm

Re: Application exits when $frmName.Hide() is called

Post by josh.perkins »

Great, thank you for the quick reply.
This topic is 10 years and 6 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