Home » Community » Newbie corner » Dialog box with some internal actions
|
Re: Dialog box with some internal actions [message #31629 is a reply to message #31623] |
Fri, 18 March 2011 13:19   |
|
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: It is neccessary for the THISBACKs to work (have a look how it is defined ).
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 #31637 is a reply to message #31634] |
Fri, 18 March 2011 15:39   |
|
Oh, so there was one more mistake that I missed (but the unforgiving compiler sees it ). 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 ).
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
|
|
|
|
Goto Forum:
Current Time: Wed Apr 30 03:12:47 CEST 2025
Total time taken to generate the page: 0.01037 seconds
|