Screen resolution

Started by
2 comments, last by Gorax 15 years, 8 months ago
Hi, I am making a gui for my application where there are options for dialogs to slide in and out...I made this gui setting a resolution of 1024X768 and give static values to sliding...Know when i change the screen resolutionto say 800x600 or 1400X900 or 1280X1024 the sliding is not comming proper..boz of static positions..How to get a general formula to fix this issue...so that i can run in any resolution......
Advertisement
What you need to do is work out how much room the visuals take up, as well as their offsets, in a percentage of the current width and height of the display. For instance, say you have a text box that is 150 pixels wide, and 30 pixels high in your 1024x768 pixel display. Divide the 150 by 1024, and you get roughly 0.1465 (14.65% of the total width), divide 30 by 768 and you get roughly 0.0391 (3.9% of the total height). Multiply those values by the current width and height, and you now have the dimensions of your visuals. Unfortunately, you'll have to recalculate the sizes every single time the dimensions of the window change, but you can usually use one small function to set the offsets and sizes for all of your visuals, and another to iterate through them all.

If your GUI's using Windows' components (or something similar), you might want to ensure that the text boxes have a minimum height to ensure that they can actually display the text, but aside from that, percentages are about the only way to go.
hi,
any other way to implement it......
Sure, there's another way... Define a set of static values for the different resolutions. Doesn't quite scale too well if people try using unsupported resolutions, but that's the only other way to do it.

This topic is closed to new replies.

Advertisement