Floating toolbar
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.
Floating toolbar
My application is a set of tools that aid in coding using powershell studio gui. When I work in the ide, I want the main window of my app minimized but I want a floating tool bar with important buttons. If I maximize the main app, I want the toolbar to close. What is the best way to accomplish that? At present, I have it set up so that minimizing the main form in my app will open a new form with the buttons that I need. But this set up requires me to manually close the tool bar form before I can give focus back to the main form. I want that to be automatic so that maximizing the main form minimizes the tools form and visa versa. The code for the tool bar is attached.
- Attachments
-
- KommandStrip.psf
- (74.88 KiB) Downloaded 32 times
Re: Floating toolbar
Wow! Is that confusing. I can see why you are stuck. You cannot have two modal dialogs on the screen at the same time and have both active. The last guy up controls everything and the first form can do nothing. PowerShell has only one thread so it can execute only one line of code at a time or one script. Each form is a new script although it is wrapped in a function. When the function exits the form will close and the calling form will now be able to execute code.
Check the Sapien articles for more background on why this happens and some hints as to other ways to accomplish your task.
Check the Sapien articles for more background on why this happens and some hints as to other ways to accomplish your task.
Re: Floating toolbar
Thank you for the reply. I appreciate your help as I am obviously very new to powershell studio. As an alternative, I would be happy if closing the tool bar maximized the main form. This code maximizes the main wizard but leaves the tools form visible and dead. Just closing out of the tools form by clicking on the x in the upper right closes the tool window but doesn't maximize the main window. How can I accomplish both in one click: (1) maximize the main form; (2) close the child form.
$buttonX_Click={
Show-Wizard_psf
}
$buttonX_Click={
Show-Wizard_psf
}
- Alexander Riedel
- Posts: 8488
- Last visit: Mon Apr 15, 2024 3:28 pm
- Been upvoted: 37 times
Re: Floating toolbar
Disclaimer: I have not looked at your code.
Maybe it would be easier it you split it into two processes? The toolbar launches/activates the main form when closed. The main form terminates the toolbar process when activated. When minimized the main form starts the toolbar process. If there is little to no data exchanged between the two processes, this might make it easier.
Maybe it would be easier it you split it into two processes? The toolbar launches/activates the main form when closed. The main form terminates the toolbar process when activated. When minimized the main form starts the toolbar process. If there is little to no data exchanged between the two processes, this might make it easier.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Floating toolbar
Thank you for the reply. Two processes is a good idea. I'd prefer not to terminate the main process but don't care if the toolbar stays running or closes. It seems that splitting the processes, while a clever solution, would make it more difficult to maintain. I would prefer a strategy in which closing the toolbar closes its form but at the same time maximizes the main form. Isn't there a method by which a form can close itself? Something like: show-myform_psf.Close()
Re: Floating toolbar
Got it. I was missing the fact that there is a $this variable. The following works. I knew that it had to be simple.
$buttonX_Click={
$this.Parent.hide()
Show-Wizard_psf
}
Thank you both for your help.
$buttonX_Click={
$this.Parent.hide()
Show-Wizard_psf
}
Thank you both for your help.
- Alexander Riedel
- Posts: 8488
- Last visit: Mon Apr 15, 2024 3:28 pm
- Been upvoted: 37 times