Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recurse through all controls
Message
From
18/05/2004 06:15:16
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00904798
Message ID:
00904838
Views:
14
>Has anyone got a good tight routine that recurses through all controls on a form, including containers, pageframes etc. ?
>
>I keep coming up with code that looks too ugly to be doing it smart ! :)




Hi There again :)

Found those codes4code so here it is
define class objects_scan as custom


   procedure go_all_over
   lParameters ParentContainer
   local i,oControl

   for each oControl in ParentContainer.Controls

     do case

         Case oControl.baseclass=="Pageframe"
           for i = 1 to oControl.Pagecount
             this.go_all_over(oControl.Pages(i))
           next

         case oControl.baseclass=="Container"
           this.go_all_over(oControl)

         case oControl.baseclass=="Grid"
           for i = 1 to oControl.columncount
             this.go_all_over(oControl.columns(i))
           next

         otherwise
         this.do_the_thing(oControl) 

     endcase

   next
   this.do_the_thing(ParentContainer)

procedure do_the_thing
   Lparameters oControl
     && Place to put your action over
     && currently scanned control
     && passed here as parameter


enddefine
Implementation in subclass that going to be dropped on the form
(or code placed directly in method 'do_the_thing' could be as folows ;
define class oScan as objects_scan   

procedure do_the_thing
     Lparameters oControl  
     local oControl
     && Place to put your action over
     && currently scanned control
     && passed here as parameter 

     wait wind oControl.name 


enddefine
****
After being dropped on the form
scanning of the objects (and doing the thing :) has to be
invoked by calling method 'go_all_over' and passing desired parental container (e.g thisform ) as parameter ;
thisform.oScan.go_all_over(thisform) 

&& or
thisform.oScan.go_all_over(thisform.grid1) 

&& or
thisform.oScan.go_all_over(thisform.PageFrame1) 

&& depend what you want to scan 
Hope this can help you.
Best Regards
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform