Mike,
Based upon what you wrote below - I went back to the online help to try
and figure it out. I found an example in there - with creating some kind
of Array of Buttons on a screen. But, even in that example - it seemed
to show that I must know the names of the Objects on the screen - which
is exactly what I am trying to avoid.
I did some further searching around in the Online Help - and I came
across this:
Determining What Controls Are on a Form
To determine how many controls are on the form, you can use the
ControlCount property. The Controls[n] property of the form allows you
to reference each control on the form. The following program prints the
Name property of all the controls on the currently active form.
ACTIVATE SCREEN && to print to the main Visual FoxPro window
FOR nCnt = 1 TO Application.ActiveForm.ControlCount
? Application.ActiveForm.Controls[nCnt].Name
ENDFOR
Well - this ControlCount and this Controls[n] property is EXACTLY What I
was looking for all along. I just wasn't finding it before - and I
looked around in help in a different way this time.
So - I implemented this:
FOR nCnt = 1 TO Thisform.ControlCount
Thisform.Controls[nCnt].Visible = .F.
ENDFOR
And - OMG - it worked like a Charm!!! Such utterly simple code - yet, it
does EXACTLY What I needed.
But, still thanks for pointing me in the right direction!!!
L8r,
-K-
-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of MB Software Solutions, LLC
Sent: Wednesday, June 20, 2012 6:16 PM
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
_______________________________________________
Post Messages to: [email protected]
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/289ea162f5642645b5cf64d624c66a140e260...@us-ny-mail-002.waitex.net
** 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.