Re: Accessing Form Objects Numerically...

Author: MB Software Solutions, LLC

Posted: 2012-06-20 at 17:16:21

On 6/20/2012 5:57 PM, Kurt Wendt wrote:

> Why you'd use @SAY/GET in VFP7??? I didn't use it! Its an old, OLD

> system - starting way back as Foxbase+ or FP for DOS. I didn't build it

> - I only support it - and add new features. Many times - if it's a

> completely new screen - I will actually make it graphical as a Form.

>

> The idea of using " FOR EACH oObject in thisform.Controls " sounds

> exactly what I was looking for. Any place you can point me to in the

> Help files for more specific details? As I've definitely not ever done

> that particular type of code before...

>

> Thanks again,

> Kurt

Check out the FOR EACH in VFP Help. It's in there. Likewise, you

should consider putting something in the Init of your classes used in

the form so that you're only registering the controls that you really

want to scan/check/work-with. That avoids you cycling through tons of

controls for no reason at all. There's a pattern name for that but it

escapes me at the moment.

For example, in your txtKurt.Init class method, you'd have the following

code:

if this.lRegister then

thisform.AddToCollectionToCheck(this)

endif

And of course that means you'd have a custom property called lRegister

that you set to .T. if you cared about that object on the screen being

included in your check/work-with-it routine. Then in your frmKurt form

class, you'd have a custom method called AddToCollection that received

the object as a parameter and added it to the form's collection (using

some custom property like oControlsToCheck that was a collection object).

Then when you needed to work with those controls that you really cared

about, you could cycle through that collection. example: FOR EACH

oObject in thisform.oMyControls

This is all out of my head, but I think it should work.

(And yes, I still prefer the old Hungarian notation for form property

names. Insert mockery here! lol)

--

Mike Babcock, MCP

MB Software Solutions, LLC

President, Chief Software Architect

http://mbsoftwaresolutions.com

http://fabmate.com

http://twitter.com/mbabcock16

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/profox

OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/4FE24BB5.3080808@mbsoftwaresolutions.com

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2012 MB Software Solutions, LLC