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. Mouse set in the form

Mouse set in the form

Scheduled Pinned Locked Moved C#
question
5 Posts 4 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.
  • P Offline
    P Offline
    PozzaVecia
    wrote on last edited by
    #1

    Goodmorning, I would like to start my form having the mouse set in the form area (in any position is ok, but in the form) at the start. Is it possible? Thanks

    P OriginalGriffO L 3 Replies Last reply
    0
    • P PozzaVecia

      Goodmorning, I would like to start my form having the mouse set in the form area (in any position is ok, but in the form) at the start. Is it possible? Thanks

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Windows Forms? If so, just set MouseLocation to your desired location.

      P 1 Reply Last reply
      0
      • P Pete OHanlon

        Windows Forms? If so, just set MouseLocation to your desired location.

        P Offline
        P Offline
        PozzaVecia
        wrote on last edited by
        #3

        MouseLocation is it a proprties? of which object?

        1 Reply Last reply
        0
        • P PozzaVecia

          Goodmorning, I would like to start my form having the mouse set in the form area (in any position is ok, but in the form) at the start. Is it possible? Thanks

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Yes - you have to work relative to the Form Location property, but it's pretty simple:

          private void frmMain_Load(object sender, EventArgs e)
          {
          Cursor.Position = new Point(Location.X + 10, Location.Y + 10);
          }

          Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • P PozzaVecia

            Goodmorning, I would like to start my form having the mouse set in the form area (in any position is ok, but in the form) at the start. Is it possible? Thanks

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            private void Form1_Load(object sender, EventArgs e)
            {
            Point mid = new Point(Width / 2, Height / 2);
            Cursor.Position = new Point(this.Left + mid.X, this.Top + mid.Y);
            }

            Happy Coding...

            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