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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How can I get the Mouse POsition on click?

How can I get the Mouse POsition on click?

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

    Hello everyone, I would like to be able to get the position of the mouse once the user click the mouse. Can someone be kind enough to tell me how this can be done? Thank you very much and have a great day. Khoramdin

    K 1 Reply Last reply
    0
    • K Khoramdin

      Hello everyone, I would like to be able to get the position of the mouse once the user click the mouse. Can someone be kind enough to tell me how this can be done? Thank you very much and have a great day. Khoramdin

      K Offline
      K Offline
      kkun
      wrote on last edited by
      #2

      Try using Form's MouseClick method , private void GetPosition(object sender, MouseEventArgs e) { int x = e.X; int y = e.Y; MessageBox.Show(x.ToString()+","+y.ToString()); }

      K 1 Reply Last reply
      0
      • K kkun

        Try using Form's MouseClick method , private void GetPosition(object sender, MouseEventArgs e) { int x = e.X; int y = e.Y; MessageBox.Show(x.ToString()+","+y.ToString()); }

        K Offline
        K Offline
        Khoramdin
        wrote on last edited by
        #3

        Hello KKun, Thanx for the help, mate. I did exactly what you suggested and it is almost working! What I mean by almost is that I only get the mouse location at one particular Panel in the Windows Applicatin rather than the entire Appliication's Window. Can you think of anything which can cause such a problem? Thank you for your help, mate/ Khoramdin

        K 1 Reply Last reply
        0
        • K Khoramdin

          Hello KKun, Thanx for the help, mate. I did exactly what you suggested and it is almost working! What I mean by almost is that I only get the mouse location at one particular Panel in the Windows Applicatin rather than the entire Appliication's Window. Can you think of anything which can cause such a problem? Thank you for your help, mate/ Khoramdin

          K Offline
          K Offline
          kkun
          wrote on last edited by
          #4

          For your problem ,i estmate that you have written code under Panel's MouseClick method ,i mean that not entire Application's Click method ,try again and make a reference to the the following code fragment,Good Luck! public Form1() { InitializeComponent(); } _protected override void OnMouseClick(MouseEventArgs e) { int x = e.X; int y = e.Y; MessageBox.Show(x.ToString()+","+y.ToString()); base.OnMouseClick(e); }_

          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