Urgent Question: Hiding Status Window
Urgent Question: Hiding Status Window
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?
I searched the whole forum but didn't find a answer to this.
how is this possible?
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:
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.
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;
}
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 49
- Joined: Tue Jan 23, 2007 12:36 pm
- Location: Bedford, UK
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")
I'm always using this way:
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.
Code: Select all
#ifdef _WIN32
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
#else
int main()
#endif
{
...
This way I've got the console in debug mode and a clean window/appearance in my release build.
@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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
You mean if I add both of these lines before main() I'll see the console only on debug build?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")
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.
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact:
MasterGod wrote:You mean if I add both of these lines before main() I'll see the console only on debug build?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")
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
It asks for WinMain..
with this
I fixed it by changing this lineerror LNK2001: unresolved external symbol _WinMain@16
Code: Select all
#pragma comment(linker,"/subsystem:windows")
Code: Select all
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way