Overview
Features
Download
Documentation
Community
Add-Ons & Services

MFC and ConsoleChannel

Please post support and help requests here.

MFC and ConsoleChannel

Postby tnarol » 03 Jul 2007, 16:19

Hi,

I'm using a Logger with a ConsoleChannel attached to it. I developped a test console project and everything worked fine. Now I moved my classes to a project using MFC and it no longer works. I could check on the degugger that the log() method of the ConsoleChannel class is called but it produces no output, the console window is not displayed.

Is it possible to have a ConsoleChannel output if my project has a "windows" subsystem ?
Thanks.
tnarol
 
Posts: 22
Joined: 21 Mar 2007, 18:56
Location: France

Re: MFC and ConsoleChannel

Postby guenter » 04 Jul 2007, 09:26

Add the following code to the initialization portion of your application (e.g., InitInstance() or similar):

Code: Select all

   AllocConsole();
   SetConsoleTitle("My Application");
   freopen("CONOUT$", "w", stdout);
   freopen("CONOUT$", "w", stderr);
   freopen("CONIN$", "r", stdin);


The freopen calls make C/C++ standard input/output work with the newly allocated console.

When you no longer need the console, you can also call FreeConsole() to get rid of it, but you don't have to.
guenter
 
Posts: 1130
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: MFC and ConsoleChannel

Postby tnarol » 04 Jul 2007, 10:22

It's working fine. Thanks very much.
tnarol
 
Posts: 22
Joined: 21 Mar 2007, 18:56
Location: France


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron