Thread: how to hid cursor?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    26

    how to hid cursor?

    Hello.. I want to ask how to hide cursor?

    you know.. the cursor that's always blink..

    I got this code

    Code:
    class Cursor
    {
    public:
    Cursor():m_visible(true){}
    void Visible(bool visible) { m_visible = visible; }
    private:
    bool m_visible;
    };
    but it doesn't work..

    thanks..

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    So in other words you make up code and wonder why it doesn't work, hoping we'll write it for you.....

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by MacGyver View Post
    So in other words you make up code and wonder why it doesn't work, hoping we'll write it for you.....
    no.. I got that code from friend..

    I want to ask if there is any way to hid the cursor, the code is just an example..

    I just found that conio.h have function

    Code:
    #define _NOCURSOR 0
    but it also doesn't work

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well, which OS / Compiler do you have?
    Whatever the answer is, it will depend on that information.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    In DOS you need to either update the hardware registers directly, or use a BIOS call - you hide the cursor by setting the start and end row of the cusor size to the same value if I remember right [or was it to set both to a "higher value than the number of rows of the text" - it is about 15 years since I did this, so I can't quite remember... (I think I'm doing quite well in remembering roughly how it's done!) ]

    In windows, you need to use GetConsoleCursorInfo and SetConsoleCursorInfo
    http://msdn2.microsoft.com/en-us/library/ms683163.aspx
    http://msdn2.microsoft.com/en-us/library/ms686019.aspx

    If you are using some other environment, then we need to know what it is to be able to find how you do it.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by Salem View Post
    Well, which OS / Compiler do you have?
    Whatever the answer is, it will depend on that information.
    I'm using windows xp sp 2 and using dev c 4.9.9.2..


    In DOS you need to either update the hardware registers directly, or use a BIOS call - you hide the cursor by setting the start and end row of the cusor size to the same value if I remember right [or was it to set both to a "higher value than the number of rows of the text" - it is about 15 years since I did this, so I can't quite remember... (I think I'm doing quite well in remembering roughly how it's done!) ]
    is it really neccesary to update? because I want to give that program to my friends.. do I have to update all of their hardware registers?

    how to use BIOS call?

    thanks..

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    In that case, the above information I gave should solve your problem - using the "Windows Console" part, I mean.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by matsp View Post
    In that case, the above information I gave should solve your problem - using the "Windows Console" part, I mean.

    --
    Mats
    sorry wrong..

    what I need to include? conio2.h?

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Did you read the links I posted?
    It clearly says:
    Quote Originally Posted by MS Webpage
    Header: Declared in Wincon.h; include Windows.h.
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    sorry for the double post..

    I already include windows.h and wincon.h but still doesn't work..

    I got this error message

    Code:
    114 koper.cpp [Warning] `__stdcall__' attribute only applies to function types 
    115 koper.cpp `__in' undeclared (first use this function) 
      (Each undeclared identifier is reported only once for each function it appears in.) 
    116 koper.cpp `__out' undeclared (first use this function) 
    117 koper.cpp initializer expression list treated as compound expression

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You should certainly not include wincon.h - it will be incleded inside windows.h, which has some important declarations used by wincon.h.

    What do you have at line 114 +/- 10 lines in your "koper.cpp"?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #12
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by matsp View Post
    You should certainly not include wincon.h - it will be incleded inside windows.h, which has some important declarations used by wincon.h.

    What do you have at line 114 +/- 10 lines in your "koper.cpp"?

    --
    Mats

    I tried using each windows and wincon but still doesn't working, wincon has different errors..

    in line 114

    Code:
    BOOL WINAPI GetConsoleCursorInfo(

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by LeonLanford View Post
    I tried using each windows and wincon but still doesn't working, wincon has different errors..

    in line 114

    Code:
    BOOL WINAPI GetConsoleCursorInfo(
    Why are you declaring a function prototype that is part of the Windows API? You should be able to use it directly from the windows.h.

    As I said earlier, you NEED to include the whole of "Windows.h" unless you want to go through a ton of more or less strange header files and figure out exactly what parts are needed and what aren't, etc, etc.

    Also, if you still have problems, post about 10 lines around the problem area, as it can be that it's a line before/after that gives the ACTUAL problem.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by matsp View Post
    Why are you declaring a function prototype that is part of the Windows API? You should be able to use it directly from the windows.h.

    As I said earlier, you NEED to include the whole of "Windows.h" unless you want to go through a ton of more or less strange header files and figure out exactly what parts are needed and what aren't, etc, etc.

    Also, if you still have problems, post about 10 lines around the problem area, as it can be that it's a line before/after that gives the ACTUAL problem.

    --
    Mats
    I only copy the code

    Code:
    BOOL WINAPI GetConsoleCursorInfo(
      __in          HANDLE hConsoleOutput,
      __out         PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
    );
    I'm really newbie in cpp and I've place above

    Code:
    #include <windows.h>
    then I should the WINAPI to what?

    thanks..

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The "WINAPI" is a macro declared in the Windows.h which does the "right thing" for making this have the right calling convention for Win32 API calls - I believe this is "stdcall" calling convention.

    But as I said earlier, you don't need any of that. You need to CALL the Get & SetConsoleCursorInfo, not declaret the prototye.

    Note that the DevC++ environment may well come with windows.h files that are modified or use extra includes to "fix up" any Microsoft compiler dependancies that are in the Windows.h file from MS.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Restoring the Cursor
    By leojose in forum Windows Programming
    Replies: 8
    Last Post: 06-09-2005, 12:29 PM
  2. Custom Animated Cursor
    By willc0de4food in forum Windows Programming
    Replies: 3
    Last Post: 05-13-2005, 10:05 PM
  3. Screen Snapshot with Cursor
    By leojose in forum Windows Programming
    Replies: 2
    Last Post: 05-04-2005, 05:35 AM
  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