center the window?
I''m using OpenGl in VC++ 6. In the CreateWindowEx( function it asks for x,y coordinates to create the new window at. Is there anyway I can tell it to center it on the screen? The reason being, on my 19in monitor I put it some x,y coords and got the window centered, but when I ran the program on my 15in monitor the window was halfway off the screen. Is there a function that finds the center?
Thanks,
Brian
use getsystemmetrics(..)
sorry i cant say more but i don''t have all the help on me computer can someone pls tell me which one of the windows sdk help files this function is described in. i try downloading the files from MS but something always goes wrong (its a 500mb download) i need more detailed info on what help files i need
sorry i cant say more but i don''t have all the help on me computer can someone pls tell me which one of the windows sdk help files this function is described in. i try downloading the files from MS but something always goes wrong (its a 500mb download) i need more detailed info on what help files i need
July 18, 2000 11:09 PM
From your problem it sound like u are using a hard coded value for x and y based on the resolution on your comp with the 19inch monitor. And the 15inch monitor is using a different resolution so its not the center anymore. ie.: when in 800x600 the center would be 400x300, but in 1600x1200 the center would be 800x600! Zedzeek is right....you use the GetSystemMetrics function to find the current screen res(size). You can then use a bit of math(divide by 2) to get the center for y and x. Then based on the size of your window, you would take:
screenx -= windowssizex / 2
screeny -= windowsizey / 2
This code is based on a screen where values are like this:
0,0 1024, 0
0, 768 1024, 768
If you dont understand what im saying...email me at :
blide@mail.com
screenx -= windowssizex / 2
screeny -= windowsizey / 2
This code is based on a screen where values are like this:
0,0 1024, 0
0, 768 1024, 768
If you dont understand what im saying...email me at :
blide@mail.com
July 18, 2000 11:10 PM
damn my visual didnt come out right....what i was showing is that the upper left is 0, 0 and right gets higher in x as down gets higher in y.
July 18, 2000 11:11 PM
also forgot to mention that after all that...the screenx and screeny are the coordinates on the screen for the upper left corner of your window...which is what you need(thats what you specify to createwindowex)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement