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 » First time with upp
Re: First time with upp [message #35024 is a reply to message #35023] Thu, 29 December 2011 20:15 Go to previous messageGo to previous message
cb31_fr is currently offline  cb31_fr
Messages: 5
Registered: April 2007
Promising Member
Hi,

Your prova2.h and main.cpp modified.
The addition will be automatically done each time x or y is updated.


prova2.h :

#ifndef _prova2_prova2_h
#define _prova2_prova2_h

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define LAYOUTFILE <prova2/prova2.lay>
#include <CtrlCore/lay.h>



class prova2 : public Withprova2Layout<TopWindow> {
public:
	typedef prova2 CLASSNAME;
	prova2();

private:
	void calcolo();	
};

#endif



And main.cpp :

#include "prova2.h"

prova2::prova2()
{
	CtrlLayout(*this, "Window title");

	// you must add a callback on x or y fields update	
	x <<= THISBACK( calcolo) ;
	y <<= THISBACK( calcolo) ;
}

void prova2::calcolo()
{
	// You do the addition only if x and y are valid
	if( !( x.IsNullInstance() || y.IsNullInstance() ) )
	{
		// Here, you must get the value inserted in your x EditInt field (done with ~x)
		int xValue = ~x ;
	
		// And, you must also get the value inserted in your y EditInt field (done with ~y)
		int yValue = ~y ;
	
		// And now, you must update your somma Label field with the addition.
		// As somma is a Label, we must convert your result into text (done by Format)
		// and then, you update your field by the SetText method.
		somma.SetText( Format( "%d", xValue+yValue ) );
	}
	else
	{
		somma.SetText( "" ) ;
	}

	return ;	
}	

GUI_APP_MAIN
{
	prova2().Run();
}


Have fun with Upp.
Regards
Christian

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Accessing controls in layout within ArrayCtrl
Next Topic: MainMenu problem
Goto Forum:
  


Current Time: Wed May 22 03:36:56 CEST 2024

Total time taken to generate the page: 0.02436 seconds