U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » Init a ctrl inside INITBLOCK
Re: Init a ctrl inside INITBLOCK [message #35108 is a reply to message #35107] Thu, 12 January 2012 15:50 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3460
Registered: August 2008
Senior Veteran
Hello Honza

I have successfully applied this:
Quote:

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();
}


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Date& operator++
Next Topic: random functions proposal
Goto Forum:
  


Current Time: Sat Jun 13 17:47:25 GMT+2 2026

Total time taken to generate the page: 0.00446 seconds