GetConsoleScreenBufferInfoEx Function

This is a discussion on GetConsoleScreenBufferInfoEx Function within the C++ Programming forums, part of the General Programming Boards category; Im using the Code::Blocks IDE and the default compiler GCC i think. I went on the MSDN site and saw ...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    10

    Question GetConsoleScreenBufferInfoEx Function

    Im using the Code::Blocks IDE and the default compiler GCC i think.

    I went on the MSDN site and saw this function and one of the members of CONSOLE_SCREEN_BUFFER_INFOEX data type is bFullscreenSupported. The site says i need wincon.h and windows.h included. I included the headers and i still get main.cpp|76|error: 'CONSOLE_SCREEN_BUFFER_INFOEX' was not declared in this scope. I cant figure out why its doing that.

    Also in the SetConsoleDisplayMode function when i try and set CONSOLE_FULLSCREEN_MODE the function always fails.

    When the SetConsoleDisplayMode function failed i tried the other function to see if i could do fullscreen. And everywhere i look people always say why would you want it in fullscreen and the answer is because i do and i know its possible without you forcing keystrokes into input.

    If anyone has any ideas id greatly appreciate your feedback. And thanks for your time in advance.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,406
    Do you have autocomplete on? does the parser find "CONSOLE_SCREEN_BUFFER_INFOEX" when you start typing it? post your code, or a relevant part of it too.

    Are you sure it is not CONSOLE_SCREEN_BUFFER_INFO instead?
    Last edited by rogster001; 07-11-2011 at 10:03 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    You need to set your Windows version defines properly so that you target Vista or later.
    This might help: http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jul 2011
    Posts
    10

    Exclamation

    im sure its ex as in extended info and its not letting me put the code tags so i can post the code ill try again. correction i was being retarded and used the code tag html style it works now.

    Code:
    #define _WIN32_WINNT 0x0601
    
    #include <windows.h>
    #include <wincon.h>
    #include <iostream>
    
    // Color definations:
    
    #define FBlack      0
    #define FRed        FOREGROUND_RED
    #define FGreen      FOREGROUND_GREEN
    #define FBlue       FOREGROUND_BLUE
    #define FYellow     FORGROUND_RED | FORGROUND_GREEN
    #define FCyan       FOREGROUND_GREEN | FOREGROUND_BLUE
    #define FMagenta    FOREGROUND_RED | FOREGROUND_BLUE
    #define FWhite      FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
    
    #define FRedI       FOREGROUND_RED | FOREGROUND_INTENSITY
    #define FGreenI     FOREGROUND_GREEN | FOREGROUND_INTENSITY
    #define FBlueI      FOREGROUND_BLUE | FOREGROUND_INTENSITY
    #define FYellowI    FORGROUND_RED | FORGROUND_GREEN | FOREGROUND_INTENSITY
    #define FCyanI      FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
    #define FMagentaI   FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY
    #define FWhiteI     FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
    
    #define BBlack      0
    #define BRed        BACKGROUND_RED
    #define BGreen      BACKGROUND_GREEN
    #define BBlue       BACKGROUND_BLUE
    #define BYellow     BACKGROUND_RED | BACKGROUND_GREEN
    #define BCyan       BACKGROUND_GREEN | BACKGROUND_BLUE
    #define BMagenta    BACKGROUND_RED | BACKGROUND_BLUE
    #define BWhite      BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
    
    #define BRedI       BACKGROUND_RED | BACKGROUND_INTENSITY
    #define BGreenI     BACKGROUND_GREEN | BACKGROUND_INTENSITY
    #define BBlueI      BACKGROUND_BLUE | BACKGROUND_INTENSITY
    #define BYellowI    BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY
    #define BCyanI      BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY
    #define BMagentaI   BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY
    #define BWhiteI     BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY
    
    // Custom Console Functions: Prototypes
    
    void ClearScreen(HANDLE hOut);
    void ChangeCursor(HANDLE hOut,int iSize, bool bVisable);
    void MoveCursor(HANDLE hOut, COORD Pos);
    void MoveCursor(HANDLE hOut, int iX, int iY);
    void SetColor(HANDLE hOut, int iForeColor, int iBackColor);
    
    using namespace std;
    
    int main()
    {
        HANDLE hIn;
        HANDLE hOut;
    
        COORD MouseWhere  = {19, 0};
        COORD DClickWhere = {19, 1};
        COORD LeftWhere   = {19, 2};
        COORD RightWhere  = {19, 3};
        COORD WheelWhere  = {19, 4};
        COORD LoopWhere   = {0, 5};
        COORD EndWhere    = {0, 6};
    
        bool Continue = TRUE;
        DWORD EventCount;
        int LoopCount = 0;
        int KeyEvents = 0;
        INPUT_RECORD InRec;
        DWORD NumRead;
    
        hIn = GetStdHandle(STD_INPUT_HANDLE);
        hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    
        CONSOLE_SCREEN_BUFFER_INFOEX CSBIE;
        GetConsoleScreenBufferInfoEx(hOut, &CSBIE);
        cout << CSBIE.bFullscreenSupported << flush;
    
        // Not Workint WTF!
        // COORD NewBufferSize;
        // if(SetConsoleDisplayMode(hOut, CONSOLE_FULLSCREEN_MODE, &NewBufferSize));
        // else cout << "Fullscreen failed!" << flush;
    
        while (Continue)
        {
    
            GetNumberOfConsoleInputEvents(hIn, &EventCount);
    
            while (EventCount > 0)
            {
                ReadConsoleInput(hIn, &InRec, 1, &NumRead);
    
                if (InRec.EventType == KEY_EVENT)
                {
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'x')
                    {
    
                                Continue = FALSE;
                    }
                }
                else if (InRec.EventType == MOUSE_EVENT)
                {
                    if (InRec.Event.MouseEvent.dwEventFlags == 0)
                    {
                        if (InRec.Event.MouseEvent.dwButtonState & 0x01)
                        {
                            // Down
                        }
                        else
                        {
                            // Up
                        }
    
                        if (InRec.Event.MouseEvent.dwButtonState & 0x02)
                        {
                            // Down
                        }
                        else
                        {
                            // Up
                        }
                    }
                    else if (InRec.Event.MouseEvent.dwEventFlags == MOUSE_MOVED)
                    {
                        //cout << InRec.Event.MouseEvent.dwMousePosition.X << "," << InRec.Event.MouseEvent.dwMousePosition.Y << "  " << flush;
                    }
                    else if (InRec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK)
                    {
                        //cout << InRec.Event.MouseEvent.dwMousePosition.X << "," << InRec.Event.MouseEvent.dwMousePosition.Y << "  " << flush;
                    }
                    else if (InRec.Event.MouseEvent.dwEventFlags == MOUSE_WHEELED)
                    {
                        // Caution: Non-MSDN documented technique
                        if (InRec.Event.MouseEvent.dwButtonState & 0xFF000000)
                        {
                            // Down
                        }
                        else
                        {
                            // Up
                        }
                    }
                }
    
                GetNumberOfConsoleInputEvents(hIn, &EventCount);
            }
        }
    
        return 0;
    }
    
    // Custom Console Functions: Implementaions
    
    void ClearScreen(HANDLE hOut)
    {
        CONSOLE_SCREEN_BUFFER_INFO SBInfo;
        int ScreenTotal;
        COORD Position;
        DWORD Written;
    
        Position.X = 0;
        Position.Y = 0;
    
        GetConsoleScreenBufferInfo(hOut, &SBInfo);
    
        ScreenTotal = SBInfo.dwSize.X * SBInfo.dwSize.Y;
    
        FillConsoleOutputCharacter(hOut, ' ', ScreenTotal, Position, &Written);
    }
    
    void ChangeCursor(HANDLE hOut, int iSize, bool bVisable)
    {
        CONSOLE_CURSOR_INFO ConCurInf;
    
        ConCurInf.dwSize = iSize;
        ConCurInf.bVisible = bVisable;
    
        SetConsoleCursorInfo(hOut, &ConCurInf);
    }
    
    void MoveCursor(HANDLE hOut, COORD Pos)
    {
        SetConsoleCursorPosition(hOut, Pos);
    }
    void MoveCursor(HANDLE hOut, int iX, int iY)
    {
        COORD Pos;
    
        Pos.X = iX;
        Pos.Y = iY;
    
        SetConsoleCursorPosition(hOut, Pos);
    }
    void SetColor(HANDLE hOut, int iForeColor, int iBackColor)
    {
       SetConsoleTextAttribute(hOut, iForeColor | iBackColor);
    }

  5. #5
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    If the function fails, the return value is zero. To get extended error information, call GetLastError.
    Might be worth a punt. Search winerror.h, use FormatMessage (like this), or look here to see what the number means.

    Just in case, fullscreen here doesn't mean maximized, it means completely takes over the desktop, no taskbar or anything (some people interchange the terms). It also flat out doesn't work on 64-bit Windows, so don't bother if that's what you're running.
    Last edited by adeyblue; 07-14-2011 at 02:45 PM.

  6. #6
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    i have windows 7 and i know how to force the window to be maximized to the maximum size possible given the font and resolution and screen size but by full screen i mean just like hitting alt-enter thats why i said i didnt want to to do it with forcing keys into the input to simulate the alt-enter key press. and what do you mean it might be worth a punt?
    Last edited by codebreather; 07-14-2011 at 03:04 PM. Reason: further reply

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    2,477
    I am searching my Hard drive for "CONSOLE_SCREEN_BUFFER_INFOEX" in file wincon.h.
    Found it in only in w64 builds of MinGW. Edit: I do NOT have all versions of MinGW on my Hard drive; but, I have almost a dozen of them.
    I think they are all based on this 64bit build http://mingw-w64.sourceforge.net/

    I suggest trying TDM 64 Bit MinGW (tdm64-gcc-4.5.2) and see if it works.
    TDM-GCC

    Edit: Just tried tdm64-gcc-4.5.2 and got a different error in a later header file.

    Tim S.
    Last edited by stahta01; 07-14-2011 at 07:04 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 06-09-2009, 02:19 AM
  2. Replies: 2
    Last Post: 02-26-2009, 10:48 PM
  3. Print function: sending a function.. through a function?
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 11-05-2008, 04:03 PM
  4. Replies: 14
    Last Post: 03-02-2008, 12:27 PM
  5. Replies: 9
    Last Post: 01-02-2007, 03:22 PM

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