title: Moving Child Form with Parent Form
body: <p>I've got 2 forms: A Parent and a supporting Child form.</p>
  
  <p>When the Child form is initially displayed, I set something called my "Zero Point", which is where the Child form should be positioned relative to the Parent, and defined by one of the controls on the Parent:</p>
  
  <pre><code>    private void miShowChild_Click(object sender, EventArgs e) {
          if ((m_childForm == null) || m_childForm .IsDisposed) {
              m_formLeft = this.Left + this.Control1.Left;
              m_formTop = this.Top + this.Control1.Top;
              m_childForm = new ChildForm1();
              m_childForm.Show(this);
              m_childForm.Parent_Shift(m_formTop, m_formLeft);
          }
          m_roleMap.TopLevel = true;
      }
  </code></pre>
  
  <p>When the Parent form is moved somewhere else, that information is translated to the Child form:</p>
  
  <pre><code>    private void Form1_MoveResize(object sender, EventArgs e) {
          if ((m_childForm != null) &amp;&amp; !m_childForm.IsDisposed) {
              m_formLeft = this.Left + this.Control1.Left;
              m_formTop = this.Top + this.Control1.Top;
              m_childForm.Parent_Shift(m_formTop, m_formLeft);
          }
      }
  </code></pre>
  
  <p>That logic seems OK, right?</p>
  
  <p>So, what happens in the Child form?</p>
  
  <p>First, I've got these variables defined:</p>
  
  <pre><code>    private bool m_automate;
      private int m_left, m_top;
      private Point m_zero;
  
      private void ChildForm_Load(object sender, EventArgs e) {
          m_left = 0;
          m_top = 0;
          m_zero = Point.Empty;
      }
  </code></pre>
  
  <p>When the Child is set using <code>Parent_Shift</code>, I want to get where this "Zero Point" should be defined:</p>
  
  <pre><code>    public void Parent_Shift(int parentTop, int parentLeft) {
          m_automate = true;
          if (m_zero != Point.Empty) {
              this.Left = parentLeft - m_left;
              this.Top = parentTop - m_top;
          } else {
              this.Left = parentLeft;
              this.Top = parentTop;
          }
          m_zero = new Point(this.Left, this.Top);
          m_automate = false;
      }
  </code></pre>
  
  <p>When the Child form is repositioned, and not because of the Parent moving, then I want to record how far from my "Zero Point" this is:</p>
  
  <pre><code>    private void Form_MoveResize(object sender, EventArgs e) {
          if (!m_automate &amp;&amp; this.Visible) {
              if (m_zero != Point.Empty) {
                  m_left = m_zero.X - this.Left;
                  m_top = m_zero.Y - this.Top;
              } else {
                  m_zero = new Point(this.Left, this.Top);
              }
          }
      }
  </code></pre>
  
  <p>All of the methods are firing, but I can't seem to get the coordinate system figured out.</p>
  
  <p>I can move the Child form around manually, then move the Parent form and the Child form warps to some other location - then moves proportional to the Parent.</p>
  
  <p>I want the Child to remain at some (X, Y) coordinates relative to the Parent.</p>
  
  <p>When the Child form is moved, that relative coordinate needs to be updated to be where ever the Child form was left.</p>
  
  <h2>Does anyone know how to fix my issue?</h2>