May 19, 2024, 02:08:28 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Hiding Console Cursor

Started by GWS, August 04, 2016, 10:02:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

August 04, 2016, 10:02:15 PM Last Edit: August 05, 2016, 03:37:57 AM by GWS
Hi folks,

I noted the discussion on hiding the console cursor in the IWB section ..  ;D

Strange I can't find any reference to it before ..

Anyway, for completeness, here's the Creative translation ..  ::)


' Console mode cursor manipulation

TYPE cInfo
def s:int
def v:int
ENDTYPE
def size,visible:int
def hStdOut,p:int

DECLARE "kernel32",GetConsoleCursorInfo(hConsoleOutput:INT, lpConsoleCursorInfo:CONSOLE_CURSOR_INFO),INT
DECLARE "kernel32",SetConsoleCursorInfo(hConsoleOutput:INT, lpConsoleCursorInfo:cInfo),INT
DECLARE "kernel32",GetStdHandle(nStdHandle:INT),INT

def cInf:cInfo

OPENCONSOLE

PRINT" Press any key to step forward"

' Save original cursor information

' Note: STD_OUTPUT_HANDLE = -11 = 0xFFFFFFF5   this is the console screen buffer

hStdOut = GetStdHandle(0xFFFFFFF5)

' Note: STD_INPUT_HANDLE = -10 = 0xFFFFFFF6  this is the console input buffer

GetConsoleCursorInfo(hStdOut,cInf)
size = cInf.s
visible = cInf.v

' Show original cursor
locate 5,5
PRINT " Original cursor: ",

do:until inkey$ <> ""

' Hide the cursor
cInf.s = 100
cInf.v = 0
p = SetConsoleCursorInfo(hStdOut,cInf)
PRINT
locate 5,5
PRINT " Hey, no cursor! "
do:until inkey$ <> ""

' Show original cursor
hStdOut = GetStdHandle(0xFFFFFFF5)
cInf.s = size
cInf.v = visible
p = SetConsoleCursorInfo(hStdOut,cInf)

locate 5,5
PRINT" Now the cursor is back: ",
do:until inkey$ <> ""
CLOSECONSOLE
END



all the best, :)

Graham
Tomorrow may be too late ..

Egil

QuoteStrange I can't find any reference to it before ..

Exactly what I thought too. But using these APIs were one of the first things I did after purchasing EB and CB when I retired. Can't find that code though, but I remember struggling a lot to retreive the original  cursor when calling SetConsoleCursorInfo with a non-zero visibility value.
Because if I call it without using the saved visibility value, I get a square "blob" cursor here. Maybe this fact can be used for changing cursor type in console mode?

Also, if we add  a new line: DEF hStdOut,p:INT, all variables are properly defined and AUTODEFINE "off" can be used whithout warnings popping up.

(The same can be done using IWB)


Regards,
Egil.

Support Amateur Radio  -  Have a ham  for dinner!

GWS

Hi Egil,

Thanks for the DEF hStdOut,p:INT definition  .. very remiss of me not trying it with Autodefine "off" ..  ;D

best wishes, :)

Graham
Tomorrow may be too late ..

Egil

August 05, 2016, 04:20:45 AM #3 Last Edit: August 05, 2016, 04:23:10 AM by Egil
Hehe, didn't think of it myself either when commenting Brian's code in the IWB section yesterday.
My friends in the background here say it's the advanced age.... But that can't be true.  :D

House is filling up with radio amateurs here today. Its my turn to arrange the annual club barbecue. Have just told them that first they have to catch their own food before I light up the grill... I lied, of course, but a couple of them now do intensive studies of my neighbours chicken. The others prepare fishing rods.
And if the band conditions improves tonight, there is a chance for hearing us on the 20m band. But all we can hear right now is the ticking produced by an electrical fence...


73's
Egil
Support Amateur Radio  -  Have a ham  for dinner!

GWS

Oooh !  a barbecue .. that sounds nice  ;D

I hope it goes well, and the interference dies down ..

best wishes, :)

Graham
Tomorrow may be too late ..

Egil

Thanks Graham,

These annual events usually are very entertaining. The fishing team have just returned with lots of mackerel, a couple of pollocks, and a sea trout. So in addition to all the meat and vegetables I already had purchased, we can keep the barbecue going for days....
And if one should judge by the amount of beer that some of the guys have brought with them, none of them will be able to go home before some time next week...
Turning off the computer now.... 8) 8)
Support Amateur Radio  -  Have a ham  for dinner!