Powershell Studio Title text manipulation

Post feature requests, product enhancement ideas, and other product-specific suggestions here. Do not post bug reports.
Forum rules
Do not post any licensing information in this forum.
This topic is 4 years and 1 month 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
owinsloe
Posts: 161
Last visit: Mon Mar 18, 2024 12:33 pm
Been upvoted: 1 time

Powershell Studio Title text manipulation

Post by owinsloe »

Would it be possible to add a table to the text title so you could have a left align cell followed by a right aligned cell?

I would like to specify left aligned product and version on the left and Company (owner) copyright details right aligned on teh right.

You can not really do this by padding with spaces and a resize of the form does not reposition.

Thanks
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Powershell Studio Title text manipulation

Post by brittneyr »

I'm not quite sure what you are asking for, can you please elaborate?
Brittney
SAPIEN Technologies, Inc.
User avatar
owinsloe
Posts: 161
Last visit: Mon Mar 18, 2024 12:33 pm
Been upvoted: 1 time

Re: Powershell Studio Title text manipulation

Post by owinsloe »

Hmmm, after re-reading I can see that I did not explain myself very well (seemed to sound right in my head at the time).

If you look at the image you can see the text position on the Form title bar. I want to be able to separate the two different types of strings and have them remain where they are if the form is resized. I had tried padding with spaces but its not very nice.

'cnwiniadmin v1.0.3.4' left-aligned
'(c) Jade Software Corporation' right-aligned

Thanks
form.jpg
form.jpg (48.92 KiB) Viewed 15157 times
User avatar
owinsloe
Posts: 161
Last visit: Mon Mar 18, 2024 12:33 pm
Been upvoted: 1 time

Re: Powershell Studio Title text manipulation

Post by owinsloe »

Oh, I should explain that I used ms-paint to move the strings into the desired positions to explain what I would like. This is not an example of what the form current has (all text left-aligned)
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: Powershell Studio Title text manipulation

Post by Alexander Riedel »

Hmm, yeah, I can see how you may be tempted to do that. The short answer is, no, there is no such control or style. For a long winded explanation as to why not, please read on :D

There is a thing called CUA (Common User Access) (see https://en.wikipedia.org/wiki/IBM_Common_User_Access) which defined a long time a go where what goes and what certain keys do in an application.
The overall goal was to make all graphical applications adhere to the same standards, so that once user was trained in one application, the knowledge gained would transfer to all other applications and thereby reduce the amount of training required. Which is why *most* windows applications look very similar and even Linux and Apple MacOS apps look somewhat familiar.
The window's caption, which is the area you want to customize, is meant to be descriptive as to the task the window represents.
So if you click on an "open..." item, the following dialog or form should be titled "Open".
The application's main window by convention contains the title of the application, centered. If an app opens documents, single or multiple, it generally either uses a prefix or a post-fix placement for the title.
My document - Very Cool App or Very Cool App - My document
This allows the user to easily comprehend which application is active and what document, if any is open. The main window's caption is also used by the Windows task bar to display information when hovering.
So in general, and that is just my private opinion, I would rather stick to the standard and not mess with that.

If you really want to do that, there is a Windows message, WM_NCPAINT (https://docs.microsoft.com/en-us/window ... wm-ncpaint) which paints all non-client areas of a window.
It is quite a complex undertaking and I think not something you want to tackle in powershell. But you could most certainly paint the actual caption left justified rather than centered and paint additional
supplemental information wherever you like it, without disturbing the actual caption data itself.
This is however not an job for the faint of heart, (just read this https://social.msdn.microsoft.com/Forum ... evelopment) as it involves doing what Windows normally does for you and, usually, undocumented trickery.
But if you want to do that, I wish you the best of luck :D
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
owinsloe
Posts: 161
Last visit: Mon Mar 18, 2024 12:33 pm
Been upvoted: 1 time

Re: Powershell Studio Title text manipulation

Post by owinsloe »

Alexander,
I really appreciate the time you have taken to outline this. I think I will stick to the way it currently works. Thanks
User avatar
owinsloe
Posts: 161
Last visit: Mon Mar 18, 2024 12:33 pm
Been upvoted: 1 time

Re: Powershell Studio Title text manipulation

Post by owinsloe »

Okay, I may be chasing a lost cause but after a little reading I thought I could achieve my deired result approaching this in a different direction. However it does not work and I think I'm comparing apples with pears but can not see where it's going wrong..

The code
$Product = 'cnwiniadmin'
$script:version = '1.0.0.0'

$Font = [System.Drawing.SystemFonts]::CaptionFont
$TotalWidth = ($MainForm.clientsize).width

$Space = ' '
$SpaceSize = ([System.Windows.Forms.TextRenderer]::MeasureText($Space, $font)).width
$SpacePercent = ($SpaceSize * 100)/$TotalWidth

$ProductText = $Product + ' v' + $script:version
$ProductSize = ([System.Windows.Forms.TextRenderer]::MeasureText($ProductText, $font)).width
$ProductPercent = ($ProductSize * 100)/$TotalWidth

$CompanyText = '© ' + (Get-Date -Format 'yyyy') + ' Jade Software Corporation'
$CompanySize = ([System.Windows.Forms.TextRenderer]::MeasureText($CompanyText, $font)).width
$CompanyPercent = ($CompanySize * 100)/$TotalWidth

#Determine space padding
$i=0
do
{
$i++
$SpaceSizeTotal += $SpacePercent
}
until ($SpaceSizeTotal -ge (100 - ($ProductPercent + $CompanyPercent)) )

$Title = $ProductText.PadRight($i,' ') + $CompanyText
$MainForm.text = $Title

The result
form.jpg
form.jpg (35.25 KiB) Viewed 15124 times
User avatar
owinsloe
Posts: 161
Last visit: Mon Mar 18, 2024 12:33 pm
Been upvoted: 1 time

Re: Powershell Studio Title text manipulation

Post by owinsloe »

I know this is a wish list forum but have added to this to show the history behind the query
This topic is 4 years and 1 month 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