Click to See Complete Forum and Search --> : How to use resolution independent unit?


visharad
March 10th, 2009, 06:02 AM
Take any winform control. As an example, suppose there is a button named btn1. If I write
btn1.Width = 150;

then the Width of betn1 becomes 150 pixels.
But, for all controls in a given winform, I do not want to use pixel as unit. Rather I want to use some unit, which does not depend on resolution, e.g, milimeter.
How do I do that?

BigEd781
March 10th, 2009, 01:37 PM
You could get the current resolution and use the ratio of that to your optimum res. as a scale factor, but I have never found the need. If you don't make things overly large you should be fine. The smallest common resolution these days is something like 1024x768 (I am probably off a little, but it is close.) Just program to meet that requirement and you should be fine.