Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding All Textboxes in Form
Message
De
05/09/2005 09:43:21
 
 
À
05/09/2005 08:50:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 6
Divers
Thread ID:
01045035
Message ID:
01046780
Vues:
49
Why not ??
Number of baseclasses is limited and they are known upfront.
I simply prefer it this way. Makes code simplier.

See how easy was to fix code below & add missing functionality u mentioned in yr previous mesage. (Drill down to include Command/Option Groups).

I think that now only formsets are missing. I always hated & never used those... But I am gonna add them later today just to make it complete.

Am I missing any other object that can contain objects available to VFP6 ?
All I can think of are form's datasessions.

***Fix in order to include Command/Option Groups
local oGPRO
oGPRO=createobject('ObjectScanner')
oGPRO.scan_vfp()
*oGPRO.scan_containtership(oFormReference)   &&valid call for 


***App GPRO
define class ObjectScanner as shape

    procedure scan_vfp
        local i,oObj
        i=1
        do while type('_vfp.objects(i)') <> 'U'
            oObj=_vfp.objects(i)
            do case
                case inlist(oObj.baseclass,'Form','Container','Toolbar')
                    this.scan_containership(oObj)

                *Case it is formset do we bother handling that ?                 

                *Case it is collection then what ?   (I am with VFP6)
                
                *Anything else ?

                otherwise
                    this.with_object(oObj)

            endcase
            i=i+1
        enddo


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

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

                *** Addition to include Commandgroups and Optiongroups 
                case inlist(oControl.baseclass,'Commandgroup','Optiongroup')
                    for i = 1 to  oControl.buttoncount
                        this.with_object(oControl.buttons(i))
                    next

                otherwise
                    this.with_object(oControl)

            endcase
        next
        this.with_object(oParentContainer)


    procedure with_object
        lparameters oObj
        wait wind 'Scanning object [' + oObj.name + ']' timeout 0.5


enddefine
Anyway as I said this code is just an open idea
so perhaps by people commenting on it, will spark up
creation of more functionality.

Thks & Rgds++
Sergio




>I meant hardcoding of baseclasses like:

