I have been tasked to write a windows program using nothing but the console(no window) and the windows.h header file. I want to change the size of the console and the font at the beginning of the program and have found functions to do so using the MSDN documentation. However, one of the functions, SetCurrentConsoleFontEx(), is supposedly not part of the scope, even though the MSDN documentation said it was included in wincon.h (part of windows.h).
Is there any reason other windows.h functions would work but this one would be missing? Also, is there any other functions I could use that would fulfill the same purpose in case it isn't actually part of windows.h?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <iostream>
#define _WIN32_WINNT 0x0601
#include <windows.h>
using namespace std;
void changeWindowSize();
void changeFontAttributes();
const int MY_WIDTH = 800;
const int MY_HEIGHT = 1000;
const int CHAR_WIDTH = 6;
const int CHAR_HEIGTH = 8;
int main()
{
//Increases the size of console
changeWindowSize();
//Decreases the size of font
changeFontAttributes();
//Wait to terminate program
cin.ignore();
return 0;
}
//Increases the size of console
void changeWindowSize()
{
//Will be used to store where the window is
RECT winSize;
//Gets all of the consoles current attributes
HWND console = GetConsoleWindow();
GetWindowRect(console, &winSize);
MoveWindow(console, winSize.left, winSize.top, MY_WIDTH, MY_HEIGHT, true);
}
//Decreases the size of font
void changeFontAttributes()
{
//Default values
typedef struct _CONSOLE_FONT_INFOEX
{
ULONG cbSize;
DWORD nFont;
COORD dwFontSize;
UINT FontFamily;
UINT FontWeight;
WCHAR FaceName[LF_FACESIZE];
} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
PCONSOLE_FONT_INFOEX consoleFont;
HANDLE toScreen;
toScreen = GetStdHandle(STD_OUTPUT_HANDLE);
//Sets new font sizes
consoleFont->dwFontSize.X = CHAR_WIDTH;
consoleFont->dwFontSize.Y = CHAR_HEIGTH;
SetCurrentConsoleFontEx(toScreen, true, consoleFont);
}
|
All other functions are recognized with current headers, but I get this error message for SetCurrentConsoleFontEx:
H:\changingConsole\main.cpp\ 60 error: 'SetCurrentConsoleFontEx' was not declared in this scope
This function is implemented inside the changeFontAttributes() function at the bottom.
I am aware that the user can change console properties during run-time but I need the program to do it by itself.
Any suggestions are welcome, as I am still very new!