StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
zyxi  
#1 Posted : Wednesday, June 12, 2019 1:32:08 PM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
I want to set the window to 2/5 of the screen length and 1/4 of the screen width and move it to (1/3 of the screen length and 1/2 of the screen width).
How to achieve it? Thank you
Rob  
#2 Posted : Wednesday, June 12, 2019 5:17:19 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Hopefully this is what you mean, but it has everything you need to change it how you would like.

Note that you could use action.Window.Size and action.Window.Location separately, but this is faster. Those two methods just read/write from the Position property anyway.

The parseInt wrapper calls are to ensure the value is a whole number, not a decimal, or you will get an error since Windows only supports positioning values which are whole numbers (integers).

action.Window.Screen.WorkingArea represents the rectangle of the working area of the screen, for example it does not include the space occupied by the taskbar (if not auto hidden).
action.Window.Screen.Bounds would give you the full dimensions of the screen.


Code:
var position = action.Window.Position;
position.Top = action.Window.Screen.WorkingArea.Top + parseInt(action.Window.Screen.WorkingArea.Height * 0.33);
position.Bottom  = position.Top + parseInt(action.Window.Screen.WorkingArea.Height * 0.4);
position.Left = action.Window.Screen.WorkingArea.Left + parseInt(action.Window.Screen.WorkingArea.Width / 2);
position.Right = position.Left + parseInt(action.Window.Screen.WorkingArea.Width / 4);
action.Window.Position = position;

Edited by user Wednesday, June 12, 2019 5:35:44 PM(UTC)  | Reason: Corrected height calculation, was setting to 1/5

thanks 1 user thanked Rob for this useful post.
zyxi on 6/13/2019(UTC)
zyxi  
#3 Posted : Thursday, June 13, 2019 10:06:23 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

Thanks: 8 times
Was thanked: 1 time(s) in 1 post(s)
Yes, that's what I want, and I know the reason for my previous mistake is that it can't recognize the score.
Thank you, Rob, for helping me a lot.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.