soulik icon

I love C++ - students

soulik | PRO | 06/30/16 12:05:26 PM UTC | 0 ⭐ | 10329 👁️ | Never ⏰ | []
C++ (WinAPI) |

0 B

|

None

|

0 👍

/

0 👎

#include <windows.h>
#include <string.h>
 
bool setConsoleFontSize(HANDLE console, COORD dwFontSize){
    CONSOLE_FONT_INFOEX info{ sizeof(CONSOLE_FONT_INFOEX) };
    if (!GetCurrentConsoleFontEx(console, false, &info))
        return false;
    info.dwFontSize = dwFontSize;
    return SetCurrentConsoleFontEx(console, false, &info);
}
 
void getConsoleSize(HANDLE console, short & width, short & height){
    CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
 
    GetConsoleScreenBufferInfo(console, &bufferInfo);
    width = bufferInfo.srWindow.Right;
    height = bufferInfo.srWindow.Bottom;
}
 
void niceText(const char * text, unsigned short baseColor = 0x07, unsigned short specialColor = 0x07){
    // ...
 
    HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
    setConsoleFontSize(console, {12, 16});
 
    short width, height;
    getConsoleSize(console, width, height);
 
    COORD centeredPosition = {width/2 - length/2, height/2};
    COORD position = { centeredPosition.X, centeredPosition.Y };
 
    unsigned long charactersWritten = 0;
 
    // ...
}
 
int main(int argc, char ** argv, char ** env){
    niceText("I \03 C++", 0x07, 0x04);
    return 0;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