Fontsize in Console Apps

Jun 26, 2009 at 5:18pm
Hey, is there a way to change the font size in a console application to something like 8x8 px? I've tried SetCurrentConsoleFontEx but this won't work with Windows XP. I've also tried some googled stuff but didn't get it to work. I'm using Windows XP SP3 and CodeBlocks 8.02 with GNU GCC Compiler.
Any help is appreciated.
Jun 26, 2009 at 6:05pm
I'm not sure about coding to change the font size, but I know that if you right click the app, you can change font size and other stuff in there.
Jun 26, 2009 at 7:19pm
There is 1 problem, you can't change the font of the console unless you use the SetCurrentConsoleFontEx().... But as far as i know it works with Windows XP

I think you need to do this before:

1
2
3
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif /*_WIN32_WINNT*/ 


into a header file and include it then build up your font template and use it with the function SetCurrentConsoleFontEx()
Jun 26, 2009 at 8:48pm
Well, I have tried it like this:
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
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif /*_WIN32_WINNT*/

#include <windows.h>

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 testFont;

int main()
{
    HANDLE OutputH;

    OutputH = GetStdHandle(STD_OUTPUT_HANDLE);

    testFont->dwFontSize.X = 10;
    testFont->dwFontSize.Y = 20;

    SetCurrentConsoleFontEx(OutputH, TRUE, testFont);

    return 0;
}

But it doesn't work. I'll get this error when I try to compile:
1
2
3
\Desktop\test.cpp||In function `int main()':|
\Desktop\test.cpp|27|error: `SetCurrentConsoleFontEx' was not declared in this scope|
||=== Build finished: 1 errors, 0 warnings ===|

Altough I have defined "_WIN32_WINNT 0x0500". Could it be my compiler?
Topic archived. No new replies allowed.