Posts Tagged ‘Form’


Why does this button close my form?

Monday, June 29th, 2015 by David Corrales
Have you ever copied a button and found that when a user presses it, the form closes immediately afterwards? We are here to answer: Why does this button close my form? The reason the form closes is that the Button control’s DialogResult property is set to a value other than None. This property tells the form to close after the user has clicked the button without you having to explicitly close the form in the button’s click event script block. So next time you copy an OK or Cancel button, be sure to set the button’s DialogResult to None. For…   More »

PowerShell Studio: Knowing when to use STA mode

Monday, March 9th, 2015 by David Corrales
Follow @SAPIENDavid Recently, on our forums, a user asked why certain controls didn’t function correctly or threw an error when he unchecked the STA option in PowerShell Studio. STA (Single Threaded Apartment) and MTA (Multi-Threaded Apartment) determine how a process manages legacy COM objects and their communication with multiple threads. I will not go into the detail, but you need not concern yourself with the inner workings of COM objects, other than to remember that STA is required for some of the GUI controls to function correctly. If you're interested in the details, see Processes, Threads, and Apartments in the…   More »

PowerShell Studio: Form and Script Recovery

Monday, October 20th, 2014 by David Corrales
Once in a while our support team gets a request to recover a script from a packaged executable because the original was lost. In fact this just happened recently when a user contacted us to recover his lost form project from his packaged script. We were able to recover the script, but unfortunately the user still had to rebuild all his GUI forms from scratch. He was at least fortunate enough to be able to copy and paste the script portions of his project without having to completely rewrite it all. Please don’t find yourself in the same situation. For…   More »

PowerShell Studio: New Form Template

Thursday, November 1st, 2012 by David Corrales
In the (v3.1.9) service release we introduced a new form template called: Wizard Template. This template simulates an application wizard by utilizing a TabControl to represent the various pages of the wizard. The template also includes navigation buttons that enable and disable depending on the current position and if the controls validate.   Each tab page has a sample input that must either be entered or checked in order to proceed. For example, tab page “Step 1” has a textbox that must have information entered before proceeding: Before Entering Text: The Next button is disabled.   After Entering Text: The…   More »

PowerShell Studio: Creating Responsive Forms

Wednesday, May 16th, 2012 by David Corrales
When working with GUIs you may have noticed that the Form can freeze when running long scripts. Previously I discussed how to make your loops more responsive in this article, but not every long script comes in the form of a loop. If you truly want to make your forms responsive, you will need to move these slow scripts into another thread and in the PowerShell world this means using jobs. For those of you who aren’t familiar with PowerShell Jobs, they allow you to run scripts while freeing up the console to perform other tasks. In this case it…   More »

South Florida IT Camp 2011

Friday, July 29th, 2011 by David Corrales
I had a fun time at last Saturday’s South Florida IT Camp . The camp was a great opportunity to meet old and new friends. I would like to thank all the IT Camp organizers for allowing me to present a session on "How to create GUIs for PowerShell using PrimalForms 2011.” I would especially like to thank all the attendees. You were a great group! You can download the Sample GUIs created during the session from the Downloads section.…   More »

PrimalForms 2011: Creating Responsive Loops

Friday, July 15th, 2011 by David Corrales
In the PrimalForms: Preventing Multiple Button Clicks blog article, we introduced the [System.Windows.Forms.Application]::DoEvents method, which allows the application to process form events. This method also becomes very useful when you have a script that runs through a long loop. Here is a sample loop with a progress bar you may encounter in your script:$buttonProcessLoop_Click={ #Reset the Progress Bar $progressbar1.Value = 0 for($i = 0; $i -lt $progressbar1.Maximum; $i++) { #Simulate work sleep -Milliseconds 200 #Step the progress bar $progressbar1.PerformStep() } } When we click the button, the script will go through a loop a number of times and step the…   More »