Thread: SetConsoleCursorInfo() related issues..

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    220

    SetConsoleCursorInfo() related issues..

    Very wierd problem..but this code doesn't resize the cursor in my console o.O It compiles and everything but the cursor is normal..like it would be if I didn't resize the cursor..any clues?

    Heres my code:
    Code:
    /*Headers for this file*/
    #include <iostream>
    #include <windows.h>
    #include <conio.h>
    
    /*Namespaces*/
    using namespace std;
    
    /*Globals*/
    HANDLE m_Screen = GetStdHandle(STD_OUTPUT_HANDLE);
    HANDLE m_Keyboard = GetStdHandle(STD_INPUT_HANDLE);
    WORD m_TextColor;
    WORD m_BackgroundColor;
    CONSOLE_CURSOR_INFO curInf;
    
    /*Console Colors*/
    enum ConColor
    {
      ConRed = 1, ConGreen = 2, ConBlue = 4
    };
    
    int main()
    {
      char *title = "WinCon exp.";
        SetConsoleTitle(title);
      SetConsoleCursorInfo(m_Screen, &curInf);
      curInf.dwSize = 100;
      curInf.bVisible = FALSE;
      SetConsoleTextAttribute(m_Screen, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
      DWORD Written;
      char *write = "Hello World!";
      WriteConsole(m_Screen, write, strlen(write), &Written, NULL);
      getch();
      SetConsoleTextAttribute(m_Screen, FOREGROUND_GREEN | BACKGROUND_BLUE);
      WriteConsole(m_Screen, write, strlen(write), &Written, NULL);
      getch();
    
    return 0;
    }
    Bit lost on why it doesn't resize it..does SetConsoleTextAttribute() somehow overwrite my changes? o.O
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Here's your problem:
    Code:
       SetConsoleCursorInfo(m_Screen, &curInf);
       curInf.dwSize = 100;
       curInf.bVisible = FALSE;
    gg

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    If i'm interpreting what you posted right, I tried setting 'curInf.bVisible' to TRUE and going from there, I still got no results.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You need to fill in the structure before you pass it to the function.

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Part 3 of my tutorial.

    http://www.adrianxw.dk/SoftwareSite/...Consoles3.html

    (My web server is playing up at the moment - if it 404's try again later.)
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    Thank you anonytmous

    Adrianxw: Infact that was the tutorial I was looking on Very good site btw.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doxygen failing
    By Elysia in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 04-16-2008, 01:24 PM
  2. windows linux compatibility issues
    By svaidya in forum C++ Programming
    Replies: 3
    Last Post: 08-26-2007, 04:57 PM
  3. Presentation on a Computer related Topic
    By PING in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 08-02-2007, 11:47 PM
  4. hexdump issues
    By daluu in forum C Programming
    Replies: 2
    Last Post: 03-04-2003, 09:01 PM
  5. Related to Pointers
    By Extol in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 08:41 PM