>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 :)
I have one class in my libraries based on custom
which is fairly easy to use. But u have to turn it into visual object.
So just create new class to yr main vcx based on 'custom' and add folowing two methods.
Here is code version ;
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
enddefine
Implementation in subclass (that going to be dropped on the form)
then goes like this ;
define class oScan as objects_scan
procedure do_the_thing
Lparameters oControl
local oControl
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
thisform...oScan.go_all_over(thisform)
and passing desired container (e.g thisform )
as parameter.
Sorry for bad readability of the message (I always forget those
codes for presenting code)
There4 copy/paste/beautify :))
Hope this can help you.
Best Regards