diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index 22c62436d5..df26f6d108 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -2621,4 +2621,23 @@ HB_FUNC( __CLSGETPROPERTIES ) } hb_itemRelease( hb_itemReturn( pReturn ) ); -} \ No newline at end of file +} + +/* Real dirty function, though very usefull under certain circunstances: + * It allows to change the class handle of an object into another class handle, + * so the object behaves like a different Class of object. + * Based on objects.lib SetClsHandle() */ + +HB_FUNC( HB_SETCLSHANDLE ) /* ( oObject, nClassHandle ) --> nPrevClassHandle */ +{ + PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT ); + USHORT uiPrevClassHandle = 0; + + if( pObject ) + { + uiPrevClassHandle = pObject->item.asArray.value->uiClass; + pObject->item.asArray.value->uiClass = ( USHORT ) hb_parnl( 2 ); + } + + hb_retnl( uiPrevClassHandle ); +}