So 2 days ago I asked how to move 2 forms together, I got this answer which really helped me.
But now I would like to know how to move the first form, while the second one is minimized (so it has to stop moving while minimized, or it will result in a crash from the second form...)?
I tried this:
private void MainForm_LocationChanged(object sender, EventArgs e) {
// All open child forms to be moved
Form[] formsToAdjust = Application
.OpenForms
.OfType<ChildForm>()
.ToArray();
FormsToAdjust formsToAdjust1 = new FormsToAdjust(); //added this
// If the main form has been moved...
if (formsToAdjust1.WindowState != FormWindowState.Minimized) //and this statement as well
{
if (m_PreviousLocation.X != int.MinValue)
foreach (var form in formsToAdjust) //... we move all child froms aw well
form.Location = new Point(
form.Location.X + Location.X - m_PreviousLocation.X,
form.Location.Y + Location.Y - m_PreviousLocation.Y
);
m_PreviousLocation = Location;
}
}
but it can't work as it will open the second form each time the main form will be moved (yes this was a stupid attempt, but I really can't manage how to go through that problem)...
So the goal would be to, if the second form is minimized, keep being able to move the main form, without changing the location of the second one.
Any help would be really appreciated, I'm going to continue searching by my side (actually searching for a while now) while waiting for a reply.
Thanks :)