Page 1 of 1

hide msdos window

Posted: Sun Jul 24, 2005 10:58 pm
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

Posted: Fri Aug 12, 2005 4:47 pm
by Guest
you're compiling a console-application.
change it to gui-application.

Posted: Fri Aug 12, 2005 5:17 pm
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().

Posted: Sat Sep 17, 2005 4:28 pm
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

Posted: Sat Sep 17, 2005 4:58 pm
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.

Posted: Sat Sep 17, 2005 5:08 pm
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

Posted: Sun Sep 18, 2005 2:09 am
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 :)

Posted: Sun Sep 18, 2005 9:44 am
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