Why are PowerShell Studio GUI's not WYSIWYG?

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 5 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Brendan49
Posts: 14
Last visit: Tue Feb 13, 2024 11:06 am

Why are PowerShell Studio GUI's not WYSIWYG?

Post by Brendan49 »

Hello,

I've often wondered this over the course of time and finally decided to post a question about it. It seems that whenever I've done anything where I try to make a GUI in PowerShell Studio I end up fighting with the editor for quite some time to try to get the look I want. That is, I place buttons and labels in certain spots only to have them shift slightly when I either run the GUI app in PowerShell Studio or else as a packaged application.

Case in point, right now I have two buttons that are supposed to be at the bottom left and right hand corners of a form, respectively. However, if I run the app within PowerShell Studio the buttons appear a number of pixels too far down so that they are no longer fully showing. Try running it packaged and the buttons are in the right place. Try copying the app to other computers (one is another Windows 10 system like my own, and the other being Windows Server 2012), and the buttons are now shifted UP a number of pixels for some reason. Incidentally, for some other buttons, I'm using the Wingdings 3 font to leverage up and down arrows for a listbox. On the one Windows Server 2012 server I'm testing on the arrows now appear as garbage characters.

In all cases the resolution on the computers was the same 1920 x 1080 (not that that should even matter). For my form and buttons I've tried to turn on anything I could find to make things fixed and so that any autosizing is disabled. The overall form itself is set to not allow any re-sizing. It is at a fixed 1024 x 768.

Just as a further FYI, I also had wanted to have a background image that I could Drag and Drop a file onto. I quickly realized that the picturebox control doesn't have the AllowDrop method so I used a label that does and then assigned a picture to the label that takes up the whole part of the forms available area. I then sent the label to the back so that the buttons I am talking about above are on top of it. I'm not sure if doing things in this way could somehow be causing me issues. There are even other buttons on the form that are also not in the right place as well under these same scenarios.

Anyway, are there some guidelines you can provide so that I don't have to keep wondering how things will look on a particular system and so that I can truly achieve a GUI that is WhatYouSeeIsWhatYouGet from PowerShell Studio?

Thank you!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Why are PowerShell Studio GUI's not WYSIWYG?

Post by jvierra »

Here is a good place to start:

https://info.sapien.com/index.php/guis/ ... -shrinkage

https://info.sapien.com/index.php/guis/ ... i-displays

https://info.sapien.com/index.php/guis/gui-scripting

Most of your issues are caused by a lack of understanding about how Microsoft has intended for forms to work. THe history of GUI design has dictated what controls do and how they are used. When you attempt to use controls and forms in ways that were not intended then things will not work as expected. I also have noticed that many new to programming and GUI scripting try to accomplish things they have seen in forms without realizing that many commercial forms are using custom controls that can do things that the standard controls cannot easily do.

Most newer apps now use WPF forms and not Windows Forms. WPF has more and better support for more complex and fancier forms.

Windows Forms have been evolving for decades. It is a very complex technology designed to support classic data entry requirements. There are some books available that discuss the technology of forms and how to design with Forms. Unfortunately they are all written in C#, VB.Net, C/C++ and assume a good proficiency in programming but they can still be helpful in understanding forms.

Overall the more you understand about forms technology the easier design becomes. It is not something you can learn by trial and error techniques.

As far as you issues with WYSIWYG, this is not a technical term but I suspect you mean that controls do not stay where you put them. Controls have "docking" and "anchor" properties that allow us to determine how a control relates to a container. There is also a whole group of properties under "Layout" that assist with siting controls.

Also be aware of the requirements for high DPI monitor support.
User avatar
Brendan49
Posts: 14
Last visit: Tue Feb 13, 2024 11:06 am

Re: Why are PowerShell Studio GUI's not WYSIWYG?

Post by Brendan49 »

Thanks for all the information and background. I will take my time studying this.
User avatar
MarvelManiac
Posts: 63
Last visit: Thu Sep 13, 2018 3:40 pm

Re: Why are PowerShell Studio GUI's not WYSIWYG?

Post by MarvelManiac »

I would throw in the fact when making an application, your DPI should be set at 100% and the form has the setting of AutoScaleMode to Dpi
I have 2k monitors and the techs have 1920x1080 monitors and all buttons,labels, text, etc.. are the same across all 100+ computers
This topic is 5 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked