filipehd
filipehd

Reputation: 930

How to use GUI Windows Application with Console on Visual Studio 2012?

I've been searching arround StackOverflow but seems I can't find the exact explanation for my problem:

I am running a GUI Application compiled under Visual Studio 2012. As it is a GUI application, sometimes it's quite hard to Debug it normally, so I need to printout some values while executing. I've done a couple of printf but the problem is that, as it is a GUI application there is no Console available while debugging it. I need to debug and have a Console to display these output values from printf. I know under CodeBlocks it is possible to do so, however the project is quite big to have to migrate everything to gcc CodeBlocks.

Could anyone tell me how to display such console or how to workaround the problem and have a similar result?

Thank you very much

Upvotes: 0

Views: 1850

Answers (1)

user1773602
user1773602

Reputation:

Windows applicaton can't be both GUI and console.

There is a workaround however:

  • If you applicatop is based on MFC use TRACE macro.
  • Otherwise make your own wrapper around OutputDebugString function.

Both will output to Visual Studio's 'Output' pane when you launch our program under debugger

An of course you can always output diagnostic messages to good old log file.

Upvotes: 2

Related Questions