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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Newbie Problems with the menu example...
Newbie Problems with the menu example... [message #3515] Tue, 30 May 2006 19:12 Go to next message
_Seven_ is currently offline  _Seven_
Messages: 35
Registered: April 2006
Member
Hi everyone. I am trying follow an example posted on site of U++ and i tried to create the same program but it's not work. I don't know where is the problem. Can you help me? Where i am wrong?
The code:
#include <CtrlLib/CtrlLib.h>

struct App : public TopWindow{
	bool list_numbers;
	
	void Exit(){
		Close();
	}
	void List_Numbers(){
		list_numbers=!list_numbers;
	}
	void show(int i){
		PromptOK(AsString(i));
	}
	void draw(Bar& bar){
		for(int i=0;i<10;i++)
			bar.Add(AsString(i), THISBACK(show,i));
	}
	void Opcoes(Bar& bar){
		bar.Add("Mostrar numeros", THISBACK(List_Numbers));
		bar.Add("Lista :", THISBACK(draw));
		bar.Add("Sair", THISBACK(Exit)).Key(CTRL_Q);
	}
	void MenuBar(Bar& bar){
		bar.Add("Opcoes",THISBACK(Opcoes));
	}
		
	MainBar Opcoes;
	typedef App CLASSNAME;
	
	App(){
        numbers_enabled = true;
        AddFrame(Opcoes);
        menu.Set(THISBACK(MainBar));
    }
};

GUI_APP_MAIN
{
	App.Run();
}


[Updated on: Wed, 31 May 2006 16:47] by Moderator

Report message to a moderator

Re: Problems with the code [message #3516 is a reply to message #3515] Tue, 30 May 2006 19:47 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1189
Registered: March 2006
Location: Italy
Senior Contributor
_Seven_ wrote on Tue, 30 May 2006 19:12

Hi everyone. I am trying follow an example posted on site of U++ and i tried to create the same program but it's not work. I don't know where is the problem. Can you help me? Where i am wrong?
The code:
#include <CtrlLib/CtrlLib.h>

struct App : public TopWindow{
	bool list_numbers;
	
	void Exit(){
		Close();
	}
	void List_Numbers(){
		list_numbers=!list_numbers;
	}
	void show(int i){
		PromptOK(AsString(i));
	}
	void draw(Bar& bar){
		for(int i=0;i<10;i++)
			bar.Add(AsString(i), THISBACK(show,i));
	}
	void Opcoes(Bar& bar){
		bar.Add("Mostrar numeros", THISBACK(List_Numbers));
		bar.Add("Lista :", THISBACK(draw));
		bar.Add("Sair", THISBACK(Exit)).Key(CTRL_Q);
	}
	void MenuBar(Bar& bar){
		bar.Add("Opcoes",THISBACK(Opcoes));
	}
		
	MainBar Opcoes;
	typedef App CLASSNAME;
	
	App(){
        numbers_enabled = true;
        AddFrame(Opcoes);
        menu.Set(THISBACK(MainBar));
    }
};

GUI_APP_MAIN
{
	App.Run();
}





Hello Seven,

to help us (at least me) to help you please add some other information. For example let me know which was the original example you are referring to. In your code I see several mistakes. For example:

	bar.Add(AsString(i), THISBACK(show,i));

should be
	bar.Add(AsString(i), THISBACK1(show,i));

Please note the '1' as you are passing "one" parameter to show() method. There are other problems but first address me to the original example in this forum.

Luigi

PS: I guess our administrator will move this post in another forum, perhaps here:
http://www.arilect.com/upp/forum/index.php?t=thread&frm_ id=21& It is very important to post in the right place to speed up the answer and even to help new user to find what they need in few clicks. To have an idea about the topics treated in each forum try to have a look at them. I started in this manner and after some mistakes I learned where to post correctly, at least most of the time Smile .

[Updated on: Tue, 30 May 2006 19:48]

Report message to a moderator

Re: Problems with the code [message #3520 is a reply to message #3516] Wed, 31 May 2006 07:19 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1189
Registered: March 2006
Location: Italy
Senior Contributor
This work:
#include <CtrlLib/CtrlLib.h>

struct App : public TopWindow {
	bool    list_numbers;
	
	void Exit(){
		Close();
	}
	void List_Numbers(){
		list_numbers=!list_numbers;
	}
	void show(int i){
		PromptOK(AsString(i));
	}
	void draw(Bar& bar){
		for(int i=0;i<10;i++)
			bar.Add(AsString(i), THISBACK1(show,i));
	}
	void Opcoes(Bar& bar){
		bar.Add("Mostrar numeros", THISBACK(List_Numbers));
		bar.Add("Lista :", THISBACK(draw));
		bar.Add("Sair", THISBACK(Exit)).Key(K_CTRL_Q);
	}
	void MainBar(Bar& bar){
		bar.Add("Opcoes",THISBACK(Opcoes));
	}
		
	MenuBar opcoes;
	typedef App CLASSNAME;
	
	App(){
        list_numbers = true;
        AddFrame(opcoes);
        opcoes.Set(THISBACK(MainBar));
    }
};

GUI_APP_MAIN
{
	App().Run();
}


You mixed up the old code with the new one. Moreover there were some mistakes due to variable with capital letter. Compare it with your previous code to see the difference and understand the errors.
Luigi
Re: Problems with the code [message #3523 is a reply to message #3516] Wed, 31 May 2006 09:07 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
forlano wrote on Tue, 30 May 2006 18:47



PS: I guess our administrator will move this post in another forum, perhaps here:
http://www.arilect.com/upp/forum/index.php?t=thread&frm_ id=21& It is very important to post in the right place to speed up the answer and even to help new user to find what they need in few clicks. To have an idea about the topics treated in each forum try to have a look at them. I started in this manner and after some mistakes I learned where to post correctly, at least most of the time Smile .



Thanks, Luigi, for your help.

Seven,
1. when posting, please, try hard to make your topic name unique. Think, if all topics are named "Problems with code"... or "Help".
2. Also, in cases like yours (when code doesn't compile), post the first few lines of compiler output. Compiler messages should be helpful to name your topic and ... find the "problems with the code"... Smile
Re: Problems with the code [message #3534 is a reply to message #3515] Wed, 31 May 2006 15:27 Go to previous messageGo to next message
_Seven_ is currently offline  _Seven_
Messages: 35
Registered: April 2006
Member
sorry i'm a noob working on this but erros of the code are:
Quote:


H:\MyApps\myfirstGUI\main.cpp:28: error: `MainBar' does not name a type
H:\MyApps\myfirstGUI\main.cpp: In member function `void App::Opcoes(Bar&)':
H:\MyApps\myfirstGUI\main.cpp:22: error: `CTRL_Q' undeclared (first use this function)
H:\MyApps\myfirstGUI\main.cpp:22: error: (Each undeclared identifier is reported only once for each function it appears in.)
H:\MyApps\myfirstGUI\main.cpp: In constructor `App::App()':
H:\MyApps\myfirstGUI\main.cpp:32: error: `numbers_enabled' undeclared (first use this function)
H:\MyApps\myfirstGUI\main.cpp:33: error: no matching function for call to `App::AddFrame(<unknown type>)'
H:/Programas/upp/uppsrc/CtrlCore/CtrlCore.h:770: note: candidates are: Ctrl& Ctrl::AddFrame(CtrlFrame&)
H:\MyApps\myfirstGUI\main.cpp:34: error: `menu' undeclared (first use this function)
H:\MyApps\myfirstGUI\main.cpp:34: error: `MainBar' is not a member of `App'
H:\MyApps\myfirstGUI\main.cpp: In function `void GuiMainFn_()':
H:\MyApps\myfirstGUI\main.cpp:40: error: expected primary-expression before '.' token
Re: Problems with the code [message #3537 is a reply to message #3534] Wed, 31 May 2006 16:37 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
_Seven_ wrote on Wed, 31 May 2006 14:27

sorry i'm a noob working on this...



Then, also, if you want to experiment with examples, do not change many things at once!

1. Make a copy of the example package.
2. In that copy, change ONE thing and compile.
3. If you got an error then analyze that error and/or ask here.

have you read this topic?:
http://www.arilect.com/upp/forum/index.php?t=msg&th=483& amp;start=0&

[Updated on: Wed, 31 May 2006 16:49]

Report message to a moderator

Previous Topic: mechatronic transmission project [was -Please, help me!]
Next Topic: Problems with the position of buttons
Goto Forum:
  


Current Time: Sat Jun 15 15:43:36 CEST 2024

Total time taken to generate the page: 0.01953 seconds