Product, version and build: 5.2.128
32 or 64 bit version of product: 64
Operating system: Windows 7 32 and 64 bit
32 or 64 bit OS: 32 and 64 bit
PowerShell Version: 4
I have a single form project that uses the $statusbar1.text. When we run the .EXE we can see a message at the bottom of the screen. But when I created a multiple form project I've noticed that this command no longer works. I've tried $statusbar1.text and $statusbar.text and neither works. How do you make this work on both the parent and child forms?
multiple form project
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: multiple form project
[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: multiple form project
I moved both of your threads over as they were more overall PowerShell GUI questions as opposed to specific issues with PowerShell Studio.
One thing that would be of great help is if you could provide the code that you currently have for your multiple forms so we have a better understanding of what's going on.
You can use the code selection box at the top of where you type out a reply to format your code in a more readable format as well:
One thing that would be of great help is if you could provide the code that you currently have for your multiple forms so we have a better understanding of what's going on.
You can use the code selection box at the top of where you type out a reply to format your code in a more readable format as well:
DevinL
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: multiple form project
Hi, I have two forms and over 600 lines of code. So I created a new multiple form project with one task to show what I mean. the $statusbar1.text is never seen.
# main form
$MainForm_Load={
#TODO: Initialize Form Controls here
}
$buttonCallChildForm_Click={
#TODO: Place custom script here
if((Call-ChildForm_psf) -eq 'OK')
{
}
}
#########################################################
Child Form
$formChildForm_Load={
#TODO: Initialize Form Controls here
}
$button1_Click={
#TODO: Place custom script here
$pc = Read-Host "Enter remote computer name"
$statusbar1.text = 'The query of of a remote machines WMI can take time, please wait.'
get-wmiobject -class Win32_QuickFixEngineering -ComputerName $pc | Out-GridView -wait -Title "MGH"
$statusbar1.text = 'All done!'
}
##########################################################
# main form
$MainForm_Load={
#TODO: Initialize Form Controls here
}
$buttonCallChildForm_Click={
#TODO: Place custom script here
if((Call-ChildForm_psf) -eq 'OK')
{
}
}
#########################################################
Child Form
$formChildForm_Load={
#TODO: Initialize Form Controls here
}
$button1_Click={
#TODO: Place custom script here
$pc = Read-Host "Enter remote computer name"
$statusbar1.text = 'The query of of a remote machines WMI can take time, please wait.'
get-wmiobject -class Win32_QuickFixEngineering -ComputerName $pc | Out-GridView -wait -Title "MGH"
$statusbar1.text = 'All done!'
}
##########################################################
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: multiple form project
consider your scope when you passing data from the child to the main form.
mainform:
Call-ChildForm_psf
$statusbar1.text = $sbtext
Child form.
The ok button dialogresult property on your child should be set to ok.
$button1_Click={
$script:sbtext = 'updating the statusbar'
}
mainform:
Call-ChildForm_psf
$statusbar1.text = $sbtext
Child form.
The ok button dialogresult property on your child should be set to ok.
$button1_Click={
$script:sbtext = 'updating the statusbar'
}
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: multiple form project
- ##main
- $MainForm_Load={
- #TODO: Initialize Form Controls here
- }
- $buttonCallChildForm_Click={
- #TODO: Place custom script here
- if((Call-ChildForm_psf) -eq 'OK')
- {
- $statusbar1.Text = $sbtext
- }
- }
- ##child
- $formChildForm_Load={
- #TODO: Initialize Form Controls here
- }
- $buttonOK_Click={
- $script:sbtext = 'updating the statusbar'
- }
Re: multiple form project
If I understood you right I did the following.
$buttonCallChildForm_Click={
#TODO: Place custom script here
$statusbar1.text = $sbtext
if((Call-ChildForm_psf) -eq 'OK') {}
}
then on the child item
$button1_Click={
#TODO: Place custom script here
$computer = read-host "Enter computer name"
Get-WmiObject win32_computersystem -comp $computer | Select-Object USername, Caption, Model | Out-GridView -Title "Logged on user"
$script:sbtext = 'updating the statusbar'
}
I never saw a status bar. And my main objective is to have 1 parent form and at least 2 child forms. All 3 forums will have 6-10 buttons. Each button will use the Statusbar command.
Main Form - Called Computer Tasks. This form will have 11 buttons, each one doing a different task against computers.
Child form 1 - Called User Tasks. This form will have 6 buttons on it each one doing a different task against users.
Chile form 2 - Called Server Tasks. This form will have several buttons on it each one doing a different task against File Server machines.
I have all of this working right now but its on 1 Form. That 1 form is now far far too crowded and takes up the whole screen when run, and our desktop support team does not like it, so I am trying to create a multiple form utility that is cleaner.
so all of my posts in this form today in the long run are about the same thing.
Thank you.
$buttonCallChildForm_Click={
#TODO: Place custom script here
$statusbar1.text = $sbtext
if((Call-ChildForm_psf) -eq 'OK') {}
}
then on the child item
$button1_Click={
#TODO: Place custom script here
$computer = read-host "Enter computer name"
Get-WmiObject win32_computersystem -comp $computer | Select-Object USername, Caption, Model | Out-GridView -Title "Logged on user"
$script:sbtext = 'updating the statusbar'
}
I never saw a status bar. And my main objective is to have 1 parent form and at least 2 child forms. All 3 forums will have 6-10 buttons. Each button will use the Statusbar command.
Main Form - Called Computer Tasks. This form will have 11 buttons, each one doing a different task against computers.
Child form 1 - Called User Tasks. This form will have 6 buttons on it each one doing a different task against users.
Chile form 2 - Called Server Tasks. This form will have several buttons on it each one doing a different task against File Server machines.
I have all of this working right now but its on 1 Form. That 1 form is now far far too crowded and takes up the whole screen when run, and our desktop support team does not like it, so I am trying to create a multiple form utility that is cleaner.
so all of my posts in this form today in the long run are about the same thing.
Thank you.
Re: multiple form project
You cannot update the status bar on another form. You will need to specify the parent form"
$parent.Controls['statusbar1'].Text = 'your message'
It you are trying to update the current forms statusbar then you may need to use "DoEvents"
$parent.Controls['statusbar1'].Text = 'your message'
It you are trying to update the current forms statusbar then you may need to use "DoEvents"
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: multiple form project
The get-wmiobject command goes in your mainform under the call-childform. Think of it like this, when you call the child form your main script is paused until the childform is closed. It picks right up on the next line of the mainform after the child form button is clicked.
All forms are functions and compiled into one big script.
All forms are functions and compiled into one big script.
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am