Re: Hide Cursor in Console Window
- Posted by jacques_desch Jul 09, 2009
- 1295 views
euphoric said...
jacques_desch said...
use win32 API call SetConsoleCursorInfo()
ref: http://msdn.microsoft.com/en-us/library/ms686019(VS.85).aspx
This doesn't work for me:
ShowConsoleCursor( GetStdHandle( STD_OUTPUT_HANDLE ), 0 )
Is that the right thing to do?
the following code works for me on windows xp pro sp3 in a cmd.exe console
as indicated I'm using euphoria 3.1
--code sample euphoria 3.1 include dll.e include machine.e constant kernel32=open_dll("kernel32.dll") constant iGetStdHandle=define_c_func(kernel32,"GetStdHandle",{C_INT},C_INT) constant STD_INPUT_HANDLE=-10,STD_OUTPUT_HANDLE=-11,STD_ERROR_HANDLE=-12 global function GetStdHandle(integer std_handle_number) return c_func(iGetStdHandle,{std_handle_number}) end function constant iSetConsoleCursorInfo=define_c_func(kernel32,"SetConsoleCursorInfo",{C_POINTER,C_POINTER},C_UINT) constant iGetConsoleCursorInfo=define_c_func(kernel32,"GetConsoleCursorInfo",{C_POINTER,C_POINTER},C_UINT) --ShowConsoleCursor --show or hide console cursor --hScreen is handle of console output buffer returned by GetStdHandle(STD_OUTPUT_HANDLE) --visible is boolean if TRUE show cursor if FALSE hide it. global procedure ShowConsoleCursor(atom hScreen,integer visible) atom fnVal, pCursorInfo pCursorInfo=allocate(8) fnVal=c_func(iGetConsoleCursorInfo,{hScreen,pCursorInfo}) poke4(pCursorInfo+4,visible) fnVal=c_func(iSetConsoleCursorInfo,{hScreen,pCursorInfo}) free(pCursorInfo) end procedure ShowConsoleCursor(GetStdHandle(STD_OUTPUT_HANDLE),1) puts(1,"cursor visible now") while get_key()=-1 do end while puts(1,"\ncursor hidden now") ShowConsoleCursor(GetStdHandle(STD_OUTPUT_HANDLE),0) while get_key()=-1 do end while
Jacques