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.

Dark GDK / Window Centering Problem

Author
Message
mikeMarek 597
15
Years of Service
User Offline
Joined: 12th Feb 2009
Location:
Posted: 8th Jul 2009 03:27
I can't get my window to center using dbSetWindowPosition(), it always offsets the window from the center of the screen. I'm using a simple code as such:


I can find the exact values to use for centering, but I want options in my game to adjust screen size and resolution, and I don't want to store the exact values for each resolution, plus the user's screen size might be different - causing more problems.

So, why won't the window center perfectly? Is there something I'm not doing correctly? Also, where is the window registation point (for positioning)? Is it the top-left corner? Center of the window?

Thanks for any help on the subject,
-Mike

Wait... What were we talking about?
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 8th Jul 2009 03:37 Edited at: 8th Jul 2009 03:38
The problem is that dbScreenWidth/height() will return the size of the DBP window--the value you used with dbSetDisplayMode(). Use dbDesktopWidth() and dbDesktopHeight() instead of dbScreenWidth() and dbScreenHeight().

i like orange
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 8th Jul 2009 08:15 Edited at: 8th Jul 2009 08:17
Quote: "The problem is that dbScreenWidth/height() will return the size of the DBP window--the value you used with dbSetDisplayMode(). Use dbDesktopWidth() and dbDesktopHeight() instead of dbScreenWidth() and dbScreenHeight()."


I was also wondering if DarkGDK had some functions for this thanks AndrewT. I had to design my own since I could not find those functions in the list. Here is what i did...



CrypticDragon

You know for a fact that you have reached the edge when you can absolutely see sound!
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 8th Jul 2009 20:31
Quote: "I had to design my own since I could not find those functions in the list."


Oh, sorry about that. They were added to DBP fairly recently, however as you found out GetSystemMetrics() with a value of 0 or 1 (SM_CXSCREEN and SM_CYSCREEN accordingly) does the same thing.

i like orange

Login to post a reply

Server time is: 2024-11-25 06:25:33
Your offset time is: 2024-11-25 06:25:33