c pound

I reject your reality and substitute my own!

  Home  |   Contact  |   Syndication    |   Login
  46 Posts | 0 Stories | 25 Comments | 41 Trackbacks

News

Archives

Image Galleries

Blog Communities

Blog is a stupid word

Lunch Hour

Resources

This took me quite a bit of work in .Net 1 ... now it's easy. Bah!

public static void ScaleToFillScreen(Form form)
{
    form.FormBorderStyle =
FormBorderStyle.None;

    //calculate the appropriate scale-factor
    SizeF sf = new SizeF();
    sf.Width = (
float)SystemInformation.PrimaryMonitorSize.Width / (float)form.Width;
    sf.Height = (
float)SystemInformation.PrimaryMonitorSize.Height / (float)form.Height;

    //scale the form and the font
    form.Scale(sf);
    form.Font =
new Font(form.Font.FontFamily, form.Font.SizeInPoints * sf.Width, form.Font.Style);

    form.WindowState =
FormWindowState.Maximized;
}

posted on Wednesday, November 30, 2005 11:22 AM