Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / How to Center window?

Author
Message
Icerion
1
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 9th Sep 2018 18:34
How do you center a window no matter what resolution it is?

Thanks!
Increase
2
Years of Service
User Offline
Joined: 21st Feb 2017
Location:
Posted: 9th Sep 2018 19:09
e.g.


x=100 : y = 100

SetWindowSize( x, y, 0 )

SetWindowPosition((GetMaxDeviceWidth()-x)/2,(GetMaxDeviceHeight()-y)/2)
Icerion
1
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 9th Sep 2018 19:27 Edited at: 10th Sep 2018 16:26
Hi, @Increase. Thanks for that!
Icerion
1
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 10th Sep 2018 16:27
Although, I tried what you said but it's still not working.



Thanks!
Dark Raven
5
Years of Service
User Offline
Joined: 27th Jul 2014
Location: United States
Posted: 10th Sep 2018 22:23
I'm not sure this will work all the time though at the size you set it seemed at least on my screen to be centered though if you go bigger the height may become a problem with centering vertically.

Try


Again at your dimensions it seems centered but when I set it to 1920,1080 then the vertical centering doesn't work. So it may not work all the time.
Icerion
1
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 10th Sep 2018 22:57 Edited at: 10th Sep 2018 22:58
Is there not any way to center the window no matter what Resolution? There's got to be a way. If Blitz3D can do it then so can AGK.

Thanks!
smallg
Valued Member
13
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 11th Sep 2018 00:47
if the resolution it is trying to display is bigger than the screen can handle then no, you would need to adjust the resolution to fit inside the screen.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Icerion
1
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 11th Sep 2018 02:43 Edited at: 11th Sep 2018 02:54
That's kinda' rediculous though. Blitz did it as simple as:

Thanks!

Login to post a reply

Server time is: 2019-09-21 12:00:27
Your offset time is: 2019-09-21 12:00:27