#Ouvre une fenêtre.
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.text = "Contrôles"
$form.Size = New-Object System.Drawing.Size(200,260)
#Création d'un label (Label).
$label1 = New-Object Windows.Forms.Label
$label1.Location = New-Object Drawing.Point 20,15
$label1.Size = New-Object System.Drawing.Size(100,16)
$label1.text = "Texte du label"
#Création d'une case à cocher (CheckBox).
$case1 = New-Object System.Windows.Forms.CheckBox
$case1.Location = New-Object Drawing.Point 20,35
$case1.Size = New-Object System.Drawing.Size(20,20)
$case1.Checked = $false
#Création d'une image (PictureBox).
$image1 = New-Object System.Windows.Forms.pictureBox
$image1.Location = New-Object Drawing.Point 20,60
$image1.Size = New-Object System.Drawing.Size(60,50)
$image1.image = [system.drawing.image]::FromFile("C:\fond.jpg")
#Création d'un bouton (Button).
$bouton1 = New-Object Windows.Forms.Button
$bouton1.Location = New-Object Drawing.Point 20,120
$bouton1.Size = New-Object System.Drawing.Size(85,23)
$bouton1.text = "Cliquez moi !"
$bouton1.add_click({
#Action lorsque l'on clique sur le bouton.
if ($case1.Checked -eq $true) {Write-Host "CheckBox = 1"}
else {Write-Host "CheckBox = 0"}
Write-Host "TextBox = " $text1.Text
Write-Host "ComboBox = " $liste1.Text
})
#Création d'un Text (TextBox).
$text1 = New-Object Windows.Forms.TextBox
$text1.Location = New-Object Drawing.Point 20,150
$text1.Size = New-Object System.Drawing.Size(115,30)
$text1.Text = "Changez moi !"
#Liste deroulante (ComboBox).
$liste1 = New-Object System.Windows.Forms.Combobox
$liste1.Location = New-Object Drawing.Point 20,180
$liste1.Size = New-Object System.Drawing.Size(150,30)
$liste1.DropDownStyle = "DropDownList"
$liste1.Items.AddRange(("1","2","3","4","5","6","7","8","9"))
$liste1.SelectedIndex = 0
#Attache les contrôles à la fenêtre.
$form.controls.add($label1)
$form.controls.add($bouton1)
$form.controls.add($image1)
$form.controls.add($text1)
$form.controls.add($case1)
$form.controls.add($liste1)
#Affiche le tout.
$form.ShowDialog()
#Fin.
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.text = "Contrôles"
$form.Size = New-Object System.Drawing.Size(200,260)
#Création d'un label (Label).
$label1 = New-Object Windows.Forms.Label
$label1.Location = New-Object Drawing.Point 20,15
$label1.Size = New-Object System.Drawing.Size(100,16)
$label1.text = "Texte du label"
#Création d'une case à cocher (CheckBox).
$case1 = New-Object System.Windows.Forms.CheckBox
$case1.Location = New-Object Drawing.Point 20,35
$case1.Size = New-Object System.Drawing.Size(20,20)
$case1.Checked = $false
#Création d'une image (PictureBox).
$image1 = New-Object System.Windows.Forms.pictureBox
$image1.Location = New-Object Drawing.Point 20,60
$image1.Size = New-Object System.Drawing.Size(60,50)
$image1.image = [system.drawing.image]::FromFile("C:\fond.jpg")
#Création d'un bouton (Button).
$bouton1 = New-Object Windows.Forms.Button
$bouton1.Location = New-Object Drawing.Point 20,120
$bouton1.Size = New-Object System.Drawing.Size(85,23)
$bouton1.text = "Cliquez moi !"
$bouton1.add_click({
#Action lorsque l'on clique sur le bouton.
if ($case1.Checked -eq $true) {Write-Host "CheckBox = 1"}
else {Write-Host "CheckBox = 0"}
Write-Host "TextBox = " $text1.Text
Write-Host "ComboBox = " $liste1.Text
})
#Création d'un Text (TextBox).
$text1 = New-Object Windows.Forms.TextBox
$text1.Location = New-Object Drawing.Point 20,150
$text1.Size = New-Object System.Drawing.Size(115,30)
$text1.Text = "Changez moi !"
#Liste deroulante (ComboBox).
$liste1 = New-Object System.Windows.Forms.Combobox
$liste1.Location = New-Object Drawing.Point 20,180
$liste1.Size = New-Object System.Drawing.Size(150,30)
$liste1.DropDownStyle = "DropDownList"
$liste1.Items.AddRange(("1","2","3","4","5","6","7","8","9"))
$liste1.SelectedIndex = 0
#Attache les contrôles à la fenêtre.
$form.controls.add($label1)
$form.controls.add($bouton1)
$form.controls.add($image1)
$form.controls.add($text1)
$form.controls.add($case1)
$form.controls.add($liste1)
#Affiche le tout.
$form.ShowDialog()
#Fin.