_Screen.AddObject("AselobjTimer1","AselobjTimer") Define Class AselobjTimer As Timer Interval = 250 Procedure Init() Clear This.AddProperty("oDesignTimeIDs",Createobject("Collection")) This.AddProperty("oEventhandlers",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 This.oEventhandlers.Add(NewObject(loObject.EventhandlerClass,; loObject.EventhandlerClasslib,"",loObject)) Catch ? "failed to create eventhandler" Endtry Endif Endfor Endif Endwith Endproc EnddefineA simple eventhandler is:
Define Class Widthhandler As Custom Procedure Widthchange() Activate Screen ? "width changed" Endproc Procedure Init Lparameters toObject If toObject.DesignMode If PemStatus(toObject,"Width",5) BindEvent(toObject,"Width",This,"Widthchange") EndIf Else If PemStatus(toObject,"Resize",5) BindEvent(toObject,"Resize",This,"Widthchange") EndIf Endif Endproc Enddefineand the typical setup for a class usable with the timer and an eventhandler would be
Define Class xyz As Form EventhandlerClass = "Widthhandler" EventhandlerClasslib = "somepath/some.vcx or prg" DesignMode = .T. Name = "Form1" Procedure Init() This.DesignMode = .F. Try _Screen.Newobject(Sys(2015),This.eventhandlerclass,This.eventhandlerclasslib,"",This) Catch * Endtry Endproc Enddefineand this of course should be some visual class, not a prg class, as "MODI COMM" will not trigger anything.