Urgent Question: Hiding Status Window

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Urgent Question: Hiding Status Window

Post by mark01 »

seems like I can't find a solution to this simple task. I want to hide the status window which displays the texture loading and other details during the whole loading process.

I searched the whole forum but didn't find a answer to this.
how is this possible?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Do you mean the console window which you see on windows?

The trick to hide that is to use another entrypoint into the application. Instead of working with main() you must work with WinMain.

I do it somewhat like this:

Code: Select all

#ifdef WIN32

#include <windows.h>
int main(int argc, char *argv[]);  // forward declaration

// entry point for windows gui applications
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
        // we don't really use it, so just call the usual main
	return main(__argc, __argv);
}

// not sure right now, why I used that here. Maybe not necessary.
#pragma warning( disable : 4786 ) 

#endif	// WIN32

// here comes the usual main, which you can use as hithero
int main(int argc, char *argv[])
{
return 0;
}
Now it's hidden whenever you compile with WIN32 (which you either set as define or in the preprocessor definitions section in VS).

But you certainly also no longer see the error messages and all the informations send to stdout and stderr.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Bob Finnie
Posts: 49
Joined: Tue Jan 23, 2007 12:36 pm
Location: Bedford, UK

Post by Bob Finnie »

or if you want to still want to work with main() and you are using Visual Studio you can add this near the top of your code:

Code: Select all

#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Certainly in devcpp there's options in the project settings to hide the console. Though i think that's just by changing the project type to GUI from console.
Image Image Image
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

I'm always using this way:

Code: Select all

#ifdef _WIN32 
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine,  int nCmdShow) 
#else 
int main() 
#endif 
{ 
...
Then I just set the release build's subsystem to 'windows' (similar to bob's snippet).

This way I've got the console in debug mode and a clean window/appearance in my release build.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

@Ico: That's nearly the same as I did in my code. It certainly also works, but you have different command line parameters as the WinMain parameters have another format than main. I use those parameters so I prefered having them the same format, to avoid writing two parsers :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Incidentally, you can set the subsystem with a pragma, so you can switch it entirely within the source based on the state of NDEBUG.

Code: Select all

#pragma comment(linker,"/subsystem:console")

#pragma comment(linker,"/subsystem:windows")
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

rogerborg wrote:Incidentally, you can set the subsystem with a pragma, so you can switch it entirely within the source based on the state of NDEBUG.

Code: Select all

#pragma comment(linker,"/subsystem:console")

#pragma comment(linker,"/subsystem:windows")
You mean if I add both of these lines before main() I'll see the console only on debug build?
If not could you show an example of how to use it cause it sounds the most simple way of all that was said above.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

for debug console add :

#pragma comment(linker,"/subsystem:console")

if you dont want one add :

#pragma comment(linker,"/subsystem:windows")




it tells the compiler what to use main as, so yea.
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

MasterGod wrote:
rogerborg wrote:Incidentally, you can set the subsystem with a pragma, so you can switch it entirely within the source based on the state of NDEBUG.

Code: Select all

#pragma comment(linker,"/subsystem:console")

#pragma comment(linker,"/subsystem:windows")
You mean if I add both of these lines before main() I'll see the console only on debug build?
If not could you show an example of how to use it cause it sounds the most simple way of all that was said above.

Code: Select all

#ifdef _DEBUG
#pragma comment(linker,"/subsystem:console")
#else
#pragma comment(linker,"/subsystem:windows")
#endif
(You could also replace the define and use NDEBUG, RELEASE or whatever is defined only in debug or release build.)
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

It asks for WinMain..
error LNK2001: unresolved external symbol _WinMain@16
I fixed it by changing this line

Code: Select all

#pragma comment(linker,"/subsystem:windows")
with this

Code: Select all

#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I tend to use NDEBUG (to indicate a release build) as it's specified in the ANSI standard for <assert.h>, but whatever works for you. ;)

Code: Select all

#include <stdio.h>
#include <windows.h>

// To see this working, ensure that you pass some command line arguments.

int main(int argc, char * argv[])
{
	// Just show the command line arguments
	char arguments[1024] = {0};

	for(int arg = 0; arg < argc; ++arg)
	{
		(void)strcat_s(arguments, sizeof(arguments), argv[arg]);
		(void)strcat_s(arguments, sizeof(arguments), "\n");

		(void)printf("%s\n", argv[arg]); // This will only appear on the debug console
	}

	(void)MessageBoxA(NULL, arguments, "Arguments", MB_OK);

	return 0;
}

#if defined(NDEBUG)
// In a release build, use the Windows subsystem so that we don't get a console
// and call through to the common main() from WinMain
#pragma comment(linker, "/subsystem:windows")

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
{
	// Unfortunately there's no CommandLineToArgvA() so I'll extract the args manually.
	char * nextToken;
	char * token = strtok_s(GetCommandLineA(), " ", &nextToken);
	int argc = 0;
	char * argv[256]; // If there's more than 256 arguments, expect mayhem.

	while(token)
	{
		argv[argc++] = token;
		token = strtok_s(NULL, " ", &nextToken);
	}

	return main(argc, argv);
}
#else // NDEBUG
#pragma comment(linker, "/subsystem:console")
// And main() will be used implicitly
#endif // NDEBUG
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

thanks very much :)
After half a year of work I finally finished my highschool project

some Impressions:

Image

Image

Image


Presentation will be next week
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

Looks interesting, but I'd try to change that blank wall in the second pic - even some light greyish texture might look better imo. Maybe it's the pic but it looks like unfinished/a bug.
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

I know, this is an error. I had some texture on it but somehow it isnt possible to display the texture like it should be. Ill see what I can do until next week
Post Reply