I am having trouble getting the cursor to disappear in a console app.
I am using the GetConsoleCursorInfo and SetConsoleCursorInfo functions.
The first thing I do is use the Get function to read the initial console cursor info structure.
The value returned in bVisible is 0 (false), even though the cursor is visible (should be true).
If I attempt to set bVisible to any value other than 0, I get error 57h (invalid parm).
I can happily set the dwSize variable to any value from 1 to 64h, so long as bVisible is 0.
On a related issue, I notice in windows.inc equates...
TRUE equ 1
FALSE equ 0
Am I missing something here? I always thought it should be...
FALSE equ 0
TRUE equ not FALSE
The later will yield -1 (i.e. 0FFh for bytes, 0FFFFh for words, and 0FFFFFFFFh for dwords).
OK - I tried everything I know - lol - that took all of 10 minutes
I tried writing to the VGA CRTC registers (we all know how that went).
I tried positioning the cursor off-screen - the OS adjusts the window.
These are the tricks we used in the old days to make the cursor disappear on stubborn display adapters.
Any help out there ?
I remember one more trick - let me try it.....
Not easy under windows, but I may be able to set the foreground attribute to black
on some unused location of the screen and set the cursor there when not in use.
.nolist
include \masm32\include\masm32rt.inc
.data?
cci CONSOLE_CURSOR_INFO <>
chand dd ?
.code
program:
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
end program
This works for me. There may be some extraneous stuff in there, it's cut an paste from elsewhere.
dedndave,
does the following example work on your machine? On mine it worked fine.
include \masm32\include\masm32rt.inc
.data?
ConCurInfo CONSOLE_CURSOR_INFO <?>
hStd DWORD ?
.code
start:
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov hStd,eax
.if hStd==INVALID_HANDLE_VALUE
print "Error GetStdHandle",13,10
jmp _exit
.endif
invoke GetConsoleCursorInfo,hStd,ADDR ConCurInfo
test eax,eax
jz _exit
print "dwSize: "
print str$(ConCurInfo.dwSize),13,10
print "bVisible: "
print str$(ConCurInfo.bVisible),13,10
print "now turning cursor off..."
mov ConCurInfo.bVisible,FALSE
invoke SetConsoleCursorInfo,hStd,ADDR ConCurInfo
invoke Sleep,5000
mov ConCurInfo.bVisible,TRUE
invoke SetConsoleCursorInfo,hStd,ADDR ConCurInfo
_exit:
exit
end start
dang - both of those work - lol
i must be doing something wrong
maybe i was bad in a past life (been an angel in this one ::) ) - lol
Thanks guys - i will let you know what i find
lol - dang
my fault totally
i had been looking at the CONSOLE_SCREEN_BUFFER_INFO structure
all the variables are word size
CONSOLE_CURSOR_INFO is (for some odd reason) dwords
so - i was trying to set the high-order word of dwSize rather than bVisible
Thanks for the help guys