Task #1901

Updated by Zbigniew Rebacz almost 2 years ago

GUI_APP_MAIN_HOOK is now part of public CtrlCore API and it looks bad and generates warning "GUI_APP_MAIN_HOOK" redefined when used as designed.

In my opinion GUI_APP_MAIN_HOOK problem should be solved in following way:
<pre><code class="cpp">
// Solution
std::function<bool()> AfterAppInitHandler = {};

#define GUI_APP_MAIN \
void GuiMainFn_(); \
\
int main(int argc, char *argv, const char *envptr) { \
UPP::AppInit__(argc, (const char **)argv, envptr); \
if(AfterAppInitHandler && AfterAppInitHandler()) \
return UPP::GetExitCode(); \
...

// Usage:
INITBLOCK {
AfterAppInitHandler = []() -> bool {
// Do whatever you need here (handle command line etc.)...

return false;
};
}
</code></pre>

Clean and elegant solution compatible with c++11 and above that can be used in 3-rd party code with convenience. above.

Back