Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C# (http://www.programmingforums.org/forum16.html)
-   -   How to stop a window from moving on screen (http://www.programmingforums.org/showthread.php?t=13316)

lucifer Jun 10th, 2007 11:16 AM

How to stop a window from moving on screen
 
Hi
i am creating a windows form application in C# and i want that the user should not be able to move the application around the screen .is there any way to do this .please help

Booooze Jun 10th, 2007 7:18 PM

If you don't mind not having a title bar, then you can set the form border style to none. The user will not be able to move the form.

Samuaijack Jun 15th, 2007 12:56 AM

i tried this on VS 2005

:

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Location = new Point(300, 300);
        }

        //LocationChanged Event
        private void Form1_LocationChanged(object sender,EventArgs e)
        {
            this.Location = new Point(300, 300);
        }
    }
}


lectricpharaoh Jun 15th, 2007 3:25 AM

Question: wh do you want to do this? Denying users the ability to move windows around to their liking is a quick way to have them delete your program.

melbolt Jun 15th, 2007 9:54 AM

edit: oops sorry didn't see samjack already had something like this


:

  1.  
  2.  
  3.         public Form1()
  4.         {
  5.             InitializeComponent();
  6.  
  7.             //gotta set up the event handler for the move event of the form
  8.             this.Move += new System.EventHandler(this.Form1_Move);
  9.         }
  10.  
  11.         //handle the move event
  12.         private void Form1_Move(object sender, EventArgs e)
  13.         {
  14.             //put the form right back where it was
  15.             this.Location = new System.Drawing.Point(50, 50);
  16.         }



All times are GMT -5. The time now is 2:35 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC