2. Creating a new form - CodeBlueG/PSForms GitHub Wiki
CmdLets
After initialising the form, the new form can be created using the "New-Form" cmdlet. The new-Form cmdlet should pass the results back to the form variable to ensure the form is updated - see the examples for clarification.
This cmdlet has the following options;
- formObject,
- escapeToClose,
- minimizeBox,
- maximizeBox,
- PSIcon,
- iconFile,
- iconEncode
formObject
This is a mandatory field
Enter the name of the form that you are creating, this is the same as the name used in the "Initialize-Form" cmdlet.
escapeToClose
Will add the option for the form to be closed by pressing the Escape key on the keyboard
minimizeBox
Will add the minimize box to the form
maximizeBox
Will add the maximize box to the form. Note that this will maximise the form "as is" - there is no resizing of the form or the fields.
PSIcon
Will make the form icon the PowerShell icon (the :> logo)
IconFile
Will use an icon file (.ico) to create the icon for the form. Note that this file will need to be available to the script and the path to the file should be provided
IconEncode
Will use a base-64 encoded image to create the icon for the form. More details on creating and using base-64 encoded images, see the "Base-64 Images" section.
Examples
$TestForm = New-Form -formObject $TestForm -escapeToClose -PSIcon
will create a new form, "$TestForm", that will have the PowerShell icon on the form and will allow pressing escape to close the form.
$TestForm = New-Form -formObject $TestForm -iconFile "C:\images\icon.ico" -minimizeBox -maximizeBox
will create a new form, "$TestForm", that will use the file icon.ico to generate the form icon and will include the minimise and maximise buttons