Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Design time event handler - part 2
Message
From
17/05/2007 17:31:05
 
 
To
16/05/2007 05:46:26
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01225893
Message ID:
01226551
Views:
25
Another advanced version of the AselobjTimer:
Try
   _Screen.RemoveObject("AselobjTimer1")
Catch
Endtry
_Screen.AddObject("AselobjTimer1","AselobjTimer")

Define Class AselobjTimer As Timer
   Interval = 250
   Procedure Init()
      Clear
      * maintain a collection of the created eventhandlers with 
      * the cDesignTimeIDs of the event source objects as key.
      This.AddProperty("oEventhandlers",Createobject("Collection"))
   Endproc

   Procedure Timer()
      * observe Aselobj
      Private paObjects
      Release paObjects
      =Aselobj(paObjects,1)
      
      Activate Screen
      Local loObject, loEventhandler, lnCount, llKeepID
      Local Array laEvents(1)
      With This.oEventhandlers
         * find entries in oEventhandlers collection with nonexistant event souce objects
         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 .GetKey(loObject.cDesignTimeID)=lnCount
                     llKeepID = .T.
                     Exit
                  Endif
               Endfor
            Endif
            If !llKeepID And Aevents(laEvents, .Item(lnCount))>0 And Vartype(laEvents(2))="O"
               llKeepID = .T.
            Endif
            If !llKeepID
               ? "removed "+.GetKey(lnCount)
               .Remove(lnCount)
            Endif
         Endfor

         * add an item for each new object in designtime with eventhandler,
         * if EventhandlerClass info is available.
         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
                  Try
                     loEventhandler = Newobject(loObject.EventhandlerClass,;
                        loObject.EventhandlerClasslib,"",loObject)
                  Catch
                     ? "failed to create eventhandler"
                     loEventhandler = .Null.
                  Endtry
                  .Add(loEventhandler,loObject.cDesignTimeID)
               Endif
            Endfor
         Endif
      Endwith
   Endproc
Enddefine
Bye, Olaf.
Previous
Reply
Map
View

Click here to load this message in the networking platform