Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enable / Disable All Form Controls
Message
From
15/07/2013 10:04:47
 
 
To
12/07/2013 12:28:48
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01578324
Message ID:
01578438
Views:
63
Likes (1)
>Greetings All,
>
>Attempting to enable and disable all text boxes in a page frame once the user selects the edit or add button. Here is the code I have in my form method:
>
>DISABLEALL Method:
>
>FOR I = 1 TO THISFORM.CONTROLCOUNT
> IF UPPER(THISFORM.CONTROLS(I).NAME) = [TXT_]
> THISFORM.CONTROLS(I).ENABLED = .F.
> ENDIF
>ENDFOR
>
>But it's not going through those textboxes that are listed throughout the 4 pages of the pageframe. the enableall method is quite naturally the opposite, setting enabled to .T.
>
>How do I set all the controls on the pages of the pageframe?



Hi Jeffrey
Here is generic code (class) which you can use to handle this kind of situations
with nested objects/hierarchies (containers inside containers, pageframes etc) ;
define Class ObjectScanner as Custom

procedure do_the_thing
lParameters oControl

** Input control handling here at subclass level
***Once you dropped it to the form





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)


enddefine
You turn it into custom class in some vcx of yours (from this code you create visual class) and then drop on form you want to handle. Once in form as custom object you can call it's main method and pass object reference of cobject containing other objects (form, pageframe, container etc)
Class will traverse through object hierarchy (starting from given point) and call place holder method 'do_the_thing' and parse each control object reference to it. Use place holder method to perform action on (stream) of controls.
**place holder method 'do_the_thing' on subclassed instance of object scanner on the form;
lparameters oControl
if ... 
oControl.enabled = .t.
else
oControl.enabled = .f.
endif
To start it all you call main method ;
Thisform.ObjectScanner1.go_all_over(thisform)
**or
Thisform.ObjectScanner1.go_all_over(thisform.Pagerframe1) 

**or
Thisform.ObjectScanner1.go_all_over(thisform.SomeContainer) 
HTH
Sergio
*****************
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