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 » Switch control on the main window
Switch control on the main window [message #46235] Thu, 31 March 2016 11:25 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I have this switch control on the main window. There is a procedure that fills in the switch with some options, taking them from a database. The problem with this procedure is that it works fine if I launch it after the main window is executed i.e. after the MyApp().Run(); instruction in the GUI_APP_MAIN. If I run the procedure before the .Run(), it fails, without any message: the main window is launched, but the switch control is empty. I could try to trigger the execution of that procedure after the main window is running (e.g. with a button), but is there a more straightforward method to do that?
Thanks,
Gio
Re: Switch control on the main window [message #46238 is a reply to message #46235] Thu, 31 March 2016 19:36 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Use Switch's SetData( indexOfItemToBeSelected) to do that, here is a small example:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyApp: public TopWindow
{
	MyApp()
	{
		s.SetLabel("Label\nArray\nButton\nSwitch");
		Add(s.SizePos());
		

                s.SetData(3);  //<----------- 
	}
	
	Switch s;
};


GUI_APP_MAIN
{
	MyApp().Run();
}
Re: Switch control on the main window [message #46242 is a reply to message #46238] Fri, 01 April 2016 09:51 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Thanks, you gave me the right hint: I had just to move the procedure that fills in the switch from the GUI_APP_MAIN to the constructor.
Previous Topic: Selecting MYAPPS after starting theide.exe it is blank
Next Topic: How to set the font controls?
Goto Forum:
  


Current Time: Fri Mar 29 15:52:59 CET 2024

Total time taken to generate the page: 0.00961 seconds