In Depth Banner
Skip Navigation Links

Select your preferred language

The mouse button handlers. 

    private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)

    {

      cursorOffset=new Point(e.X,e.Y);

      currentPos=new Point(e.X,e.Y);

      if(inborder)

      {

        sizing=true;

        this.Capture=true;

      }

      else

      {

        moving=true;

        this.Cursor=Cursors.SizeAll;

      }

    }

 

    private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)

    {

 

      if(!sizing & closerPos==45 & e.X>this.Size.Width-23 & e.Y<23)

          Application.Exit();

 

      if(sizing | moving)

      {

        sizing=moving=false;

        this.Capture=false;

      }

      //do non-border mouseup actions here    

    }

 

Return to the article. 

Copyright © Bob Powell 2003-2009. All rights reserved