Make forms unmovable
-
I am writing a Windows Mobile CE 5.0 device application in VS2005. I want to prevent the user from moving the windows form while maintaining the title bar (though the control box can be hidden). Any help please? Ashvin Gunga
-
I am writing a Windows Mobile CE 5.0 device application in VS2005. I want to prevent the user from moving the windows form while maintaining the title bar (though the control box can be hidden). Any help please? Ashvin Gunga
Declare an instance variable of Type Point name it say loc. In the end of your Form_Load event Handler write this line of code this.LocationChanged += new System.EventHandler ( this.FormName_LocationChanged ); this.loc.X = this.Location.X; this.loc.Y = this.Location.Y; And in the LocationChanged Event Handler private void DbDeploy_LocationChanged ( object sender , EventArgs e ) { this.Location = this.loc; }
-
I am writing a Windows Mobile CE 5.0 device application in VS2005. I want to prevent the user from moving the windows form while maintaining the title bar (though the control box can be hidden). Any help please? Ashvin Gunga
Sorry i didn't noticed you mentioned Windows Mobile CE application.. However you can use the same strategy there as well... Just use Mouse_Move event and check if the Left mouse Button is pressed when the Mouse_Move event has raised... If yes then reassign the location property.
-
Sorry i didn't noticed you mentioned Windows Mobile CE application.. However you can use the same strategy there as well... Just use Mouse_Move event and check if the Left mouse Button is pressed when the Mouse_Move event has raised... If yes then reassign the location property.
Hi Syed, Thanks for your reply. I have tried to use the private instance variables some days back (as you mentioned above). However, this allows the user to move the form, say using the pen (since I am using a touch screen device), and once he stops dragging it, the form goes back to the original position. Instead, I want the user not able to move the form at all. I want the form to be completely unmovable. The reason is because I will maximize the screen and the user should not be allowed to see anything behind the form (e.g. the desktop etc). With the solution above, he is possible to see what's behind. Can you help please? Ashvin Gunga
-
Hi Syed, Thanks for your reply. I have tried to use the private instance variables some days back (as you mentioned above). However, this allows the user to move the form, say using the pen (since I am using a touch screen device), and once he stops dragging it, the form goes back to the original position. Instead, I want the user not able to move the form at all. I want the form to be completely unmovable. The reason is because I will maximize the screen and the user should not be allowed to see anything behind the form (e.g. the desktop etc). With the solution above, he is possible to see what's behind. Can you help please? Ashvin Gunga
AFAIK a form that is maximized can not be moved at all; it normally can be: - restored (to its non-maximized size) - minimized - closed So if you disable the ones you dont want, you're done. I would disable the maximize and minimize buttons, and set it maximized either in Designer or in constructor or Load event. :)
Luc Pattyn
-
AFAIK a form that is maximized can not be moved at all; it normally can be: - restored (to its non-maximized size) - minimized - closed So if you disable the ones you dont want, you're done. I would disable the maximize and minimize buttons, and set it maximized either in Designer or in constructor or Load event. :)
Luc Pattyn
Hi Luc, Thanks a lot for your help. I think it works :-)
Ashvin Gunga