On Nov 30, 2007, at 4:54 PM, Daniel Stenning wrote:
>
>
>
> On 30/11/07 21:39, "Dave Addey" <listmail1 at addey dot com> wrote:
>
>> Hi Daniel,
>>
>> That does help! A few more questions in that case:
>>
>> 1) Where should I store "d"? Can it be a property of the class
>> myClass?
>>
> You can pretty much store it anywhere you want to. But it will
> always invoke
> the method on the particular class instance that you created the
> delegate
> INSTANCE from.
>
>> 2) If I am registering a callback (using a declare), should I pass
>> d as a
>> ptr into the declare?
> RB will convert a delegate instance into a Ptr type on the fly, so
> I think
> you can either declare the callback as a ptr OR the delegate name.
> I seem to
> recall just doing that myself recently.
>
>> Or something else? I guess I'm not looking to invoke
>> the delegate myself, but rather to have it called from a callback.
>
> Actually - for callbacks I you cannot pass any delegate that was
> created
> from a class instance. Youre forced to use a global or shared
> method. The
> Calling conventions are different.
Actually, this isn't quite right. I think it's more accurate to say
that when a delegate is converted to Ptr, any information about the
object is stripped, and all that's left is the function pointer
itself. So you can pass an object method delegate to an external
callback, but all that is passed is the function pointer, and you
can't go back.
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|