Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Problem in example code (Tried SplitterFrame yet minor problem.)
Re: Problem in example code [message #45780 is a reply to message #45773] Sun, 03 January 2016 21:08 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

vegaonline wrote on Sun, 03 January 2016 14:41

However, I may reach Plot menu from any other menu item having separate layout except card menu. Should I use ".Remove() for all other different layout or there is any single Remove command to remove all other layout which may be present there?

There are ways to access the all the children of given Ctrls and to iterate through them. See GetFirstChild(), GetNext(), GetChildIndex(), GetIndexChild(), GetChildCount() and related functions in Ctrl documentation. In your particular case it would probably be ok just to call GetLasChild()->Remove(). But I never actually needed to use such a low level approach in my apps and it feels kind of error prone to me.

There is actually much simpler way: You can just remember your last state Smile For example, you can add Ctrl* active to your class (don't forget to initialize it to NULL in constructor, otherwise you'll get crashes Wink ), and then use a method like this for the switching:
void Testing::SetLayout(Ctrl* ctrl) {
	if (active)
		active->Remove();
	Add(*ctrl);
	active = ctrl;
}
Your menu code could then be as simple as this:
		menu.Add("Configure", THISBACK1(SetLayout, &doCard)).Help("Edit Simulation Setup");
		menu.Add("Geometry", THISBACK1(SetLayout, &doPlot)).Help("Edit Experimental Geometry");
That is of course assuming there is no special initialization for each layout needed on each switch, in which case you would have to still call doConfig() and doGeom() from menu and they would in turn call the common switching code in SetLayout.

Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Issues using 2015.2 version
Next Topic: How to build FREBSD *.so in Windows?
Goto Forum:
  


Current Time: Thu May 09 14:58:51 CEST 2024

Total time taken to generate the page: 0.01753 seconds