>>>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,
>I'm sorry but it's not generic. It's limited to part of controls that can be used in VFP.
>Cetin
Ok Cetin :)
It is generic to *me* because that is about all controls containin other
controls I use.
Will shortly add 'support' for cmdbutton/option groups. What else is there that I overlooked in this respect ?