Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can SetAllX be used to call a method of a particular cla
Message
From
06/08/2007 02:30:53
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01245942
Message ID:
01246080
Views:
18
>Hi all
>
>I wanted to loop through all controls on a form and if an instance of a particular class is found I wanted a method of this class to be executed, can SetAllX do this?
>
>Further, this called method will return a logical value depending on which I want the calling code to stop further processing, so out of multiple instances even if one of them returns a .F. I want the calling code to stop executing. So is it possible to get a list of return values from SetAllX?
>
>Please advise.

Hi Bhav

Here is generic solution I use for this kind of things;

Create custom object class in some of your common VCX libraries
out of this code
define class FormScanner as custom

    procedure ScanControls
        lparameters oParentContainer
        local i,oControl
        for each oControl in oParentContainer.controls
            do case
                case oControl.baseclass="Pageframe"
                    for i = 1 to  oControl.pagecount
                        this.ScanControls(oControl.pages(i))
                    next

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

                case oControl.baseclass="Grid"
                    for i = 1 to  oControl.columncount
                        this.ScanControls(oControl.columns(i))
                    next
                otherwise
                    this.with_object(oControl)
            endcase
        endfor
        this.with_object(oParentContainer)


    procedure with_object
        lparameters oControl
        wait wind oControl.name timeout 0.5

enddefine
Then simply drop that class object to form you want to scan
and use 'With_Object' hook method to do whatever you want with that particular control. This method will receive all form controls wherever
they are as object reference parameter.

To run whole thing simply call loop method of custom obect scanner
as
thisform.FormScanner1.ScanControls(thisform)

*Or any other containership  

thisform.FormScanner1.ScanControls(thisform.myPageFrame1)

thisform.FormScanner1.ScanControls(thisform.myContainer1)

*etc
HTH
*****************
Srdjan Djordjevic
Limassol, Cyprus

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

Click here to load this message in the networking platform