c pound

I reject your reality and substitute my own!
posts - 46, comments - 46, trackbacks - 40

My Links

News

Archives

Image Galleries

Blog Communities

Blog is a stupid word

Lunch Hour

Resources

Scale your Form and it's contents to fill the screen

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;
}

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

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

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: