Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Make forms unmovable

Make forms unmovable

Scheduled Pinned Locked Moved C#
helpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashvin Gunga
    wrote on last edited by
    #1

    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

    S 2 Replies Last reply
    0
    • A 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

      S Offline
      S Offline
      Syed Muhammad Kamran
      wrote on last edited by
      #2

      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; }

      1 Reply Last reply
      0
      • A 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

        S Offline
        S Offline
        Syed Muhammad Kamran
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • S Syed Muhammad Kamran

          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.

          A Offline
          A Offline
          Ashvin Gunga
          wrote on last edited by
          #4

          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

          L 1 Reply Last reply
          0
          • A 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

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            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

            A 1 Reply Last reply
            0
            • L 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

              A Offline
              A Offline
              Ashvin Gunga
              wrote on last edited by
              #6

              Hi Luc, Thanks a lot for your help. I think it works :-)

              Ashvin Gunga

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups