Hi, I am rather baffled at the moment, I have a form which I show as a dialog (although non dialog is the same) in response to a menu item click.
var createUser = new FrmCreateUser();
createUser.ShowDialog();
Somewhere between the constructor exiting, and when the load event is fired the size is being changed.
I have overloaded WndProc in the 'parent' form, although it just falls though to the base implementation so I find it hard to believe that's the cause.
protected override void WndProc(ref Message m)
{
if (m.Msg == (int)WindowsMessages.WM_SYSCOMMAND)
{
if (m.WParam.ToInt32() == (int)WindowsMessages.SC_MINIMIZE)
{
foreach (Form f in Application.OpenForms)
if (f != this)
f.Hide();
}
else if (m.WParam.ToInt32() == (int)WindowsMessages.SC_RESTORE)
{
foreach (Form f in Application.OpenForms)
if (f != this && f.GetType() != typeof (Controls.DockLocation) )
f.Show();
}
}
base.WndProc(ref m);
}
I can restore the size to what is should be in the load event handler, but I remain confused as to the cause.
private void FrmCreateUser_Load(object sender, EventArgs e)
{
Size = new Size(RestoreBounds.Width, RestoreBounds.Height);
}
If anyone can shed some light on this it would be much appreciated.
Edit
Removing the WndProc override has no effect.
SizeChanged is only invoked once (inside the createUser.ShowDialog()
call) which occurs before OnHandleCreated(EventArgs e)
is called.
Edit 2
Here are some pictures to show the effect.
designer:
runtime: