问题描述
我用C ++开发了一个控制台应用程序,该应用程序只能在Windows上运行.我想在程序运行时更改命令提示符的文本大小.我进行了一些搜索,但是找不到任何可以解决该问题的方法.每个人都在谈论改变颜色.
I developed a console application in C++ that will run only on Windows. I want to change Command Prompt's text size when the program runs. I did some search but, I could not find anything that would solve the problem. Everybody is just talking about changing the color.
无论如何,如果可能的话,如何更改命令提示符的文本大小.
Anyway, if this is possible, how can I change the text size of Command Prompt.
谢谢!
推荐答案
在获取当前字体信息之前,必须使用sizeof(CONSOLE_FONT_INFOEX)初始化CONSOLE_FONT_INFOEX结构.
另外,您必须仅使用可用尺寸:
You have to initialize CONSOLE_FONT_INFOEX structure with sizeof(CONSOLE_FONT_INFOEX) before getting current font info.
Also you have to use only available sizes:
- 4 x 6
- 16 x 8
- 6 x 9
- 8 x 9
- 5 x 12
- 7 x 12
- 8 x 12
- 16 x 12
- 12 x 16
- 10 x 18
BOOL SetConsoleFontSize(COORD dwFontSize){
HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX info{sizeof(CONSOLE_FONT_INFOEX)};
if (!GetCurrentConsoleFontEx(output, false, &info))
return false;
info.dwFontSize = dwFontSize;
return SetCurrentConsoleFontEx(output, false, &info);
}
这篇关于更改命令提示符文本大小C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!