Skip to content

Instantly share code, notes, and snippets.

@Winand
Last active September 17, 2021 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Winand/24add82d8ca39116718dc2718f873726 to your computer and use it in GitHub Desktop.
Save Winand/24add82d8ca39116718dc2718f873726 to your computer and use it in GitHub Desktop.
Проверка ввода
$glob_var = 0
Function Generate-Form {
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Build Form
$Form = New-Object System.Windows.Forms.Form
$Form.Text = "My Form"
$Form.Size = New-Object System.Drawing.Size(200,200)
$Form.StartPosition = "CenterScreen"
$Form.Topmost = $True
$textBox = New-Object System.Windows.Forms.TextBox
$Form.Controls.Add($textBox)
# Add Button
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(35,35)
$Button.Size = New-Object System.Drawing.Size(120,23)
$Button.Text = "Проверка"
$Form.Controls.Add($Button)
#Add Button event
$Button.Add_Click({
$global:glob_var += 1
if($textBox.text) {
[System.Windows.Forms.MessageBox]::Show("Введён текст: " + $textBox.text , $global:glob_var)
} else {
[System.Windows.Forms.MessageBox]::Show("Сначала введите текст" , $global:glob_var)
}
})
#Show the Form
$form.ShowDialog()| Out-Null
} #End Function
#Call the Function
Generate-Form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment