I'm using C# Windows Forms. I have an MDI app with a panel anchored to the left side of the MDI form. I'm opening MDI child windows maximized, which works fine. However, I two two separate problems, which are probably linked, which are:
When I click the restore button on the MDI child form, the form goes to a sort of pseudo-minimized state i the middle of the MDI parent. It's not possible to resize it and stretch it out, or even move it. I can then minimize it (to the bottom of the parent), restore it (to the same strange pseudo-minimized state) or maximize it as before. How to I get it to go to it's normal state... errr... normally.
Another effect which is occuring, which may or may not be related is that when I open the child, the form's title bar doesn't integrate with the MDI menu. There is the child window bar and then under that is the MDI menu bar. Normally these integrate.
I've created a short video to demonstrate this, a picture is worth a thousand words, here: https://youtu.be/l1yFeDFJeMQ
For clarity, the name of the MDI parent for is "mdi". The name of the MDI child form is "frmForm". This might sound strange, but the purpose of "frmForm" is to enable you to design forms.
The calling code in the MDI parent form is this:
private bool EditForm(AppData.Server oServer, AppData.App oApp, int iFrmID)
{
// this edits the form passed within the indicated Appster server/app.
frmForm oFrmForm;
try
{
oFrmForm = new frmForm();
if (!oFrmForm.EditForm(_owner, _g, oServer, oApp, iFrmID)) throw new Exception("Cannot show form for editing.");
return true;
}
catch (Exception ex)
{
_g.Errs.Raise(ex);
return false;
}
}
The code in the MDI child form is here:
public bool EditForm(Form oMDIParent, AppData.Globals oG, AppData.Server oServer, AppData.App oApp, int iFrmID)
{
try
{
_g = oG;
_app = oApp;
_server = oServer;
_mode = Dolphin.enumFormEditMode.Edit;
toolbox.Init(_g, (TextBox)fd.Controls["txtDebug"]);
fd.Init(_g, _server);
fd.SnapToGrid = true;
svEvents.Init(_g);
svSteps.Init(_g);
if (!ReadData(iFrmID)) throw new Exception("Could not read form data.");
if (!PopulateParams()) throw new Exception("Could not populate parameters list correctly.");
if (!PopulateQueries()) throw new Exception("Could not populate queries list correctly.");
if (!PopulateModes()) throw new Exception("Could not populate modes list correctly.");
if (!PopulateControls()) throw new Exception("Could not populate controls list correctly.");
if (!PopulatePropControls(false)) throw new Exception("Could not populate properties control dropdown correctly.");
if (!PopulatePropMode(false)) throw new Exception("Could not populate properties mode dropdown correctly.");
if (!ShowData()) throw new Exception("Could not populate with form data.");
//if (!SetControlAccess()) throw new Exception("Could not set access to controls correctly.");
_isDirty = false; // has to happen after all the fields are setup
if (!ValidateCtrlXml()) throw new Exception("Could not validate XML for controls."); // might set the form dirty if it has to make changes
if (!SetFormTitle()) throw new Exception("Could not set title.");
_g.DatProp.AddSubscriber(new DatPropSubscription(this, _server.ConnectionName, "Ctrl"));
_g.DatProp.AddSubscriber(new DatPropSubscription(this, _server.ConnectionName, "Event"));
_g.DatProp.AddSubscriber(new DatPropSubscription(this, _server.ConnectionName, "FrmMode"));
_g.DatProp.AddSubscriber(new DatPropSubscription(this, _server.ConnectionName, "FrmParam"));
_g.DatProp.AddSubscriber(new DatPropSubscription(this, _server.ConnectionName, "FrmQuery"));
_g.DatProp.AddSubscriber(new DatPropSubscription(this, _server.ConnectionName, "MacroStep"));
this.MdiParent = oMDIParent;
this.WindowState = FormWindowState.Maximized;
this.Show();
txtName.Focus();
txtName.SelectionStart = 0;
txtName.SelectionLength = txtName.Text.Length;
tcForm.SelectedTab = tcForm.TabPages["tabDesign"];
return true;
}
catch (Exception ex)
{
_g.Errs.Raise(ex);
return false;
}
}
Even with the code forcing the form to be WindowState.Normal, it still opens maximized. What am I missing?
Edit: I've made the changes suggested in the "how to avoid screen bouncing" link below. I've now got a different, strange symptom and have created another video of it here: https://youtu.be/MQENr4pNonA
In short, the MDI child appears to open sort-of maximized, but not taking up the whole available area in the MDI parent.
Edit 2: Added the calling code above.