Home » Community » Newbie corner » Callback and Thisback Function call parameters
Callback and Thisback Function call parameters [message #43429] |
Tue, 29 July 2014 11:50 |
NilaT
Messages: 70 Registered: November 2011 Location: Austria
|
Member |
|
|
Hi everybody, I've got a new question for you, which is driving me nuts.
Callbacks and Thisbacks are quite difficult for beginners, but I think I got them... almost
One thing is still unclear to me.
How can I add Parameters to a Function which is called, when a callback occurs?
For example:
Somewhere I got this:
Callback2<Point, Point> WhenProductChanging;
and then I got this, somewhere
...
WhenProductChanging(p1, p2);
...
And somewhere else I got this:
xxx.WhenProductChanging = THISBACK(OnProductChanging);
And finally, I got the function itself:
void yyy::OnProductChanging(Point firstP, Point secondP)
{ /* do something */
}
Now, what I want is to add another parameter to my "OnProductChanging" Method, like for example:
void yyy::OnProductChanging(Point firstP, Point secondP, int newParameter)
{ /* do something */
}
So I thought I have to change the THISBACK to THISBACK1 and pass the parameter after the Methodname, like this:
xxx.WhenProductChanging = THISBACK1(OnProductChanging, 1);
But this doesn't work, because it seems that all necessary parameters come from the callback. How can I pass another parameter, which is defined somewhere else and not known in the "callback-calling" function?
Thanks in advance!
[Updated on: Tue, 29 July 2014 11:51] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Apr 28 09:54:44 CEST 2024
Total time taken to generate the page: 0.03846 seconds
|