Created
October 2, 2016 11:57
-
-
Save ydakoukn/1880918f8b91c59d9dae4c4313b696e9 to your computer and use it in GitHub Desktop.
Consoleウィンドウ表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <Windows.h> | |
#include <io.h> | |
#include <fcntl.h> | |
#include "ConsoleWindow.h" | |
int ConsoleWindow::m_hConsole = 0; | |
ConsoleWindow::ConsoleWindow(){ | |
m_hConsole = 0; | |
} | |
ConsoleWindow::ConsoleWindow(ConsoleWindow& other){ | |
} | |
ConsoleWindow::~ConsoleWindow(){ | |
this->Close(); | |
m_hConsole = 0; | |
} | |
void ConsoleWindow::Create(){ | |
::AllocConsole(); | |
m_hConsole = ::_open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); | |
*stdout = *::_fdopen(m_hConsole, "w"); | |
setvbuf(stdout, NULL, _IONBF, 0); | |
return; | |
} | |
void ConsoleWindow::Close(){ | |
if (m_hConsole) | |
{ | |
::_close(m_hConsole); | |
} | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _CONSOLEWINDOW_H | |
#define _CONSOLEWINDOW_H | |
class ConsoleWindow | |
{ | |
public: | |
ConsoleWindow(); | |
ConsoleWindow(ConsoleWindow&); | |
~ConsoleWindow(); | |
static void Create(); | |
static void Close(); | |
private: | |
static int m_hConsole; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment