Home » U++ Library support » U++ Core » Middle-ground between CONSOLE_APP_MAIN and GUI_APP_MAIN
Middle-ground between CONSOLE_APP_MAIN and GUI_APP_MAIN [message #29643] |
Fri, 05 November 2010 11:00 |
cbpporter
Messages: 1401 Registered: September 2007
|
Ultimate Contributor |
|
|
I was wondering how could I achieve a middle ground between these two modes, basically a CONSOLE_APP_MAIN that expands to WinMain or alternatively a GUI application with a GUII_APP_MAIN that does not create any windows and does not use CtrlCore. I do not want to have a console window.
How does TheIDE control the option for creating a console app or not based on the absence or presence of the GUI flag.
A week ago I hacked this together and it works fine except for the acquisition of arguments, but I would like to apply a proper solution:
#ifdef PLATFORM_WIN32
void AppInit__(int argc, const char **argv);
void AppInitEnvironment__();
#define CONSOLE_APP_MAIN2 \
void ConsoleMainFn_(); \
\
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int nCmdShow) \
{ \
UPP::AppInitEnvironment__(); \
ConsoleMainFn_(); \
UPP::DeleteUsrLog(); \
UPP::AppExit__(); \
return UPP::GetExitCode(); \
} \
\
void ConsoleMainFn_()
#endif
#ifdef PLATFORM_POSIX
void AppInit__(int argc, const char **argv, const char **envptr);
#define CONSOLE_APP_MAIN2 \
void ConsoleMainFn_(); \
\
int main(int argc, const char **argv, const char **envptr) { \
UPP::AppInit__(argc, argv, envptr); \
ConsoleMainFn_(); \
UPP::DeleteUsrLog(); \
UPP::AppExit__(); \
return UPP::GetExitCode(); \
} \
\
void ConsoleMainFn_()
#endif
Ideally, is there a way to have you application not open o console, but when it is opened from a console it still writes to it. If I compile it with GUI, i get no output, even if opened from cmd. If I compile it without, I get the output, but when opening it from the shell I get a new console window.
|
|
|
Re: Middle-ground between CONSOLE_APP_MAIN and GUI_APP_MAIN [message #29647 is a reply to message #29643] |
Fri, 05 November 2010 13:04 |
|
cbpporter wrote on Fri, 05 November 2010 11:00 | Ideally, is there a way to have you application not open o console, but when it is opened from a console it still writes to it.
|
Hi cbporter,
This is the default behavior for GUI apps on Linux. On windows it is more problematic... Theide uses a wrapper (umk) for command line invocation, as you probably know. My knowledge of windows is very limited, but this article seems to explain the topic quite good and also provides solutions. If you can apply it on U++, it would be IMHO valuable addition.
Honza
|
|
|
Re: Middle-ground between CONSOLE_APP_MAIN and GUI_APP_MAIN [message #29649 is a reply to message #29647] |
Fri, 05 November 2010 13:28 |
cbpporter
Messages: 1401 Registered: September 2007
|
Ultimate Contributor |
|
|
Thank you for the help. I've tried the solution there, but it opens a new console window, even if I already have one. And indeed, I am trying to emulate the Linux behavior without realizing it.
I have one of the following situations:
1. I compile without GUI flag. Application uses existing console or opens new one. Irrlicht debug messages appear. So do my own console outputs.
This situation is not acceptable, because I don't want windows to create a console.
2. I compile with GUI flag. No console appears and output is not visible.
Here there are two issues.
First, it would be nice if we could pick up the existence of a console and use it to output. This is a convenience feature, so I don't need it but it is useful. Linux model.
Second, I need to include CtrlLib only for GUI_APP_MAIN. That is why I am using a CONSOLE_APP_MAIN2 that uses WinMain instead of main. This is why I would like to add something like CONSOLE_WIN_MAIN that is just CONSOLE_APP_MAIN under Linux, and uses WinMain under Windows.
3. I use the example from your link and I have one or two consoles, where the extra one pick up only my outputs, but not Irrlicht debug messages. I guess it uses a different handle and default console has them all set to the same.
|
|
|
|
|
Re: Middle-ground between CONSOLE_APP_MAIN and GUI_APP_MAIN [message #29691 is a reply to message #29652] |
Mon, 08 November 2010 15:10 |
cbpporter
Messages: 1401 Registered: September 2007
|
Ultimate Contributor |
|
|
Thanks for the help. This also does not work like I want it. No use bothering with it though.
So any chance on getting the WinMain CONSOLE_APP_MAIN included into Core as an alternative with a different name? If yes, I'll add parameter recognition like with GUI_APP_MAIN. If not, I'm fine with only adding the macro to my code.
|
|
|
Goto Forum:
Current Time: Thu Apr 25 12:33:49 CEST 2024
Total time taken to generate the page: 0.01437 seconds
|