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 / C++ / MFC
  4. Cursor Postition

Cursor Postition

Scheduled Pinned Locked Moved C / C++ / MFC
3 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.
  • S Offline
    S Offline
    sunny
    wrote on last edited by
    #1

    I have problem of finding the curson's position!! When the curson is not inside the program that I create!!!!

    R P 2 Replies Last reply
    0
    • S sunny

      I have problem of finding the curson's position!! When the curson is not inside the program that I create!!!!

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #2

      Check out the AttachThreadInput() Win32 API call. Sorry, that's the best I can provide without spending a lot of time trying it out myself.

      1 Reply Last reply
      0
      • S sunny

        I have problem of finding the curson's position!! When the curson is not inside the program that I create!!!!

        P Offline
        P Offline
        Philip Nicoletti
        wrote on last edited by
        #3

        The following code gets the current mouse position :

        POINT point;
        GetCursorPos(&point);

        // point.x and point.y have the mouse position
        // with respect to the entire screen
        // NOT the application

        The problem is to get this code called whenever the mouse moves. WM_MOUSEMOVE only generates messages when in the application window. The only way I have found to do it is as follows: 1) add a WM_TIMER message to your application 2) code it as follows :

        void YOUR_CLASS::OnTimer(UINT nIDEvent)
        {
        // TODO: Add your message handler code here and/or call default

        CDialog::OnTimer(nIDEvent);

        POINT point;
        GetCursorPos(&point);

        // point.x and point.y have the mouse position
        // with respect to the entire screen
        // not the application

        // do whatever you want with these values

        1. start the timer :

        SetTimer(1,200,NULL); // calls OnTimer() every 200 milliseconds

        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