Hiding cursor in console (HLA) 
Author Message
 Hiding cursor in console (HLA)

Hello,

as i am quite new to assembler, please excuse my ignorance...
I am just learning assembler reading the excellent book "AoA", and doing
some exercises from there with HLA.

My simple question is: How can I hide the cursor in the console window
(and show it again)? E.g., when I run the following program, it exactly
does what I want (waiting for a keypress and then terminate), but I
always see a blinking cursor while waiting for the keypress.

program test1;  // HLA-program: Wait until any key pressed.
#include ("stdlib.hhf")

static
        INP: win.INPUT_RECORD;

begin test1;

        stdout.put ("Press any key to terminate!");

        forever
                console.readInput ( INP );
                breakif (eax);          
        endfor;
end test1;

Thank you in advance for any advice.
Best regards
Helmut



Wed, 19 Jan 2005 16:35:22 GMT  
 Hiding cursor in console (HLA)


Quote:
> Hello,

> as i am quite new to assembler, please excuse my ignorance...
> I am just learning assembler reading the excellent book "AoA", and doing
> some exercises from there with HLA.

> My simple question is: How can I hide the cursor in the console window
> (and show it again)? E.g., when I run the following program, it exactly
> does what I want (waiting for a keypress and then terminate), but I
> always see a blinking cursor while waiting for the keypress.

To hide the cursor you'll need to make some Win32 API calls.
There is documentation on Webster that describes all the Win32
calls (well, most of them, anyway).  The console stuff is documented
in the Kernel32 section.  Off the top of my head I don't remember
how to do this, but the calls do exist.

Note that HLA/Win32 supports a console module.  There are some
useful console-related procedures in that module you can call.
See the HLA Standard Library documentation for more details.
Randy Hyde



Thu, 20 Jan 2005 13:29:43 GMT  
 Hiding cursor in console (HLA)
Randall Hyde schrieb:

Quote:

> To hide the cursor you'll need to make some Win32 API calls.
> There is documentation on Webster that describes all the Win32
> calls (well, most of them, anyway).  The console stuff is documented
> in the Kernel32 section.  Off the top of my head I don't remember
> how to do this, but the calls do exist.

> Note that HLA/Win32 supports a console module.  There are some
> useful console-related procedures in that module you can call.
> See the HLA Standard Library documentation for more details.
> Randy Hyde

Hello, thank you for your answer.
I think I have found the API call I need in kernelref.pdf:

1.339 SetConsoleCursorInfo

Unfortunately, I could not find a reference to this function in the
console module, HLA Standard Library, so i guess I have to call the
function on my own, which seems to be a rather hard task for a beginner.
Well, nevertheless I gave it a try, so I declared the function as
follows in my program:

static
        SetConsoleCursorInfo: procedure
                        (
                                hConsoleOutput:      dword;
                            var lpConsoleCursorInfo: CONSOLE_CURSOR_INFO
                        );

                        returns( "eax" );


Then I defined a new type CONSOLE_CURSOR_INFO, according to information
I found on the MSDN-WebSite:

type
        CONSOLE_CURSOR_INFO:
                record  
                        dwSize:         dword;
                        bVisible:       boolean;
                endrecord;

                lpConsoleCursorInfo: pointer to CONSOLE_CURSOR_INFO;

Then I defined a new variable and set the values:

static
        CCI: CONSOLE_CURSOR_INFO;

begin No_Cursor;

        mov (false, CCI.bVisible);

But now I am stuck. I still cannot call SetConsoleCursorInfo, because I
don't have the first parameter it requires. What shall I do with the
first parameter of SetConsoleCursorInfo, hConsoleOutput? According to
kernelref.pdf it is  a " ... Handle to a console screen buffer. The
handle must have GENERIC_WRITE access..." How do I get such a handle for
the current console? How can I enable generic write access?

Best regards,
Helmut



Thu, 20 Jan 2005 22:29:44 GMT  
 Hiding cursor in console (HLA)


Quote:
> Hello, thank you for your answer.
> I think I have found the API call I need in kernelref.pdf:

> 1.339 SetConsoleCursorInfo

