I have 4 images that are of decreasing size down the screen. The composition of these images and their relation to each other must appear the same on all possible screen resolutions, with specific regards to their size, and their margins. In other words, the height, width and margins must all be factors of the height and width of the screen. What is the generic formula if the only known values are the height and width of the screen?
I use the following to get the screen height and width:
string Width = Convert.ToString(HtmlPage.Window.Eval("screen.width"));
string Height = Convert.ToString(HtmlPage.Window.Eval("screen.height"));
Loading

FroglegRank #1,020 · 1.9K reputationPosted Mar 30, 2011, 10:25 PM EDT
public partial class Form1 : Form
{
int deskHeight;
int deskWidth;
double ratio = 0.25;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
deskHeight = Screen.PrimaryScreen.Bounds.Height;
deskWidth = Screen.PrimaryScreen.Bounds.Width;
label3.Text = ("Screen resolution = " + Convert.ToString(deskWidth) + " x "+ Convert.ToString(deskHeight));
pictureBox1.Width = Convert.ToInt32((double)deskWidth * ratio);
pictureBox1.Height = Convert.ToInt32((double)deskHeight * ratio);
}
}
Sam HobbsRank #107 · 20.5K reputationPosted Mar 30, 2011, 10:42 PM EDT
Does that answer your question?
Update: Oooops looks like Frogleg beat me to it. I assume his answer is better than mine.
Mc Combi7 reputationPosted Mar 30, 2011, 11:15 PM EDT
The images are all square, right-aligned and top-aligned, so I only need to set the margins from the top and right (left and bottom margins = 0), and use a single value for height and width.
I use the following to get the resolution:
string Width = Convert.ToString(HtmlPage.Window.Eval("screen.width"));
string Height = Convert.ToString(HtmlPage.Window.Eval("screen.height"));