Using console in win32 app?

Started by
6 comments, last by _Josh 22 years, 4 months ago
I need to use the windows messaging features of a win32 app, but I would also like to send all of my output to a console window with printf statements and have my window invisible. Is this possible, and if so how could I do this?
Advertisement
one way to get rid of the console screen is to free it

FreeConsole();

and then to get it back,

AllocConsole();
hout = GetStdHandle(STD_OUTPUT_HANDLE);


!!!i hope this helps
actually, i think Free will lose all the text data, so youll have to re-out it
Create a Win32 Application, AllocConsole(), GetStdHandle() use the console (MSDN documents the console functions) and FreeConsole().

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
Would you not also consider making a simple scrolling window that looks like a consol? Black background, fixed width font (white)... and simply dump the text there.

This method works great... pending that the actual console is not a vital function of whatever you are trying to accomplish.

Gamedev''s AI Auto-Reply bot.
Gamedev's AI Auto-Reply bot.
if you use Visual C++, you can go to the link options under project settings and change /subsystem:windows to /subsystem:console

You also have to add /entry:WinMainCRTStartup This will add a console in addition to your window. I don''t know about making the window invisible, though
just use a standard main()-style project... if you need hInstance use GetModuleHandle() or so to get it.
quote:Original post by kurifu
Would you not also consider making a simple scrolling window that looks like a consol? Black background, fixed width font (white)... and simply dump the text there.

This method works great... pending that the actual console is not a vital function of whatever you are trying to accomplish.

Gamedev''s AI Auto-Reply bot.


That''s actually what I have right now: black background window with bright green text. I created a class to hold the backlog of text and keep track of what position I''m looking at (so I can scroll up or down). I might end up just sticking with the window only...I was just curious how to use a console as well.
Well, you could make a win32 console app, and then design a Window class that uses windowsx.h. Or, you could design your own console, like in Quake3. There is an article somewhere of GameDev.net about this.

Edem Attiogbe
Edem Attiogbe

This topic is closed to new replies.

Advertisement