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 » Dialog box with some internal actions
Dialog box with some internal actions [message #31623] Fri, 18 March 2011 09:52 Go to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

I have a modal dialog box with 3 buttons (let's say : Ok, Cancel and Action). Action is some stuff to do inside the dialog box. I wrote this code :

struct MyDlg : public WithMydialogLayout<TopWindow> {
	...
	void DoAction();
	...
	MyDlg() {
		...
		action.WhenPush <<= THISBACK(DoAction);
	}
}

MyDlg::DoAction() {
...
}


I get an error :
error : 'DoAction' is not a member of 'Upp:TopWindow'


Surely, I should not use WithMydialogLayout<TopWindow>, but I don't understand what to use instead ? Is there some simple example showing how to do that ?

I think that the difficulty for me is that I don't understand well what the code
WithMydialogLayout<TopWindow>

is doing... I suppose that we ask to construct a dialog box from the Layout, with 'TopWindow' as base class ? But what are the possible base classes for dialog boxes ? I was unable to find some document describing the base classses and their hierarchy (as I suggested in this post, some more links between the various pages of documentation should help everybody a lot, especially beginners Wink )
Re: Dialog box with some internal actions [message #31629 is a reply to message #31623] Fri, 18 March 2011 13:19 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Jibe,

jibe wrote on Fri, 18 March 2011 09:52

I think that the difficulty for me is that I don't understand well what the code
WithMydialogLayout<TopWindow>

is doing...


Actually the problem is not in WithXYZLayout<> template, but in the THISBACK macro... You are missing here is the CLASSNAME typedef inside the MyDlg:
typedef MyDlg CLASSNAME;
It is neccessary for the THISBACKs to work (have a look how it is defined Wink ).

jibe wrote on Fri, 18 March 2011 09:52

I suppose that we ask to construct a dialog box from the Layout, with 'TopWindow' as base class ? But what are the possible base classes for dialog boxes ?

Yes, you suppose right. It creates class with TopWindow as base, which has all the Ctrl you defined in the layout. In 95% of cases TopWindow is the correct base class to use, especially in case of dialogs. Alternatively, in other cases, you can use Ctrl as base class (to create Ctrl composed from other Ctrls) or some Frame derived class (when you want to create frame that contains Ctrls). Generally, you can use any class that is derived from Ctrl as a base class (both TopWindow and Frame are Ctrl-derived).

Best regards,
Honza
Re: Dialog box with some internal actions [message #31634 is a reply to message #31623] Fri, 18 March 2011 15:17 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
I already tried to add the typedef, but I got an error
error: no match for ‘operator<<=’ in ‘((MyDlg*)this)->MyDlg::<anonymous>.WithMydialogLayout<Upp::TopWindow>::DoAction.Upp::Button::<anonymous>.Upp::Pusher::WhenPush <<= Upp::callback(OBJECT*, void (METHOD::*)()) [with OBJECT = MyDlg, METHOD = MyDlg](&MyDlg::DoAction)’

and I don't understand well about what the compiler is complaining...
Re: Dialog box with some internal actions [message #31637 is a reply to message #31634] Fri, 18 March 2011 15:39 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Oh, so there was one more mistake that I missed (but the unforgiving compiler sees it Smile ). To assign WhenPush callback, you should use just plain "=" operator:
MyDlg() {
		...
		action.WhenPush = THISBACK(DoAction);
	}

The "<<=" is shortcut for ".WhenAction =". For other callbacks, only ordinary assignment is used. BTW: Are you sure you want to use WhenPush? WhenAction gives you the expected results most of the time, I think WhenPush is only for some special cases (I personally never used it Smile ).

So, to sum it up:
MyDlg() {
		...
		action <<= THISBACK(DoAction); // Sets WhenAction
	/*OR*/	action.WhenAction = THISBACK(DoAction);
	/*OR*/	action.WhenPush = THISBACK(DoAction); // If you really want WhenPush
	}

Honza
Re: Dialog box with some internal actions [message #31640 is a reply to message #31623] Fri, 18 March 2011 15:47 Go to previous message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Ok, it was that ! Thank you very much ! Smile
Previous Topic: Dialog boxes : why struc instead of class ?
Next Topic: Install Error
Goto Forum:
  


Current Time: Mon Apr 29 01:15:10 CEST 2024

Total time taken to generate the page: 0.03657 seconds