>
>>>> case oControl.baseclass=="Pageframe"
>
>Instead you might check if oControl has any members. Something like this:
>
*FillCollection
>Lparameters oContainerObject
>Local ix, nMembers, lnExpand, oObjectRef, aContainerObjects[1]
>nMembers = amembers(aContainerObjects, oContainerObject,2)
>With this
>	For ix = 1 to nMembers   && Start collecting
>		lnExpand = iif(type(".aCollection[1]")= "L",0,1)
>		Dimension .aCollection[alen(.aCollection,1)+lnExpand]
>		oObjectRef = eval("oContainerObject."+aContainerObjects[ix])
>		.aCollection[alen(.aCollection,1)] = oObjectRef
>		IF LOWER(oObjectRef.BaseClass) # "olecontrol" ;
>			AND LOWER(oObjectRef.BaseClass) # "oleboundcontrol"
>			.FillCollection(oObjectRef)  && Recurse
>		endif
>	Endfor
>Endwith
>*...
>
>Cetin
>
>>Hi Cetin,
>>What do you mean by checking them by names ?
>>I am checking them by baseclass, and then drill down accordingly.
>>You are right I did not include Command/Option group but this
>>can be arrangead easily. Especially that those two are getting accessed and passed to 'with_object'. So either can be relatively easily handled there, or built up within existing mechanisam. Most probably I will provide for this later today :)
>>
>>Wait windowing names in 'with_object' method is there just to show that every & each object is being accessed. That method is to be used later in subclasses to handle real life code handling.
>>
>>Thks for taking time to view & try code.
>>Any feedback is higly appreciated.
>>
>>Rgds++
>>Sergio
>>
>>
>>
>>>Srdjan,
>>>IMHO just checking by names is not enough nor flexible for determining container type objects. ie: In your code Commandgroup,OptionGroup... are missing. In FoxyClasses udfObjCollector class (which does drill down on objects) what I do is to check amembers(). If an object has members than it's a container type that you should drill down.
>>>Cetin
>>>
>>>>Hi Dragan,
>>>>Since we did more less the same thing more less the same way, I propose
>>>>we dare for more - together:)
>>>>
>>>>Here is basic code/idea how to drill down ALL objects starting with VFP
>>>>application object if requested, and then access everything within.
>>>>So let's see what (else) can be done with it.
>>>>
>>>>Difference in aproach is that i/o calling it via procs/funcs
>>>>user will simply subclass it and write it's own object handling
>>>>in special kind of listener method 'with_object' that gets EACH scanned object passed as parameter letting him do whatever he/she wants with it.
>>>>
>>>>I used similar aproach with XDIR tool for scanning directory structures
>>>>and I kind of liked it :)
>>>>
>>>>Just copy this code in a new prg and try it.
>>>>It shld work right away showing names of all object found within _vfp
>>>>object.
>>>>
>>>>
>>>>
>>>>local oGPRO
>>>>oGPRO=createobject('ObjectScanner')
>>>>oGPRO.scan_vfp()
>>>>
>>>>*oGPRO.scan_containtership(oFormReference)   &&valid call for
>>>>*downsizing scan scope to a single containership.
>>>>
>>>>
>>>>***App GPRO
>>>>define class ObjectScanner as shape
>>>>
>>>>    procedure scan_vfp
>>>>        local i,oObj
>>>>        i=1
>>>>        do while type('_vfp.objects(i)') <> 'U'
>>>>            oObj=_vfp.objects(i)
>>>>            do case
>>>>                case inlist(oObj.baseclass,'Form','Container','Toolbar')
>>>>                    this.scan_containership(oObj)
>>>>
>>>>                *Case it is formset do we bother
>>>>                *handling  that ?
>>>>
>>>>                *Case it is collection then what ?   (I am with VFP6)
>>>>
>>>>                *Anything else like accessing all session objects ?
>>>>
>>>>                otherwise
>>>>                    this.with_object(oObj)
>>>>
>>>>            endcase
>>>>            i=i+1
>>>>        enddo
>>>>
>>>>
>>>>    procedure scan_containership
>>>>        lparameters oParentContainer
>>>>        local i,oControl
>>>>        for each oControl in oParentContainer.controls
>>>>            do case
>>>>                case oControl.baseclass=="Pageframe"
>>>>                    for i = 1 to  oControl.pagecount
>>>>                        this.scan_containership(oControl.pages(i))
>>>>                    next
>>>>
>>>>                case oControl.baseclass=="Container"
>>>>                    this.scan_containership(oControl)
>>>>
>>>>                case oControl.baseclass=="Grid"
>>>>                    for i = 1 to  oControl.columncount
>>>>                        this.scan_containership(oControl.columns(i))
>>>>                    next
>>>>                otherwise
>>>>                    this.with_object(oControl)
>>>>            endcase
>>>>        next
>>>>        this.with_object(oParentContainer)
>>>>
>>>>
>>>>    procedure with_object  && Listener method
>>>>        lparameters oObject
>>>>        wait wind 'Scanning object [' + oObject.name + ']' timeout 0.5
>>>>
>>>>
>>>>enddefine
>>>>
>>>>
>>>>
>>>>Lets see where we can take it from here :)
>>>>If we come up with something usefull , then we can post it together
>>>>here on UT, or just add it to yr existing download.
>>>>
>>>>Rgds++
>>>>Sergio
>>>>
>>>>
>>>>
>>>>>>>You can curse at this all you want, but you can re-curse as well. Download #21923.
>>>>>>
>>>>>>Hi Dragan,
>>>>>>I recursed it myself :)
>>>>>>See Message#1045044 in this thread. It is also general purpose recursion
>>>>>>class but only within single form. I did not subclass it in my message for simplicity purposes.
>>>>>>
>>>>>>Will however take good look at yr GPR class
>>>>>>to see what else is there :)
>>>>>
>>>>>Probably not much. I tried to keep it fat-free, no salad.
>>>>>
>>>>>Maybe the example may give you some ideas.
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform