How to adjust MDI forms size according to screen size...?

Hi...

In my MDI application , Before loading my parent form i want to check my screen size & according to that i want to adjust my MDI parent & child form size. In my application, I have a child form which is always active & which is covering the parent forms area.

For that I want to adjust my parent form & that child forms area according to the screen size. How I can do this in C#...

Thanks & regards,

Vinay



Answer this question

How to adjust MDI forms size according to screen size...?

  • mtfurious

    Hi...

    Thanks...

    But with this,I think i can only change my MDI parent size...How can I change my child forms size to fit inside the parent forms area & position the child from at (0, 0) according to MDI parent form.

    Thanks for your reply,

    Vinay


  • rtaiss

    There is no documented way to get the MDI client rectangle that I'm aware of. But there is an undocumented way. I'm not sure if you should use it, but here's code for an MDI child form that positions itself inside the parent as large as it fill fit without scroll bars:

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Reflection;

    namespace WindowsApplication1 {
    public partial class Form2 : Form {
    public Form2() {
    InitializeComponent();
    }
    private void Form2_Load(object sender, EventArgs e) {
    Type t = typeof(Form);
    PropertyInfo pi = t.GetProperty("MdiClient", BindingFlags.Instance | BindingFlags.NonPublic);
    MdiClient cli = (MdiClient)pi.GetValue(this.MdiParent, null);
    this.Location = new Point(0, 0);
    this.Size = new Size(cli.Width - 4, cli.Height - 4);
    }
    }
    }


  • MikeS

    Try this in your MDI parent:

    private void Form1_Load(object sender, EventArgs e) {
    this.Location = Screen.PrimaryScreen.WorkingArea.Location;
    this.Size = Screen.PrimaryScreen.WorkingArea.Size;
    }



  • How to adjust MDI forms size according to screen size...?