Skip to content

Instantly share code, notes, and snippets.

@williamblair333
Last active May 29, 2020 17:33
Show Gist options
  • Save williamblair333/e744f3d9b14ec5b57273c4791d9b55ee to your computer and use it in GitHub Desktop.
Save williamblair333/e744f3d9b14ec5b57273c4791d9b55ee to your computer and use it in GitHub Desktop.
PS7 GUI Test 01
<# This form was created using POSHGUI.com a free online gui designer for PowerShell
.NAME
First_GUI
#>
<# Here are the errors you get using PS7
SetValueInvocationException: PS7-GUI-Test-01.ps1:10
Line |
10 | $Form.ClientSize = '400,400'
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception setting "ClientSize": "Cannot convert the "400,400" value of type "System.String" to type
| "System.Drawing.Size"."
SetValueInvocationException: C:\temp\Ricoh\First_GUI1.ps1:19
Line |
19 | $OK.Font = 'Microsoft Sans Serif,10'
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception setting "Font": "Cannot convert the "Microsoft Sans Serif,10" value of type "System.String"
| to type "System.Drawing.Font"."
#>
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = '400,400'
$Form.text = "Form"
$Form.TopMost = $false
$OK = New-Object system.Windows.Forms.Button
$OK.text = "button"
$OK.width = 60
$OK.height = 30
$OK.location = New-Object System.Drawing.Point(13,11)
$OK.Font = 'Microsoft Sans Serif,10'
$Form.controls.AddRange(@($OK))
$OK.Add_Click({ $ })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment