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. Visual Basic
  4. Cursor Question

Cursor Question

Scheduled Pinned Locked Moved Visual Basic
questioncomjson
5 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.
  • N Offline
    N Offline
    Nick Parker
    wrote on last edited by
    #1

    This question is really a question of why not how. I was playing around with an application that would hide and display the cursor with the Win API ShowCursor. I was calling this function in the load event of the application and it was not working. I had a timer on the form and decided to call the ShowCursor function there. Even though this is repetative it works. Does anyone have any ideas what would cause this? Nick Parker

    J 1 Reply Last reply
    0
    • J Jeremy Falcon

      Because its param isn't a boolean to just toggle the cursor on and off. From MSDN about the param... Specifies whether the internal display counter is to be incremented or decremented. If bShow is TRUE, the display count is incremented by one. If bShow is FALSE, the display count is decremented by one. So, ShowCursor False isn't guaranteed to hide the cursor. If another application passed it True a couple of times it won't hide it. If the internal counter is 0 or greater the cursor will remain visible and it hides if it's -1, so check the return value of ShowCursor() and keep on calling it until the counter is -1. That's why the timer method worked. It ensured the internal counter was -1 by calling it over and over again. The thing is though, once it's hidden you can stop calling ShowCursor() to avoid wasting CPU cycles. Jeremy L. Falcon Homepage : Sonork = 100.16311
      "It was a blind man who taught me how to see." - Aerosmith

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Thanks for the response Jeremy, I figured that out about 30 minutes later during lunch :(( . This was just something that I was playing around with so no worries. :) Nick Parker

      J 1 Reply Last reply
      0
      • N Nick Parker

        This question is really a question of why not how. I was playing around with an application that would hide and display the cursor with the Win API ShowCursor. I was calling this function in the load event of the application and it was not working. I had a timer on the form and decided to call the ShowCursor function there. Even though this is repetative it works. Does anyone have any ideas what would cause this? Nick Parker

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #3

        Because its param isn't a boolean to just toggle the cursor on and off. From MSDN about the param... Specifies whether the internal display counter is to be incremented or decremented. If bShow is TRUE, the display count is incremented by one. If bShow is FALSE, the display count is decremented by one. So, ShowCursor False isn't guaranteed to hide the cursor. If another application passed it True a couple of times it won't hide it. If the internal counter is 0 or greater the cursor will remain visible and it hides if it's -1, so check the return value of ShowCursor() and keep on calling it until the counter is -1. That's why the timer method worked. It ensured the internal counter was -1 by calling it over and over again. The thing is though, once it's hidden you can stop calling ShowCursor() to avoid wasting CPU cycles. Jeremy L. Falcon Homepage : Sonork = 100.16311
        "It was a blind man who taught me how to see." - Aerosmith

        N 1 Reply Last reply
        0
        • J Jeremy Falcon

          Nick Parker wrote: I figured that out about 30 minutes later during lunch Funny ain't it? It's usually the same way with me. When I get away from the computer is when the solution just pops in my head. Oh well, at least it gave me an excuse to visit the VB forum again. :) Jeremy L. Falcon Homepage : Sonork = 100.16311
          "It was a blind man who taught me how to see." - Aerosmith

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          Same here, I had been hanging my head in the C# forum for quite a while. :) Nick Parker

          1 Reply Last reply
          0
          • N Nick Parker

            Thanks for the response Jeremy, I figured that out about 30 minutes later during lunch :(( . This was just something that I was playing around with so no worries. :) Nick Parker

            J Offline
            J Offline
            Jeremy Falcon
            wrote on last edited by
            #5

            Nick Parker wrote: I figured that out about 30 minutes later during lunch Funny ain't it? It's usually the same way with me. When I get away from the computer is when the solution just pops in my head. Oh well, at least it gave me an excuse to visit the VB forum again. :) Jeremy L. Falcon Homepage : Sonork = 100.16311
            "It was a blind man who taught me how to see." - Aerosmith

            N 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