Last active
September 17, 2021 13:42
-
-
Save Winand/24add82d8ca39116718dc2718f873726 to your computer and use it in GitHub Desktop.
Проверка ввода
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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