Thread: how to hid cursor?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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,666
    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
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > if (!SetConsoleCursorInfo(hOut, &cursInfo) {
    Is missing a )
    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.

  12. #12
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by Salem View Post
    > if (!SetConsoleCursorInfo(hOut, &cursInfo) {
    Is missing a )
    thanks..

    @mat
    thanks a lot mat! I really apreciate it.. thanks!

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    There probably needs to be a "return true;" at the end of the function too.

    --
    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
    There probably needs to be a "return true;" at the end of the function too.

    --
    Mats
    ow I see.. I don't really understand the program.. thanks

  15. #15
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Then you should be learning the language first.

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