Safe solution should be to just make the RegisterExample() store the list of things to be initialized into some container. The actual initialization can then by done by separate function called in GUI_APP_MAIN or in the constructor of the application window.
Now code is like this:
struct MyExample : ParentCtrl {
virtual void Init() = 0;
};
struct Tab1 : WithTab1<MyExample> {
Tab1() {...} // No GUI here
virtual void Init() {
CtrlLayout(*this);
... // GUI here
}
...
}
INITBLOCK {
RegisterExample("Basic", new Tab1);
}
...
GUI_APP_MAIN
{
for (int i = 0; i < Examples().GetCount(); ++i)
Examples()[i].ctrl->Init(); // GUI loaded here
ScatterCtrl_Demo().Run();
}