> Unfortunately, I could not find a reference to this function in the
> console module, HLA Standard Library, so i guess I have to call the
> function on my own, which seems to be a rather hard task for a beginner.

No, it's not in the console module.  Yes, dealing with the Win32 API is
a rather hard task for a beginner :-)  HLA's standard library doesn't
attempt
complete coverage of the console (or other) stuff because that would make
the library just as imposing as the Win32 API itself.  Indeed, I've come
to believe that putting the console stuff in the standard library was a big
mistake -- it's not portable (most of the standard library, with the
noticable
exception of the console module, ports to Linux and other OSes without
too much difficulty).

Quote:
> Well, nevertheless I gave it a try, so I declared the function as
> follows in my program:

> static
> SetConsoleCursorInfo: procedure
> (
> hConsoleOutput:      dword;
>     var lpConsoleCursorInfo: CONSOLE_CURSOR_INFO
> );

> returns( "eax" );


> Then I defined a new type CONSOLE_CURSOR_INFO, according to information
> I found on the MSDN-WebSite:

> type
> CONSOLE_CURSOR_INFO:
> record
> dwSize: dword;
> bVisible: boolean;
> endrecord;

> lpConsoleCursorInfo: pointer to CONSOLE_CURSOR_INFO;

> Then I defined a new variable and set the values:

> static
> CCI: CONSOLE_CURSOR_INFO;

> begin No_Cursor;

> mov (false, CCI.bVisible);

> But now I am stuck. I still cannot call SetConsoleCursorInfo, because I
> don't have the first parameter it requires. What shall I do with the
> first parameter of SetConsoleCursorInfo, hConsoleOutput? According to
> kernelref.pdf it is  a " ... Handle to a console screen buffer. The
> handle must have GENERIC_WRITE access..." How do I get such a handle for
> the current console? How can I enable generic write access?

Off the top of my head I don't remember how to do this (I wrote the console
module a year or two ago and haven't thought about it since).  However, I'm
pretty sure that the console output handle gets used throughout the HLA
Standard Library Module's source code, so I'd recommend taking a look
at some of that code.

BTW, I've got new header files for Windows that I'll put up some year that
will have most of the definitions you're looking for. :-)  Just have to get
some
other projects out of the way first.

In any case, the way you progress from beginner to expert is by doing
exactly what you're doing -- read the Win32 documentation and play
around with the stuff until you get it working.  That's exactly how I
developed
most of the console module stuff way back when...
Randy Hyde



Fri, 21 Jan 2005 03:24:41 GMT  
 Hiding cursor in console (HLA)
Randall Hyde schrieb:

Quote:



> > Hello, thank you for your answer.
> > I think I have found the API call I need in kernelref.pdf:

> > 1.339 SetConsoleCursorInfo

> > Unfortunately, I could not find a reference to this function in the
> > console module, HLA Standard Library, so i guess I have to call the
> > function on my own, which seems to be a rather hard task for a beginner.

> No, it's not in the console module.  Yes, dealing with the Win32 API is
> a rather hard task for a beginner :-)  

Yes, that's true, just experienced it for myself ...

[...]

Quote:

> In any case, the way you progress from beginner to expert is by doing
> exactly what you're doing -- read the Win32 documentation and play
> around with the stuff until you get it working.

And it's fun to get something working! I like solving puzzles :-)

Finally I got the invisible-cursor thingy working! My first fully
functional assembler-program! ;-)
Thank you, Randy, for your hints!

Best regards,
Helmut

PS: Ummm, maybe someone wants to see the source? As I don't want to
bother the experts here, I include a link, just for the case, another
beginner is lurking ... here it is:

http://members.aon.at/hweinberger/HideCursor.hla

(Tried to well-document it, but alas, my English is not the best ....)



Fri, 21 Jan 2005 06:05:01 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Hiding the DOS console on a console application on Windows

2. How do I hide the console??

3. Hide Console in windows

4. Hiding Console?

5. Hiding Macintosh Console

6. simple question: want to hide non-console window

7. Problems to hide console in Windows NT

8. Problem to hide console under Windows NT

9. hide the Tcl console

10. Hiding the console

11. Cursor positioning with console application under Windows NT

12. Console cursor position

 

 
Powered by phpBB® Forum Software