>/* >VFP sample code : >o1 = createobject('Custom') >o2 = createobject('Container') >_screen.addobject('MyShape','Shape') >? Add_Property(o1,"Test_Property1",12345) >? Add_Property(o1,"Test_Property2","Hello") >? Add_Property(o1,"Test_Property3",date()) >? Add_Property(_screen.myShape,"bgcolor",0xffff00) >? Add_Property(o2,"objref",createobject('textbox')) >o2.objref.Value = 'MyValue' >luValue1 = Get_Property(o1,"Test_Property1") >luValue2 = Get_Property(o1,"Test_Property2") >luValue3 = Get_Property(o1,"Test_Property3") > >? type('luValue1'), luValue1 >? type('luValue2'), luValue2 >? type('luValue3'), luValue3 >with _screen.myShape > .Top = 100 > .Left = 100 > .BackColor = .bgcolor > .Visible = .t. >endwith >luObj = Get_Property(o2,"objref") >? luObj.Name, luObj.Baseclass, luObj.Value >set library to >wait window 'Any key to continue...' >_screen.myShape.Visible = .f. >_screen.removeobject('myShape') > >*/ >#include <pro_ext.h> > >char FAR *NullTerminate(Value FAR *cVal) >{ > char *RetVal; > if (!_SetHandSize(cVal->ev_handle, cVal->ev_length + 1)) > { > _Error(182); // "Insufficient memory" > } > > ((char FAR *) _HandToPtr(cVal->ev_handle))[cVal->ev_length] = '\0'; > RetVal = (char FAR *) _HandToPtr(cVal->ev_handle); > return RetVal; >} > >void FAR PropGet(ParamBlk FAR *parm) >{ > #define obj (parm->p[0].val) > #define prpname (parm->p[1].val) > > Value val; > ZeroMemory(&val, sizeof (Value)); > > char FAR *PropertyName = NullTerminate(&prpname); > int Success = _GetObjectProperty(&val, &obj, PropertyName) ; > if ( Success != 0) > { > _Error(Success*-1); > } > else > { > _RetVal(&val); > } >} > >void FAR PropAdd(ParamBlk FAR *parm) >{ > #define obj (parm->p[0].val) > #define prpname (parm->p[1].val) > #define prpval (parm->p[2].val) > > > char FAR *PropertyName = NullTerminate(&prpname); > > // success code - 0 success, > //negative error abs value foxpro error number > // 1 add if not exists > int Success = _SetObjectProperty(&obj, PropertyName, &prpval, 1) ; > if ( Success != 0) > { > _Error(Success*-1); > } > else > { > _RetLogical(1); // Return .T. to foxpro > } >} > >FoxInfo myFoxInfo[] = >{ > {"Add_Property", (FPFI) PropAdd, 3, "OC?"}, > {"Get_Property", (FPFI) PropGet, 2, "OC"}, >}; > > >extern "C" { >FoxTable _FoxTable = >{ > (FoxTable *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo >}; >} >>Cetin