title: Move form without border through a panel
body: <p>I been searching around for a solution for my problem but for now I wasn't able to get any sucessfull code for what I want to do. So, I have a form without border that is filled with 2 custom panels, so there is no way to the user click on the frame, thinking in that, I implement a code that when user click on a panel, this will call a function on my form that recive by parameter the event of the mouse.
  This is the code of my Panel (note that both of my panels in the frame are the same class, it's just 2 diferent instances)</p>
  
  <pre><code> public class MyPanel : System.Windows.Forms.Panel{
  
                         (...)
  
       private void MyPanel_MouseDown(object sender, MouseEventArgs e)
       {
           BarraSms.getInstance().mouseDown(e);
       }
  
       private void MyPanel_MouseMove(object sender, MouseEventArgs e)
       {
           BarraSms.getInstance().mouseMove(e);
       }
  
  }
  </code></pre>
  
  <p>And this is the code of my form:</p>
  
  <pre><code> public partial class BarraSms : Form
  {
    private Point mousePoint;
  
               (...)
  
     public void mouseDown(MouseEventArgs e) {
  
          mousePoint = new Point(-e.X, -e.Y);
  
      }
  
      public void mouseMove(MouseEventArgs e) {
  
          if (e.Button == System.Windows.Forms.MouseButtons.Left)
          {
              Point mousePos = Control.MousePosition;
              mousePos.Offset(mousePoint .X, mousePoint .Y);
              this.Location = mousePos;
          }
  
      }
  }
  </code></pre>
  
  <p>Is there something that I'm missing?
  Thank you in advance for the help.</p>
  
  <p>The working code (update), problem solved by: x4rf41</p>
  
  <p>The <strong>MyPanel Class</strong> :</p>
  
  <pre><code>MouseMove += MyPanel_MouseMove; // added in class constructer
  </code></pre>
  
  <p>the <strong>BarraSms class (Form)</strong></p>
  
  <pre><code>public partial class BarraSms : Form
  {
      public const int WM_NCLBUTTONDOWN = 0xA1;
      public const int HT_CAPTION = 0x2;
  
  
      [DllImportAttribute("user32.dll")]
      public static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
      [DllImportAttribute("user32.dll")]
      public static extern bool ReleaseCapture(); 
  
       public void mouseMove(MouseEventArgs e) {
  
          if (e.Button == System.Windows.Forms.MouseButtons.Left)
          {
              ReleaseCapture();
              SendMessage(this.Handle, WM_NCLBUTTONDOWN, new IntPtr(HT_CAPTION), IntPtr.Zero);
              Point loc = this.Location;
  
              writeCoordToBin(loc.X, loc.Y);
  
          }
  
      }
  
  }
  </code></pre>