Console 工程设置

c++ 控制台

1
2
3
4
5
6
7
SetConsoleOutputCP (65001);
CONSOLE_FONT_INFOEX info = { 0 }; // 以下设置字体来支持中文显示。
info.cbSize = sizeof(info);
info.dwFontSize.Y = 16; // leave X as zero
info.FontWeight = FW_NORMAL;
wcscpy(info.FaceName, L"Consolas");
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, &info);

copy from vlpp

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
namespace UI
{
namespace Console
{
class Console
{
public:
/// <summary>Write to the command line window.</summary>
/// <param name="string">Content to write.</param>
/// <param name="length">Size of the content in wchar_t. The zero terminator is not
/// included.</param>
static void Write(const wchar_t* string, int length);

/// <summary>Write to the command line window.</summary>
/// <param name="string">Content to write.</param>
static void Write(const wchar_t* string);

/// <summary>Write to the command line window.</summary>
/// <param name="string">Content to write.</param>
static void Write(const std::wstring& string);

/// <summary>Write to the command line window with a CRLF.</summary>
/// <param name="string">Content to write.</param>
static void WriteLine(const std::wstring& string);

/// <summary>Read from the command line window.</summary>
/// <returns>The whole line read from the command line window.</returns>
static std::wstring Read();

static void SetColor(bool red, bool green, bool blue, bool light);
static void SetTitle(const std::wstring& string);
};
} // namespace console
} // namespace UI
打赏
  • 版权声明: 本博客所有文章除特别声明外,均采用 Apache License 2.0 许可协议。转载请注明出处!
  • © 2020-2021 一潭清泓
  • Powered by Hexo Theme Ayer
  • PV: UV:

请我喝杯咖啡吧~

支付宝
微信