Have form in right bottom corner?

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 1 year and 10 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
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Have form in right bottom corner?

Post by stevens »

Hi,

Is there a way to have the form for a Powershell Studio project open in right bottom corner?
The idea is to have it opened when a systray icon is clicked, then opened just above a systray icon (other question I asked in these forums).

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

Re: Have form in right bottom corner?

Post by jvierra »

You can create and launch a form from an icon event. Look at the Sapien blog posts for more details.

Here is one: https://www.sapien.com/blog/2017/07/10/ ... owershell/

And another: https://www.sapien.com/blog/2019/01/10/ ... lications/
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Have form in right bottom corner?

Post by stevens »

Thanks, but how do I position the form in the right bottom corner above the systray?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Have form in right bottom corner?

Post by jvierra »

Just calculate the position in the "Load" event and move it.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Have form in right bottom corner?

Post by stevens »

Did that, entered location 2760; 910 and have set startposition manual in form. That works for my screen but when I open the form/exe on another computer it is no visible (range problaby out of screen).
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Have form in right bottom corner?

Post by jvierra »

You have to compute the location for this to work on any machine.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Have form in right bottom corner?

Post by stevens »

Yes, that's what you said, but I have no clue howto do that besides entering what I did.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Have form in right bottom corner?

Post by jvierra »

Get the current screen size and just use basic arithmetic to calculate the new location of the top corner relative to the lower right corner of the screen or relative to any object on the screen.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Have form in right bottom corner?

Post by stevens »

Thanks but again no clue. Googled compute form location powershell and similar other terms but I have nothing to start with.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Have form in right bottom corner?

Post by jvierra »

Get the current screen coordinates. Work from there.


[System.Windows.Forms.Screen]::PrimaryScreen.Bounds

$form.Bounds
This topic is 1 year and 10 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