Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Middle-ground between CONSOLE_APP_MAIN and GUI_APP_MAIN
Re: Middle-ground between CONSOLE_APP_MAIN and GUI_APP_MAIN [message #29651 is a reply to message #29649] Fri, 05 November 2010 18:52 Go to previous messageGo to previous message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Hello cbpporter,

It may not be what you really want... because user may press enter on that console and introduce new commands... but in this way the program reuse the same console from which it was started.

#include <wincon.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>
#include <fstream>

void SetConsole()
{
	if (AttachConsole(-1) != 0) {
		HANDLE cstdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
		*stdout = *(FILE*)_fdopen(_open_osfhandle(intptr_t(cstdout_handle), _O_TEXT), "w");
		setvbuf(stdout, NULL, _IONBF, 0);
		Cout() << "\n";
	}
}


Run it in GUI_APP_MAIN... or embed it in macro. It should work.

Andrei
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ValueArray behaviour / inconsistantcy / BUG?
Next Topic: Slight changes in DHCtrl
Goto Forum:
  


Current Time: Fri Jul 18 06:48:27 CEST 2025

Total time taken to generate the page: 0.02816 seconds