The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Neil on June 16, 2008, 10:16:25 AM

Title: Hide cursor
Post by: Neil on June 16, 2008, 10:16:25 AM
I am using getkey in a console program & don't want a cursor flashing on screen. In my DOS days you just moved it out of sight onto another page. How do you do it in Win32?
Title: Re: Hide cursor
Post by: hutch-- on June 16, 2008, 11:31:21 AM
Neil,


invoke ShowCursor,TRUE  ; show the cursor

invoke ShowCursor,FALSE ; hide cursor


Make sure you do this correctly both ways or you can lose the cursor.
Title: Re: Hide cursor
Post by: Neil on June 16, 2008, 11:45:32 AM
Thanks Hutch, just what I wanted  :U
Title: Re: Hide cursor
Post by: Tedd on June 18, 2008, 12:20:13 PM
It's probably not what you wanted :P
ShowCursor shows/hides the mouse pointer, not the console cursor.

Try SetConsoleCursorPosition -- http://msdn.microsoft.com/en-us/library/ms686025.aspx
Title: Re: Hide cursor
Post by: Neil on June 18, 2008, 12:30:17 PM
Tedd you're right, I still haven't found a way of doing it :(

I'll have a look at that link you posted, thanks
Title: Re: Hide cursor
Post by: Neil on June 18, 2008, 12:42:42 PM
I've checked the link out Tedd & that's the APi the loc macro calls. I'm wondering now if it's just as simple as hiding the cursor off the bottom of the display, I'll give it a try.
Title: Re: Hide cursor
Post by: Neil on June 18, 2008, 12:45:58 PM
No, that's not it, the display just scrolls down to where the cursor is HMMM!
Title: Re: Hide cursor
Post by: Tedd on June 18, 2008, 01:18:43 PM
Have you tried a negative position? (Try x first, then y if that doesn't work.)

Failing that, how about moving it to the bottom-right corner, and setting it to black text on black background?
Title: Re: Hide cursor
Post by: Neil on June 18, 2008, 02:04:13 PM
Just had a half hour power cut here.
I tried both of those methods Tedd & neither worked.
I've had another idea, there is a way of setting the size (vertically) of the cursor, I wonder if it's possible to reduce it to zero, I'll read up on it.
Title: Re: Hide cursor
Post by: Jimg on June 18, 2008, 02:27:15 PM
try this:.data?
cci CONSOLE_CURSOR_INFO <>
chand dd ?
.code
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov chand,eax
invoke GetConsoleCursorInfo,chand,addr cci
inkey "Press any key to hide cursor"
mov cci.bVisible,FALSE
invoke SetConsoleCursorInfo,chand,addr cci
inkey "Press any key to restore cursor"
mov cci.bVisible,TRUE
invoke SetConsoleCursorInfo,chand,addr cci
inkey "Press any key to exit..."
ret
Title: Re: Hide cursor
Post by: Neil on June 18, 2008, 02:43:27 PM
Just had another power cut!

Thanks Jimg, that code works perfectly :U

All I have to do now is adapt it into my code