hide msdos window

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
ExtremeX

hide msdos window

Post by ExtremeX »

ya, i need help, how to hide that msdos windows that opens before the program?
if its not possible how to disable that text that comes displaying the windows info and so? thanks
Guest

Post by Guest »

you're compiling a console-application.
change it to gui-application.
mohaps
Posts: 248
Joined: Tue Jun 08, 2004 1:54 pm
Location: Shrewsbury MA
Contact:

Post by mohaps »

there are two approaches:

a) if you want the window and just want to hide the messages... in your IEventReceiver::OnEvent(SEvent ev)
{
if(ev.EventType is LogEvent)
{
log to file or suppress the message i.e. do not print
return true;
}
}

b) As suggested by earlier poster use a gui win32 application...

in stead of main... use WinMain().
---
Saurav Mohapatra
author, artist and bona fide geek

web: http://www.mohaps.com
email: mohaps AT gmail DOT com
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

Just one problem with the first approach: the irr initialization messages will be still shown... (I can set evet receiver just after creating the irr device that also prints some lines).

I tried another way: redirecting cout, but it doesn't works as irr (0.12.0) logger doesn't use this. (Anyway, if you are intersted in how to redirect cout: http://www.cplusplus.com/ref/iostream/ios/rdbuf.html).
Edit: Also tried to redirect stdout to null. It works, but I don't know how to restore it. And this means no console messages at all. Then why use console window? ;)

Code: Select all

dup2(0,1);
'1' means stdout. Source http://charm.cs.uiuc.edu/users/olawlor/ ... out_pipe.c

It would be great to somehow make irr silent as it is a wasting of CPU time to keep sending log messages that nobody reads :)

Toma
Last edited by WToma on Sat Sep 17, 2005 5:00 pm, edited 1 time in total.
"This is not a bug, this is a feature!"
genesisrage
Posts: 93
Joined: Tue Feb 08, 2005 12:19 pm

Post by genesisrage »

I have found this to be a LOT easier... you still use the main() function to create the program. So no need to include a lot more files such as with using WinMain().

I have personally tested this on Visual Studio .NET 2003 edition, and on the Visual C++ Toolkit (compiled from Code::Blocks)... if you are using DevC++ there is a simple checkbox in the project settings (or somewhere like that). I still use VC Toolkit with Code::Blocks and have never had a problem with it.

Just simply paste this into the top of your main .cpp file and follow the directions :)

Code: Select all

// Un-Comment to remove the console window from build
//#pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
*BTW... this does remove the console window completely, so if your program requires the window (like some of the tutorials), the program will exit immediately.
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

That's it, I would like to print some infos onto the screen while keeping irr in 'silent mode'. It isn't a big problem as I will completely delete the console window in the final version.
Toma
"This is not a bug, this is a feature!"
genesisrage
Posts: 93
Joined: Tue Feb 08, 2005 12:19 pm

Post by genesisrage »

thats exactly what i do Toma. i leave the console up when programming so i can see messages when something doesnt load correctly, but just uncomment that line in a final build :) cuz the console gives some good info when you are debugging, but the end-user doesnt have any need to see that screen.

what im working on right now is trying to find a way that the console window is hidden by default, and only shown when there is a certain command in the command line (i.e. "game.exe" runs without console, and "game.exe -console" will have the console show... just in case)

and if anyone has hints on how to do that it would be a great help :)
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

thats exactly what i do Toma.
... and almost what I want. I would like to print some custom messages, but I don't want to see the Irr messages.
But it is a bigger problem, that in the final version, these messages will be generated and sent to the event receiver however they will not be printed.
So there are good solutions here, but the best was if there were no messages generated at all. This is what I mean by 'silent mode'. This should be set as a parameter in CreateDevice.
Toma
"This is not a bug, this is a feature!"
Post Reply