User forums > Using Code::Blocks
Print dialog in Debug build
(1/1)
rlb:
I use the PrintDlg() common dialog in my program (I know, I should use PrintDlgEx, but that doesn't compile at all and that's another subject which may be a MinGW problem), and the Release build works fine. The Debug build, though, does not. It refuses to link, says that PrintDlgA is undefined.
Now, I think I know what the problem is: that function is only defined for full GUI applications, not for console applications, not even ones which immediately fire up the GUI portion of the program. Fair enough, and not a Code::Blocks problem. However, I really would like my Debug build to fire up a console so I can use printf() for quick debugging messages, I find that a much more efficient way to see what goes wrong than going through GDB every time.
My questions are this:
- Am I right in my suspicion about the cause of the problem?
- Is there a way to kick Windows so that it allows a console application to use _all_ Common Dialogs including PrintDlg()?
and the Code::Blocks proper part of the question:
- If not, is there an option I can set to convince Code::Blocks, or to get it to convince MinGW, to give me a console window after all within my GUI application? There's a lot of options...
(Standard C::B installation, by the way - 16.01, MinGW 4.9, no other implementations installed; Win7 Pro, if that matters.)
oBFusCATed:
Yes, it is possible to have a console in a GUI app, but you have to show it manually with code.
Search for AllocConsole or AttachConsole or something similar, don't remember the exact call.
rlb:
Right... but then I'd have to do that only in the debug build. I gather Code::Blocks doesn't #define DEBUG automatically, but I can set that in the build options. However, when I try that, it does show a console window... but it doesn't show stdio output. Drat. I'll have to investigate further.
At first I thought typicalc's solution in the Help forum ("console for raspberry") would help, but that has the same problem. I can set that option - I didn't know it was there, but it was, under Windows as well - and it does start a console, but it doesn't seem to receive stdio output.
oBFusCATed:
--- Quote from: rlb on September 02, 2016, 10:10:27 am ---I gather Code::Blocks doesn't #define DEBUG automatically, but I can set that in the build options. However, when I try that, it does show a console window...
--- End quote ---
This is up to you. Code::Blocks is just the UI you're using to setup and build your project.
--- Quote from: rlb on September 02, 2016, 10:10:27 am ---but it doesn't show stdio output. Drat. I'll have to investigate further.
--- End quote ---
You have to redirect some handles to the new console. There are plenty of examples in the net. Just search for them.
rlb:
--- Quote from: oBFusCATed on September 02, 2016, 11:53:58 pm ---
--- Quote from: rlb on September 02, 2016, 10:10:27 am ---I gather Code::Blocks doesn't #define DEBUG automatically, but I can set that in the build options. However, when I try that, it does show a console window...
--- End quote ---
This is up to you. Code::Blocks is just the UI you're using to setup and build your project.
--- End quote ---
Certainly. But as CB does create a Release and Debug build automatically, I wouldn't have been surprised if it did. No big deal.
--- Quote from: oBFusCATed on September 02, 2016, 11:53:58 pm ---
--- Quote from: rlb on September 02, 2016, 10:10:27 am ---but it doesn't show stdio output. Drat. I'll have to investigate further.
--- End quote ---
You have to redirect some handles to the new console. There are plenty of examples in the net. Just search for them.
--- End quote ---
That's precisely what I meant by "investigate further", yes.
FTR, adding freopen("CONOUT$", "w", stdout); after AllocConsole(); did it for me. Not at all sure if this is a universal solution, but it's enough for what I want from it.
Navigation
[0] Message Index
Go to full version