Question Afficher puis modifier un windowsForm
- martinez
- Auteur du sujet
- Hors Ligne
- Membre junior
Réduire
Plus d'informations
- Messages : 23
- Remerciements reçus 0
il y a 6 ans 10 mois #23623
par martinez
Afficher puis modifier un windowsForm a été créé par martinez
Bonjour,
Je dois travailler sur de l'affichage, j'affiche donc une Form, je la complète au fur et à mesure que je complète les informations.
Le problème est que je dois le faire pas script et sans intervention humaine.
Le but et d'afficher la progression avant d'arriver au résultat pour que l'utilisateur comprenne que le script travail. Le script pouvant tourner pendant 5 minutes, il est important de pouvoir avoir plus qu'une progress bar, mais une véritable liaison en temps réel.
Le but est de faire :
Traitement 1 en cours.
Puis
Traitement 1 fini OK ou non OK
Traitement 2 en cours
Etc..
Merci d’avance pour votre aide
Test simple ajouter un label après avoir créer une interface
Function windowsForm{
# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\")
# Creation de la form principale
$form = New-Object Windows.Forms.Form
# Pour bloquer le resize du form et supprimer les icones Minimize and Maximize
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.MaximizeBox = $False
$form.MinimizeBox = $False
# Choix du titre
$form.Text = \"Hello world... oui pas très innovant, je sais !\"
# Choix de la taille
$form.Size = New-Object System.Drawing.Size(400,370)
# Affichage de la Windows
return $form
}
function Ajout_Label{
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = \"Please enter the information in the space below:\"
return $label
}
$form1 = WindowsForm
$form1.ShowDialog()
$label1 = Ajout_Label $form1
$form1.Controls.Add($label1)
$form1.Refresh()<br><br>Message édité par: martinez_pat, à: 15/05/17 10:17
Je dois travailler sur de l'affichage, j'affiche donc une Form, je la complète au fur et à mesure que je complète les informations.
Le problème est que je dois le faire pas script et sans intervention humaine.
Le but et d'afficher la progression avant d'arriver au résultat pour que l'utilisateur comprenne que le script travail. Le script pouvant tourner pendant 5 minutes, il est important de pouvoir avoir plus qu'une progress bar, mais une véritable liaison en temps réel.
Le but est de faire :
Traitement 1 en cours.
Puis
Traitement 1 fini OK ou non OK
Traitement 2 en cours
Etc..
Merci d’avance pour votre aide
Test simple ajouter un label après avoir créer une interface
Function windowsForm{
# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\")
# Creation de la form principale
$form = New-Object Windows.Forms.Form
# Pour bloquer le resize du form et supprimer les icones Minimize and Maximize
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.MaximizeBox = $False
$form.MinimizeBox = $False
# Choix du titre
$form.Text = \"Hello world... oui pas très innovant, je sais !\"
# Choix de la taille
$form.Size = New-Object System.Drawing.Size(400,370)
# Affichage de la Windows
return $form
}
function Ajout_Label{
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = \"Please enter the information in the space below:\"
return $label
}
$form1 = WindowsForm
$form1.ShowDialog()
$label1 = Ajout_Label $form1
$form1.Controls.Add($label1)
$form1.Refresh()<br><br>Message édité par: martinez_pat, à: 15/05/17 10:17
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
Réduire
Plus d'informations
- Messages : 6300
- Remerciements reçus 68
il y a 6 ans 10 mois #23628
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:Afficher puis modifier un windowsForm
Salut,
le showDialog() place ta fenêtre en modale .
L'ajout du contrôle ne se fait qu'une fois quitter la fenêtre.
le showDialog() place ta fenêtre en modale .
L'ajout du contrôle ne se fait qu'une fois quitter la fenêtre.
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- martinez
- Auteur du sujet
- Hors Ligne
- Membre junior
Réduire
Plus d'informations
- Messages : 23
- Remerciements reçus 0
il y a 6 ans 10 mois #23629
par martinez
Réponse de martinez sur le sujet Re:Afficher puis modifier un windowsForm
Peut-on exécuter sans appuie d'un bouton pour lancer les taches?
function Test-affichage{
Param()
$Label1 = Set_Label -y 220 -x 40 -Text \"Program 1 en cours \"
$form.Controls.Add($label1 )
Start-Sleep -Seconds 5
#Function X
$Label1.Text = \"Program 1 Fini \"
$Label2 = Set_Label -y 260 -x 40 -Text \"Program 2 en cours \"
$form.Controls.Add($label2 )
Start-Sleep -Seconds 5
#Function X
$Label2.Text = \"Program 2 Fini\"
}
function Set_Label{
Param($Text,
$y,
$x)
$label_const = New-Object System.Windows.Forms.Label
$label_const.Location = New-Object System.Drawing.Point($x,$y)
$label_const.Size = New-Object System.Drawing.Size(150,40)
$label_const.Text = $Text
return $label_const
}
# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\")
$start_button = New-Object System.Windows.Forms.Button
# Creation de la form principale
$form = New-Object Windows.Forms.Form
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.MaximizeBox = $False
$form.MinimizeBox = $False
$form.Text = \"Nouveau windows form\"
$form.Size = New-Object System.Drawing.Size(400,400)
$start_button_OnClick = {
$cpt =Test-affichage -test $cpt
}
$timer=New-Object System.Windows.Forms.Timer
$start_button.TabIndex = 2
$start_button.Name = 'button1'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 310
$System_Drawing_Size.Height = 70
$start_button.Size = $System_Drawing_Size
$start_button.UseVisualStyleBackColor = $True
$start_button.Text = 'Start'
$start_button.Font = New-Object System.Drawing.Font(\"Verdana\",12,0,3,0)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 45
$System_Drawing_Point.Y = 12
$start_button.Location = $System_Drawing_Point
$start_button.DataBindings.DefaultDataSourceUpdateMode = 0
$start_button.add_Click($start_button_OnClick)
$form.Controls.Add($start_button)
$form.ShowDialog()
$form.refresh()
function Test-affichage{
Param()
$Label1 = Set_Label -y 220 -x 40 -Text \"Program 1 en cours \"
$form.Controls.Add($label1 )
Start-Sleep -Seconds 5
#Function X
$Label1.Text = \"Program 1 Fini \"
$Label2 = Set_Label -y 260 -x 40 -Text \"Program 2 en cours \"
$form.Controls.Add($label2 )
Start-Sleep -Seconds 5
#Function X
$Label2.Text = \"Program 2 Fini\"
}
function Set_Label{
Param($Text,
$y,
$x)
$label_const = New-Object System.Windows.Forms.Label
$label_const.Location = New-Object System.Drawing.Point($x,$y)
$label_const.Size = New-Object System.Drawing.Size(150,40)
$label_const.Text = $Text
return $label_const
}
# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\")
$start_button = New-Object System.Windows.Forms.Button
# Creation de la form principale
$form = New-Object Windows.Forms.Form
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.MaximizeBox = $False
$form.MinimizeBox = $False
$form.Text = \"Nouveau windows form\"
$form.Size = New-Object System.Drawing.Size(400,400)
$start_button_OnClick = {
$cpt =Test-affichage -test $cpt
}
$timer=New-Object System.Windows.Forms.Timer
$start_button.TabIndex = 2
$start_button.Name = 'button1'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 310
$System_Drawing_Size.Height = 70
$start_button.Size = $System_Drawing_Size
$start_button.UseVisualStyleBackColor = $True
$start_button.Text = 'Start'
$start_button.Font = New-Object System.Drawing.Font(\"Verdana\",12,0,3,0)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 45
$System_Drawing_Point.Y = 12
$start_button.Location = $System_Drawing_Point
$start_button.DataBindings.DefaultDataSourceUpdateMode = 0
$start_button.add_Click($start_button_OnClick)
$form.Controls.Add($start_button)
$form.ShowDialog()
$form.refresh()
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
Réduire
Plus d'informations
- Messages : 6300
- Remerciements reçus 68
il y a 6 ans 10 mois #23630
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:Afficher puis modifier un windowsForm
martinez_pat écrit:
Oui, il faut placer le code dans le bon event .Peut-on exécuter sans appuie d'un bouton pour lancer les taches?
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- martinez
- Auteur du sujet
- Hors Ligne
- Membre junior
Réduire
Plus d'informations
- Messages : 23
- Remerciements reçus 0
il y a 6 ans 10 mois #23632
par martinez
Réponse de martinez sur le sujet Re:Afficher puis modifier un windowsForm
Merci
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.068 secondes
- Vous êtes ici :
- Accueil
- forum
- PowerShell
- Entraide pour les initiés
- Afficher puis modifier un windowsForm