1. Killing a console window created using AllocConsole() in an MFC GUI app
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 :
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
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
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)?