Add code to open a console on Win32. Hallelujah.
authorCarl Hetherington <cth@carlh.net>
Tue, 26 Nov 2013 09:40:01 +0000 (09:40 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 26 Nov 2013 09:40:01 +0000 (09:40 +0000)
src/tools/dcpomatic.cc

index 5d21579223647f04d68170a89bfe5246d7c23b75..420d828b0730635f4c6a36ac9110f9a09e88cb00 100644 (file)
@@ -246,6 +246,22 @@ public:
                : wxFrame (NULL, -1, title)
                , _servers_list_dialog (0)
        {
+#ifdef DCPOMATIC_WINDOWS_CONSOLE               
+                AllocConsole();
+               
+               HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
+               int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
+               FILE* hf_out = _fdopen(hCrt, "w");
+               setvbuf(hf_out, NULL, _IONBF, 1);
+               *stdout = *hf_out;
+               
+               HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
+               hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
+               FILE* hf_in = _fdopen(hCrt, "r");
+               setvbuf(hf_in, NULL, _IONBF, 128);
+               *stdin = *hf_in;
+#endif
+
                wxMenuBar* bar = new wxMenuBar;
                setup_menu (bar);
                SetMenuBar (bar);