#pragma once
#include <windows.h>
#include <stdio.h>
#include <iostream>
class CConsoleDebug
{
public:
CConsoleDebug(SHORT nWidth = 30, SHORT nHeight = 3000): m_pFile(NULL)
{
#ifdef _DEBUG
AllocConsole();
freopen_s(&m_pFile, "CONOUT$", "w", stdout);
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
COORD size;
size.X = nWidth;
size.Y = nHeight;
::SetConsoleScreenBufferSize(hCon, size);
std::ios_base::sync_with_stdio();
#endif
}
virtual ~CConsoleDebug()
{
#ifdef _DEBUG
fclose(m_pFile);
m_pFile = NULL;
FreeConsole();
#endif
}
private:
FILE* m_pFile;
};
GUI程序控制臺輸出調試信息
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.