how to hid cursor?

This is a discussion on how to hid cursor? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by matsp The "WINAPI" is a macro declared in the Windows.h which does the "right thing" for making ...

  1. #16
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    Quote Originally Posted by matsp View Post
    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
    I put these

    Code:
    SetConsoleCursorInfo(0, 0);
        GetConsoleCursorInfo(0, 0);
    is it right? it's still doesn't work..

    thanks for your reply..

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No, you can't just pass in zero's to this function - or at least, that won't hide the cursor.

    You probably need something like this:
    Code:
    bool hideCursor(void)
    {
        HANDLE hOut;
        CONSOLE_CURSOR_INFO cursInfo;
    
        hOut = GetStdHandle(STD_OUTPUT_HANDLE);
        if (hOut == INVALID_HANDLE_VALUE) {
           return false;
        }
        if (!GetConsoleCursorInfo(hOut, &cursInfo)) {
           return false;
        }
        cursInfo.bVisible = 0;
        if (!SetConsoleCursorInfo(hOut, &cursInfo) {
            // Error can't set cursor info.
           return false;
        }
    }
    I currently haven't got a setup to check if it works, but it should give you an idea of how it should be done. I'll leave it to you to implement "uhhideCursor".

    --
    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.

  3. #18
    Registered User
    Join Date
    Apr 2007
    Posts
    26
    wow.. I haven't learnt bool yet..

    I just pasted it and got errors

    Code:
     In function `bool hideCursor()': 
    121 koper.cpp expected `)' before '{' token 
    125 koper.cpp expected primary-expression before '}' token 
    125 koper.cpp expected `;' before '}' token
    121 to 125
    Code:
        if (!SetConsoleCursorInfo(hOut, &cursInfo) {
            // Error can't set cursor info.
           return false;
        }
    }
    I wonder why it's error because GetConsoleCursorInfo doesn't error..

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #20
    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!

  6. #21
    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.

  7. #22
    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

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

Page 2 of 2 FirstFirst 12
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, 01:29 PM
  2. Custom Animated Cursor
    By willc0de4food in forum Windows Programming
    Replies: 3
    Last Post: 05-13-2005, 11:05 PM
  3. Screen Snapshot with Cursor
    By leojose in forum Windows Programming
    Replies: 2
    Last Post: 05-04-2005, 06: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21