J
John Biddiscombe
I have a pointer to a form
form->DoStuff();
but the subclass of form is not being called despite the DoStuff() being
declared virtual in the base class. One thing that is interesting is that
the Subclass of form is declared/compiled inside an exe, whilst the base
class is inside a dll (assembly).
Is there a restriction on virtual calls not being propagated out of an
assembly an into another unit? (I notice that much of the framework
redeclares handlers for stuff, when a virtual call in the base class might
be better).
Any idea what I may have done wrong
Snippet follows. The callback is generated in an unmanaged dll, using a
GCHandle to point to the form.
void FormCallBackFn(AnObj *obj, unsigned long ID, void *self, void *data)
{
System::IntPtr handle = self;
GCHandle GCHandle = GCHandle:p_Explicit(handle);
MyWindow __gc *const thisPtr = dynamic_cast<MyWindow
__gc<*const>(GCHandle.Target);
if (!thisPtr) return;
switch (ID) {
case MyStuff:oSomethingInteresting :
thisPtr->DoStuff(obj, data);
break;
default:
break;
}
}
thisPtr->DoStuff(obj, data); is always calling
BaseForm:oStuff(obj, data);
and not
DerivedForm:oStuff(obj, data);
(Thje debugger clearly shows that thisPtr is actually a derived class and
not a base one)
thanks
JB
form->DoStuff();
but the subclass of form is not being called despite the DoStuff() being
declared virtual in the base class. One thing that is interesting is that
the Subclass of form is declared/compiled inside an exe, whilst the base
class is inside a dll (assembly).
Is there a restriction on virtual calls not being propagated out of an
assembly an into another unit? (I notice that much of the framework
redeclares handlers for stuff, when a virtual call in the base class might
be better).
Any idea what I may have done wrong
Snippet follows. The callback is generated in an unmanaged dll, using a
GCHandle to point to the form.
void FormCallBackFn(AnObj *obj, unsigned long ID, void *self, void *data)
{
System::IntPtr handle = self;
GCHandle GCHandle = GCHandle:p_Explicit(handle);
MyWindow __gc *const thisPtr = dynamic_cast<MyWindow
__gc<*const>(GCHandle.Target);
if (!thisPtr) return;
switch (ID) {
case MyStuff:oSomethingInteresting :
thisPtr->DoStuff(obj, data);
break;
default:
break;
}
}
thisPtr->DoStuff(obj, data); is always calling
BaseForm:oStuff(obj, data);
and not
DerivedForm:oStuff(obj, data);
(Thje debugger clearly shows that thisPtr is actually a derived class and
not a base one)
thanks
JB