title: ScreenToClient keeps setting point value to entire screen resolution
body: <p>I made a few functions so that when you click on a window it drags the window (like when you drag the title bar on regular windows).
  However, whenever I try to drag it, it keeps going to coordinates 0,0 on my screen. (You'll understand the title once you see the code.) I tried IF statements but the window still goes to 0,0 when I drag it (I can't get it to work properly). After I try to drag it a second time from there, it works perfectly (just for that time). Then it goes back to coordinates 0,0 on the screen if I try to drag it again and it keeps on going like that.</p>
  
  <p>Title Bar code to assign events to functions:</p>
  
  <pre><code>this-&gt;menuStrip1-&gt;MouseMove += gcnew MouseEventHandler(this, &amp;CPPGUIForm::MoveWindow);
  this-&gt;menuStrip1-&gt;MouseDown += gcnew MouseEventHandler(this, &amp;CPPGUIForm::titleBarOnClicked);
  this-&gt;menuStrip1-&gt;MouseUp += gcnew MouseEventHandler(this, &amp;CPPGUIForm::titleBarOnReleased);
  this-&gt;menuStrip1-&gt;MouseLeave += gcnew EventHandler(this, &amp;CPPGUIForm::titleBarMouseLeave);
  </code></pre>
  
  <p>MoveWindow function:</p>
  
  <pre><code>private:
      void MoveWindow(Object^ sender, MouseEventArgs^ e){
          POINT p;
          GetCursorPos(&amp;p);
          if (mClicked == true){
                  this-&gt;Location = System::Drawing::Point(p.x - mouseXLocOnWindow, p.y - mouseYLocOnWindow);
  
  
          }
  
      }
  </code></pre>
  
  <p>Title bar click and release functions:</p>
  
  <pre><code>private:
      void titleBarOnClicked(Object^ sender, MouseEventArgs^ e){
          HWND hwnd;
          POINT pt;
          GetCursorPos(&amp;pt);
          ScreenToClient(hwnd, &amp;pt);
  
          mouseXLocOnWindow = pt.x;
          mouseYLocOnWindow = pt.y;
          mClicked = true;
      }
  private:
      void titleBarOnReleased(Object^ sender, MouseEventArgs^ e){
          mClicked = false;
      }
  </code></pre>
  
  <p>Title bar mouse leave function (to fix a bug):</p>
  
  <pre><code>private:
      void titleBarMouseLeave(Object^ sender, EventArgs^ e){
          mClicked = false;
      }
  </code></pre>
  
  <p>Please tell me if you need more info in this post.</p>