Hi,
Whatever windows size u want specify in paint event of Form.
Hi Enrico,
Thank you for posting.
I think in order to make a form has the same window status or position of
another form, we should save this information such as size or location to a
"public" variable to which all the forms in your application could access.
Since the forms in your application are all derived from a base form class,
we could add some static variable to the base form class. Then we could add
a VisibleChanged, SizeChanged and LocationChanged event handlers in the
base form class to get and set the static variable.
The following is a sample.
public partial class BaseForm : Form
{
// static variable
private static Point formlocation = new Point(0,0);
private static Size formsize = new Size(300,300);
private static FormWindowState formwindowstate =
FormWindowState.Normal;
public BaseForm()
{
InitializeComponent();
this.VisibleChanged += new EventHandler(Form2_VisibleChanged);
this.SizeChanged += new EventHandler(Form2_SizeChanged);
this.LocationChanged += new
EventHandler(Form2_LocationChanged);
}
void Form2_VisibleChanged(object sender, EventArgs e)
{
this.WindowState = formwindowstate;
this.Size = formsize;
this.Location = formlocation;
}
void Form2_LocationChanged(object sender, EventArgs e)
{
formlocation = this.Location;
}
void Form2_SizeChanged(object sender, EventArgs e)
{
formwindowstate = this.WindowState;
formsize = this.Size;
}
}
Hope this is helpful to you.
If you have other conerns or need anything else, please don't hesitate to
let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
Enrico Campidoglio - 30 May 2006 10:11 GMT
Hi Linda,
Your solution solved the problem, thanks a lot!
P.S I noticed that under some circumstances the current form position or
size are not correctly updated in the common state stored in the base class.
I am trying to isolate the problem but it looks some like some
synchronization issue. The event handlers for 'PositionChanged' and
'SizeChanged' are somewhat delayed which sometimes causes forms to receive
outdated values when becoming visible.

Signature
/Enrico
> Hi Enrico,
>
[quoted text clipped - 57 lines]
> from your issue.
> ====================================================
Linda Liu [MSFT] - 30 May 2006 11:41 GMT
Hi Enrico,
Thank you for your quick response.
If these forms are displayed as MDI child forms in your program, the
position or windows status of these MDI child forms may be incorrect. This
problem is related to the MDI parent form which may change the behavior of
its MDI child forms.
Hope this helps.
Sincerely,
Linda Liu
Microsoft Online Community Support
====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================