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. Cursor detection problem

Cursor detection problem

Scheduled Pinned Locked Moved C#
jsonhelpquestion
3 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.
  • C Offline
    C Offline
    CyberKewl
    wrote on last edited by
    #1

    I'm trying to detect which cursor is currently shown on the screen, whether it is a wait cursor, arrow cursor, etc. Right now, the detection works perfectly EXCEPT that there are 3 cursors that i can't seem to detect sometimes - the hand cursor, horizontal and vertical splitter cursors. The code i'm using is (with the GetCursorInfo API): Info.Size = Marshal.SizeOf(Info.GetType()); GetCursorInfo(out Info); if (Info.Cursor == Cursors.WaitCursor.Handle) CurrentCursor = "Wait"; else if (Info.Cursor == Cursors.Default.Handle) CurrentCursor = "Default"; else if (Info.Cursor == Cursors.AppStarting.Handle) CurrentCursor = "Loading"; else if (Info.Cursor == Cursors.Hand.Handle) CurrentCursor = "Hand"; .... After i did some tests, i noticed that when i convert the values to string, the two values of Info.Cursor and Cursors.Hand.Handle (along with the HSplit and VSplit values as well) do not tally and they tend to change over and over again almost every time i run my application again. The tests were done by displaying the values of Info.Cursor and Cursors.Hand.Handle using codes like these: MessageBox.Show(Info.Cursor.ToString()); MessageBox.Show(Cursors.Hand.Handle.ToString()); I did the tests mostly on Applications that have a weblink and also on web browsers. When using a web browser, the detection seems fine (for the hand cursor at least) but when i run an app that has a weblink somewhere and the hand cursor shows up, the values of Info.Cursor and Cursors.Hand.Handle are totally different. Is there a way around this?

    N 1 Reply Last reply
    0
    • C CyberKewl

      I'm trying to detect which cursor is currently shown on the screen, whether it is a wait cursor, arrow cursor, etc. Right now, the detection works perfectly EXCEPT that there are 3 cursors that i can't seem to detect sometimes - the hand cursor, horizontal and vertical splitter cursors. The code i'm using is (with the GetCursorInfo API): Info.Size = Marshal.SizeOf(Info.GetType()); GetCursorInfo(out Info); if (Info.Cursor == Cursors.WaitCursor.Handle) CurrentCursor = "Wait"; else if (Info.Cursor == Cursors.Default.Handle) CurrentCursor = "Default"; else if (Info.Cursor == Cursors.AppStarting.Handle) CurrentCursor = "Loading"; else if (Info.Cursor == Cursors.Hand.Handle) CurrentCursor = "Hand"; .... After i did some tests, i noticed that when i convert the values to string, the two values of Info.Cursor and Cursors.Hand.Handle (along with the HSplit and VSplit values as well) do not tally and they tend to change over and over again almost every time i run my application again. The tests were done by displaying the values of Info.Cursor and Cursors.Hand.Handle using codes like these: MessageBox.Show(Info.Cursor.ToString()); MessageBox.Show(Cursors.Hand.Handle.ToString()); I did the tests mostly on Applications that have a weblink and also on web browsers. When using a web browser, the detection seems fine (for the hand cursor at least) but when i run an app that has a weblink somewhere and the hand cursor shows up, the values of Info.Cursor and Cursors.Hand.Handle are totally different. Is there a way around this?

      N Offline
      N Offline
      Nnamdi Onyeyiri
      wrote on last edited by
      #2

      try using the .NET way, Cursor.Current :) Another Post by NnamdiOnyeyiri l Website

      C 1 Reply Last reply
      0
      • N Nnamdi Onyeyiri

        try using the .NET way, Cursor.Current :) Another Post by NnamdiOnyeyiri l Website

        C Offline
        C Offline
        CyberKewl
        wrote on last edited by
        #3

        Cursor.Current only detects the cursor within the form. I need to detect the cursor system-wide (i.e: both inside and outside the form).

        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