Text overwriting image in label control with image and text aligned middle left

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 6 years and 2 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
MDinice
Posts: 20
Last visit: Sun Feb 19, 2023 4:27 pm

Text overwriting image in label control with image and text aligned middle left

Post by MDinice »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PowerShell Studio 2017 v5.4.145
32 or 64 bit version of product: 64 bit
Operating system: Win 10
32 or 64 bit OS: 64 bit

*** Please add details and screenshots as needed below. ***
Anyway to fix this behavior so its the image and then the text both aligned left. I had previously done this in a form I created manually in PS before I purchased PS Studio in a ps1 file and it behaved properly aligning the image and then the text both with ImageAlign and TextAlign set to MiddleLeft using an ImageList and ImageIndex.
Capture.PNG
Capture.PNG (46.46 KiB) Viewed 3187 times
DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Text overwriting image in label control with image and text aligned middle left

Post by davidc »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Text overwriting image in label control with image and text aligned middle left

Post by davidc »

I recommend using a PictureBox in addition to a label, this way you can ensure they don't overlap.
David
SAPIEN Technologies, Inc.
User avatar
MDinice
Posts: 20
Last visit: Sun Feb 19, 2023 4:27 pm

Re: Text overwriting image in label control with image and text aligned middle left

Post by MDinice »

I thought about doing it that way I wanted to bring it to someone's attention as a possible bug in PS Studio. I found this because I was trying to convert a gui that I wrote manually in native PS to PS Studio. When I did the same thing natively in PS using New-Object System.Windows.Forms.Label setting the same properties I did in PS studio the alignment was fine and the text did not overwrite the label image.
Capture.PNG
Capture.PNG (28.7 KiB) Viewed 3108 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Text overwriting image in label control with image and text aligned middle left

Post by jvierra »

Can't be PSS. The settings are generated exactly like you do it in a hand coded form. Dump the PS1 and look at the code.

I suspect you have some odd setting that is not set as you expect.
User avatar
MDinice
Posts: 20
Last visit: Sun Feb 19, 2023 4:27 pm

Re: Text overwriting image in label control with image and text aligned middle left

Post by MDinice »

There could be a bug when the app generates the label code. My PS Studio screen shot definitely show the over lap where my native PS does not and I verified my native code settings with the same settings in PS Studio properties pane. My goal was to re-do my natively coded project in PS Studio since the form creation is much easier. This is the issue I found when trying to do that. I'm also finding an issue with the treeview control. I use an imagelist and successfully change the images I set the ImageIndex and SelectedImageIndex to the same value for all the nodes because I don't want them to change whne selected. This works fine in preview and as long as I keep the project open. If I close and reopen the project all ImageIndex and SelectedImageIndex values default to 0 the first image in the image list. This to also works fine in my native PS code and only seems to be an issue in the PS Studio version.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Text overwriting image in label control with image and text aligned middle left

Post by jvierra »

Your native code is not setting the form correctly. The form has to be designed the exact way as PSS creates the form.

Create a simple PSS app and look at how the code is generated in the PS1. Compare that to a hand coded script and check that you are crating the form using the correct styles.

PSS does NOT create code that is not PowerShell. Dump the PS1 and run it and it will work correctly. The PS1 generated is exactly what PSS runs. It does not do anything differently.

You need to be sure visual styles are set correctly and that the rendering properties of the form are the same as PSS. YOu also need to be sure that you are setting the DPI rendering correctly for hi-res monitors. Simpler forms not using visual styles will display differently and may be far off on hi-res monitors.

Without a clear code example there is really no way to address your issue.
User avatar
MDinice
Posts: 20
Last visit: Sun Feb 19, 2023 4:27 pm

Re: Text overwriting image in label control with image and text aligned middle left

Post by MDinice »

I apologize if my previous post wasn't clear. I created the project originally natively in PS creating the forms and tediously positioning the controls without the use of PS Studio and the label images displayed properly in the label control as in the first image I attached to this post which is from my original project. I then attempted to recreate my original project in PS Studio obviously because building the forms are much easier then doing it by hand with native PS code. That's when I encountered the second image I posted. I tried this both with and without visual styles enabled [System.Windows.Forms.Application]::EnableVisualStyles() with the same resulting text overwriting the image in both cases. I can zip the project and attach its currently only 2 forms at this point if that will help.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Text overwriting image in label control with image and text aligned middle left

Post by jvierra »

Pictures are not code. There is no way to know what you are doing without the PSF file. Remember that, on hi-res monitors you will need to make adjustments to get things to display correctly.

From what you have posted it is not possible to know what is happening.
This topic is 6 years and 2 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