Thread: Darned Blinking Cursor

  1. #1
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94

    Darned Blinking Cursor

    Does anyone know how to get rid of that darned blinking cursor in text graphics mode in DOS? Or at least change the colors to only black so you can't see it? Any help would be much appreciated.

    (I have already searched the forums and nothing there that works)

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I believe you can change the color's using conio.h. It's not standard, but it is quite widely supported - give it a look.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    44
    Are you running DOS or a Windows 'Command Prompt'? If you are running the later you can use the Win32 API functions GetConsoleCursorInfo and SetConsoleCursorInfo functions to set the cursor size and visibility.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You can use SetConsoleCursorInfo() to hide the cursor under Windows.
    Here's a nice tutorial on console programming under Windows.

    gg

  5. #5
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94
    I am using the Command prompt but everything I have tested (besides the cursor code) has worked. I don't know the syntax for those functions, though.

    By the way I am using C not C++
    Last edited by VOX; 11-20-2004 at 10:31 PM.

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Move the cursor to position 0,25. A regular MS-DOS console has 80*25 resolution, starting at the upper-left corner with 0,0 coordinates. So 0,25 would be outside the screen. That's an accepted technique.

    To the other posters: he's programming directly with video modes, so Windows or POSIX API's won't work.
    Last edited by xErath; 11-20-2004 at 11:42 PM.

  7. #7
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    Quote Originally Posted by xErath
    Move the cursor to position 0,25. A regular MS-DOS console has 80*25 resolution, starting at the upper-left corner with 0,0 coordinates. So 0,25 would be outside the screen. That's an accepted technique.

    To the other posters: he's programming directly with video modes, so Windows or POSIX API's won't work.

    then does it mean that if he wants to accept the input....the user ...watever he is typing will not appear on the screen??
    dont understand this point

  8. #8
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    That's a different story. Since he's working with raw hardware mode, reading input from the keyboard would consist in removing keypresses from the key buffer in memory and transform the scancodes in ascii (or read the ascci itself), rather that using standard input functions, like getchar or scanf's, although getch() or getkey() worked well with me.
    The standard input functions (I think), just determine where the cursor is and place one char at a time there them move the cursor to the next place.

  9. #9
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    _setcursortype
    Syntax
    #include <conio.h>

    void _setcursortype(int _type);

    Description
    Sets the cursor type. _type is one of the following:


    _NOCURSOR
    No cursor is displayed.


    _SOLIDCURSOR
    A solid block is displayed.


    _NORMALCURSOR
    An underline cursor is displayed.


    hope this helps
    Monday - what a way to spend a seventh of your life

  10. #10
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94
    Quote Originally Posted by xErath
    To the other posters: he's programming directly with video modes, so Windows or POSIX API's won't work.
    What do you mean by that? I am using the deafult console mode (80x25 text) and using getch() to read in user input. There are only two problems with my program. When the player or opponent shoots, the game pauses until the shot (a while loop) missis or hits. Also only one person may move at a time, so the game is really turn based. (I don't know how to get around that in C)

    The second problem is when someone shoots, the cursor is always right next to the shot as it moves up/down the screen, so it looks really ugly and it's hard to concentrate on the actual shot.

    If anyone has C for Dummies Volume 2 I am using the same method of animation as the program DROPNUKE.C on page 593. A copy of my source code is in the "Post your games here" thread, it's near the last couple of posts.

    Iain with your above code, how would that appear as a finished function? I don't quite get what you mean.

  11. #11
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Aren't you still working with this? It seems not. Sorry then But the (0,25) cursor coordinate technique remains.
    Last edited by xErath; 11-21-2004 at 10:51 PM.

  12. #12
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    put #include <conio.h> at the top with your includes if it doesnt already exist.

    then at the point you want to switch off the cursor use

    setcursortype(_NOCURSOR);

    to turn it back on again

    setcursortype(_NORMALCURSOR);

    i have used this before and know it works with borland c++ builder, it may not be included in all releases of conio.h as they vary from compiler to compiler.
    hope this helps
    Monday - what a way to spend a seventh of your life

  13. #13
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94
    I gave up on that xErath because I didn't understand it. I am now using This because it works and makes sense. But I am not into graphics yet, I'm starting out with very simple games (text based) and once I get everything worked out I will move to graphics.

    iain the code you gave me doesn't work for some reason. I have conio.h, and am using Turbo C witch is (I believe) is a Borland compiler. I get the error message
    Code:
    Undefined symbol '_NOCURSOR' in function main
    Undefined symbol '_NORMALCURSOR' in function main
    I am simply typing as you said
    Code:
    setcursortype(_NOCURSOR);
    in a specific place and it doesn't work.

    Maybe it's because of Turbo C. Do you know if you have to pay to download Borland C++? I have been wanting to get that.

    xErath by the way your method with locating the cursor won't work with the way I am animating the bullets, I think. A copy of my source code is here.

  14. #14
    Registered User
    Join Date
    Sep 2004
    Posts
    44
    Ah, I see, you are using a DOS compiler in Windows at the Command Prompt.

    Why don't you get a 32-bit compiler? Several are available for free:
    http://www.cprogramming.com/compilers.html
    Add to the list of free ones 'Visual C++ Toolkit 2003', which is a very good command-line compiler.

  15. #15
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    see,if u are working in the dos mode,maybe this will help.
    u can do this,
    make the next display block totally black,and just before calling printf(),make it as white or whatever color u want.i dont know how to put wat i am sayin into words.
    u can use this.

    Code:
     int far *ptr=0xb8000000;
    before every printf(),use
    Code:
     *ptr=0x0f20;
    after the printf(),use
    Code:
     *ptr=0x0000;
    tell me if it works,it worked for me.i use borland 3.0 turbo c compiler.maybe what i said will help you.u can access the video memory directly using this.

    ciao
    [code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom Animated Cursor
    By willc0de4food in forum Windows Programming
    Replies: 3
    Last Post: 05-13-2005, 10:05 PM
  2. BGI and text cursor
    By Somnambulist in forum C++ Programming
    Replies: 4
    Last Post: 01-21-2004, 07:54 PM
  3. blinking cursor
    By dP munky in forum Game Programming
    Replies: 6
    Last Post: 02-15-2003, 11:21 PM
  4. cursor remains in openGL fullscreen
    By Ken Fitlike in forum Game Programming
    Replies: 5
    Last Post: 03-14-2002, 08:52 PM
  5. Mouse in 800x600 24Bit Mode?
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 11-11-2001, 01:38 AM