_Screen.AddObject("AselobjTimer1","AselobjTimer") Define Class AselobjTimer As Timer Interval = 250 Procedure Init() Clear This.AddProperty("oDesignTimeIDs",Createobject("Collection")) Endproc Procedure Timer() Private paObjects Release paObjects =Aselobj(paObjects,1) Activate Screen Local loObject, lnCount, llKeepID With This.oDesignTimeIDs For lnCount = .Count To 1 Step -1 llKeepID = .F. If Type("paObjects",1)="A" For Each loObject In paObjects If Pemstatus(loObject,"cDesignTimeID",5) And loObject.cDesignTimeID=.Item(lnCount) llKeepID = .T. Exit Endif Endfor Endif If !llKeepID ? "removed "+.Item(lnCount) .Remove(lnCount) Endif Endfor If Type("paObjects",1)="A" For Each loObject In paObjects If !Pemstatus(loObject,"cDesignTimeID",5) Or .GetKey(loObject.cDesignTimeID)=0 AddProperty(loObject,"cDesignTimeID",Sys(2015)) ? "added "+loObject.Name+ " as "+loObject.cDesignTimeID .Add(loObject.cDesignTimeID,loObject.cDesignTimeID) Try loObject.InitEventhandler() Catch ? "no eventhandler init found" Endtry Endif Endfor Endif Endwith Endproc EnddefineThis works in adding a cDesignTimeID property to any object and storing it in a collection. As long as the object lives it isn't touched again. If it's saved/closed, the item of the collection is removed by checking, if the ID is found in the array of living objects.
this.DesignMode=.F. this.InitEventhandler()...especially if you want the same eventhandling at runtime (also with handling events conditional on DesignMode property). Just don't try to bind to events or methods, if you want the eventhandler triggered at design time, as design time object methods like eg resize are not triggered, bind to height or width instead.