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.
Locked
User avatar
josh.perkins
Posts: 4
Joined: Mon Mar 18, 2013 8:52 am

Application exits when $frmName.Hide() is called

Post by josh.perkins » Thu Aug 29, 2013 11:10 am

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()
	}
}

User avatar
jvierra
Posts: 13571
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Thu Aug 29, 2013 11:32 am

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
Joined: Mon Mar 18, 2013 8:52 am

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

Post by josh.perkins » Thu Aug 29, 2013 11:40 am

Great, thank you for the quick reply.

Locked