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. Windows Forms
  4. [VC++] Getting mouse position

[VC++] Getting mouse position

Scheduled Pinned Locked Moved Windows Forms
c++winformsgraphicsgame-devdata-structures
2 Posts 2 Posters 2 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
    kctong529
    wrote on last edited by
    #1

    I am a year 1 engineering student and is quite new to programming. Just learnt the very basics of C++ like looping, pointer, array (not even inheritence, etc). Recently I was taught about windows form application, and yet I only know about double-click on button to add some codes in the event-handler upon clicking, and MessageBox::Show(). I will learn some GDI+ and will be required to display some images moving in the form. If I want to develop a dummy gun game, in which a bullet will be displayed upon clicking (using GDI+), I will need to get the current position of the mouse upon clicking. I looked up the msdn and other search engines but just couldn't understand what class or object or function I should use for this purpose. I could only find something like: public: MouseEventArgs(MouseButtons Button, int Clicks, int X, int Y, int Delta); But I don't know where I should put it in, and how I can get access to the position X and Y. I would like the whole form to be possible for mouse-clicking without any button. Can someone help me?

    L 1 Reply Last reply
    0
    • K kctong529

      I am a year 1 engineering student and is quite new to programming. Just learnt the very basics of C++ like looping, pointer, array (not even inheritence, etc). Recently I was taught about windows form application, and yet I only know about double-click on button to add some codes in the event-handler upon clicking, and MessageBox::Show(). I will learn some GDI+ and will be required to display some images moving in the form. If I want to develop a dummy gun game, in which a bullet will be displayed upon clicking (using GDI+), I will need to get the current position of the mouse upon clicking. I looked up the msdn and other search engines but just couldn't understand what class or object or function I should use for this purpose. I could only find something like: public: MouseEventArgs(MouseButtons Button, int Clicks, int X, int Y, int Delta); But I don't know where I should put it in, and how I can get access to the position X and Y. I would like the whole form to be possible for mouse-clicking without any button. Can someone help me?

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

      The MouseEventHandler[^] delegate should provide what you want.

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      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