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 » U++ Library support » U++ Widgets - General questions or Mixed problems » Problem with TopWindow and Widgets using Layout editor
Problem with TopWindow and Widgets using Layout editor [message #23735] Wed, 18 November 2009 12:35 Go to next message
Mystery Smith is currently offline  Mystery Smith
Messages: 4
Registered: November 2009
Junior Member
Hi all,

I'm new here and I have just started learning U++ with TheIde, and I am not too good at C++ itself either. I think that I have the general idea, but I have one problem with this code.


I have a layout with a button labelled "CANCELBUTTON" and I want an action to happen when it is pressed.

This is my code so far.

// gameSettings
struct gameSettings : WithSettingsWindow<TopWindow>
{
	
	
	
	void Exit() {
        if (PromptOKCancel("Cancel changes to settings?") == 1)
            { Break(); }
    }
	
	CANCELBUTTON=callback(Exit);
	
	gameSettings()
	{
		CtrlLayout(*this, "Game Settings");
	}
};


And my error message:

C:\MyApps\BrainBox\main.cpp(25) : error C3867: 'gameSettings::Exit': function call missing argument list; use '&gameSettings::Exit' to create a pointer to member
C:\MyApps\BrainBox\main.cpp(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\MyApps\BrainBox\main.cpp(25) : error C2864: 'gameSettings::CANCELBUTTON' : only static const integral data members can be initialized within a class


Is there anybody who can help me fix this problem?


Thanks very much in advance
Re: Problem with TopWindow and Widgets using Layout editor [message #23738 is a reply to message #23735] Wed, 18 November 2009 13:50 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Mystery

I would begin adding "typedef gameSettings CLASSNAME;" this way:

// gameSettings
struct gameSettings : WithSettingsWindow<TopWindow>
{
	typedef gameSettings CLASSNAME;   // This is new


And I would change "callback" with "THISBACK".

Best regards
Koldo


Best regards
Iñaki
Re: Problem with TopWindow and Widgets using Layout editor [message #23740 is a reply to message #23738] Wed, 18 November 2009 17:01 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Well, there are more problems than that.

- Callback assigment must be in a function
- Callback assigment should use the <<= operator
- Use RejectBreak so that the window is restored to it's previous state.

// gameSettings
struct gameSettings : WithSettingsWindow<TopWindow>
{
	typedef gameSettings CLASSNAME;
	
	void Exit() {
		if (PromptOKCancel("Cancel changes to settings?"))
			{ RejectBreak(IDCANCEL); }		
	}
	
	gameSettings()
	{
		CtrlLayout(*this, "Game Settings");
		
		CANCELBUTTON <<= THISBACK(Exit);
	}
};
And while naming conventions are generally a matter of style I would strongly advise against using all uppercase for variable names. It will conflict with macros and make your code more difficult to read.

Keep at it, and feel free to ask more questions Smile

[Updated on: Wed, 18 November 2009 17:03]

Report message to a moderator

Re: Problem with TopWindow and Widgets using Layout editor [message #23784 is a reply to message #23735] Sun, 22 November 2009 06:27 Go to previous messageGo to next message
Mystery Smith is currently offline  Mystery Smith
Messages: 4
Registered: November 2009
Junior Member
Thank you very much, it all works perfectly now and I don't get "Heap Leaks Detected" errors anymore.
Re: Problem with TopWindow and Widgets using Layout editor [message #23786 is a reply to message #23784] Sun, 22 November 2009 09:15 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Excellent Mystery and feel free to ask. We like to help. Smile

Best regards
Iñaki
Previous Topic: Sending an email from Upp application
Next Topic: Calling windows not in main.cpp
Goto Forum:
  


Current Time: Thu Mar 28 23:10:12 CET 2024

Total time taken to generate the page: 0.01395 seconds