Can lib calls using cout/iostream be redirected to MFC GUI console?

Can lib calls using cout/iostream be redirected to MFC GUI console?

Post by Todd Jelle » Fri, 25 Apr 1997 04:00:00



Can lib calls using cout/iostream be redirected to MFC GUI console?
Is this possible?

I have a portable library which works on Unix and in Win95/NT console
apps. This library uses cout/iostream to send diagnostic output to
stdout/stderr (using cout and cerr). Can this diagnostic info be
redirected to an MFC GUI console. I can create the console window but
nothing gets written to it. Can this be done?

If an MFC console application can redirect this output to it's console
window why can't it be redirected to the console window of an MFC GUI
application?? What am I doing wrong?

I posted this same query a week ago in somewhat more detail and didn't
get 1 reply! C'mon experts! Can it be done or not?

Any help would be greatly appreciated
Thanks
Todd
--
**********************************************************************
Todd Jellett                                Phone : (506) 453-4530        
Manager GIS Laboratory                      Fax   : (506) 453-5055          
Dept. of Geology                                                            

Fredericton, N.B.
Canada  E3B 5A3
**********************************************************************

 
 
 

Can lib calls using cout/iostream be redirected to MFC GUI console?

Post by Ronald M. Marti » Mon, 28 Apr 1997 04:00:00


Todd,

You can write a Windows app which runs your console app with its i/o
redirected through pipes and have the Windows app implement the
translation from pipes to the application window.  You could make this
rather general purpose so that it would work with any console
application.  It seems as if someone would sell such an application.
Perhaps there is an example program in VC++ or the SDK which does this.

Ron Martin
Ann Arbor, MI


> Can lib calls using cout/iostream be redirected to MFC GUI console?
> Is this possible?

> I have a portable library which works on Unix and in Win95/NT console
> apps. This library uses cout/iostream to send diagnostic output to
> stdout/stderr (using cout and cerr). Can this diagnostic info be
> redirected to an MFC GUI console. I can create the console window but
> nothing gets written to it. Can this be done?

> If an MFC console application can redirect this output to it's console
> window why can't it be redirected to the console window of an MFC GUI
> application?? What am I doing wrong?

> I posted this same query a week ago in somewhat more detail and didn't
> get 1 reply! C'mon experts! Can it be done or not?

> Any help would be greatly appreciated
> Thanks
> Todd
> --
> **********************************************************************
> Todd Jellett                                Phone : (506) 453-4530
> Manager GIS Laboratory                      Fax   : (506) 453-5055
> Dept. of Geology

> Fredericton, N.B.
> Canada  E3B 5A3
> **********************************************************************


 
 
 

1. Killing a console window created using AllocConsole() in an MFC GUI app

Hello all,

There have been numerous postings about how to use printf() and cout
in the context of a GUI application.  I have done such a thing in my
application, but I seem to have run into a stumbling block.  I have a
menu item that hides or shows my "log" window, which is nothing more
than a console created via AllocConsole().  Now what happens is if the
user closes the console window by clicking on the "x marks the spot
close area" up there in the upper right-hand corner my entire
application exits!  I would prefer to prevent this from occurring,
either one of two ways:

(a) Is there some Windows configuration that prevents the
minimize/maximize/close title-bar areas from appearing in console
windows?  Barring that, is there something in AllocConsole() or the
related console API that will prevent these from appearing?  Is there
a windows hook method I could use?

(b) Is there a way to catch the close event occurring, and then
perhaps re-AllocConsole() a new console?

To provide some more context, my MFC app spins off a little thread
that calls AllocConsole.  In this thread I use the FindWindow() Win32
function to grab and store an HWND, which I subsequently use to
hide/show the window depending on GUI menu callbacks.  My thread proc
is quite simple :

while (m_bRunning)

  WriteFile(hConOut, ...);

FreeConsole();

Of course, I've tried setting a breakpoint in a destructor, which sets
m_bRunning to FALSE, and then closed my console window.  The entire
application still terminates and the debugger never hits the
breakpoint.

Any help/advice would be most appreciated.  I really don't want to
slap together a GUI entity that shuttles STDOUT and STDERR onto a rich
text-edit control.

-Shehrzad

2. dual boot?

3. Console style app using MFC and Windows GUI

4. wireless LAN

5. MFC and DOS apps - Redirecting console output to an MFC app (Newbie)

6. TCP/IP -- Windows 95 -- Null Modem Cable -- HELP!!!!!!

7. console / cout and MFC?

8. Application does not work on PPC

9. Redirecting a console app's stdout to a GUI parent process

10. Can create but can't write to MFC GUI console

11. WOWTO: console stdout/printf and GUI-based MFC application

12. Help with iostream lib on Win CE.NET

13. Rebuild MFC with VC6 SP5 and Nov. 2001 Platform SDK (static lib nafxcw*.lib)?