Cursor Question
-
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 theShowCursor
function there. Even though this is repetative it works. Does anyone have any ideas what would cause this? Nick Parker -
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 itTrue
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 ofShowCursor()
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 callingShowCursor()
to avoid wasting CPU cycles. Jeremy L. Falcon Homepage : Sonork = 100.16311
"It was a blind man who taught me how to see." - AerosmithThanks 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
-
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 theShowCursor
function there. Even though this is repetative it works. Does anyone have any ideas what would cause this? Nick ParkerBecause 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 itTrue
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 ofShowCursor()
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 callingShowCursor()
to avoid wasting CPU cycles. Jeremy L. Falcon Homepage : Sonork = 100.16311
"It was a blind man who taught me how to see." - Aerosmith -
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." - AerosmithSame here, I had been hanging my head in the C# forum for quite a while. :) 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
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