>I was hoping to have my class manage this without needing to add anything
>else to the form.  I thought there might be a function that returns what
>if any control is located in a specific screen area.  If that is not the
>case - would the following approach be feasible?
>
>    Scan through all the objects on a form building an array of ActiveX
>control names with their screen locations
>    Add a method to my class to make the appropriate Controls visible or
>invisible based on whether the  Top, Height, Left, and Width parameters
>passed in indicate a collision.
>
>I don't know how to scan the objects on a form but I assume there is a
>way.  Will it be critical to have the scan run after all the controls are
>initialed or is the info accessible while my class.Init runs?  If it
>needs to run at form initialization is there provision in the system for
>that to happen?  Other gotchas?

There isn't any easy way to return the name of a control from an area of 
the form. But your idea of the array will work fine.

You can add an array property to your container at design time by 
specifying the property name as:

aMyArray[1]

You can iterate the form's controls collection from within your container's 
Init() like so:

LOCAL ctrlcnt, x, octrl

cntrlcnt = THISFORM.ControlCount

FOR x = 1 TO cntrlcnt
      IF THISFORM.Controls(x).Class == "Olecontrol" OR 
THISFORM.Controls(x).Class == "Oleboundcontrol"
      DIMENSION THIS.aMyArray(ALEN(THIS.aMyArray,1) + 1,4)
      oCtrl = THISFORM.Controls(x)
      THIS.aMyArray(ALEN(THIS.aMyArray,1),1) = oCtrl.Name
      * Or an object reference:
      THIS.aMyArray(ALEN(THIS.aMyArray,1),1) = oCtrl
      THIS.aMyArray(ALEN(THIS.aMyArray,1),2) = oCtrl.Top
      THIS.aMyArray(ALEN(THIS.aMyArray,1),3) = oCtrl.Left
      THIS.aMyArray(ALEN(THIS.aMyArray,1),4) = oCtrl.Width
.... etc.
ENDIF
ENDFOR

Then you could iterate your array and check those position values and do 
some calculations.

This will work in the init of your container without problems in a simple 
test. It will go quite quickly even with a lot of controls on the form. In 
any case, it occurs in the Init of the container, which comes before the 
form inits, which means it all happens before the form becomes visible.

When the form resizes though you'd need to re-gather the data, so you 
probably want the code that populates the array in a separate method called 
by both Init() and Resize().

Another possible point of contention would be hardcoding "THISFORM" in your 
search for other controls. If it's possible that this control of yours 
might eventually reside on a page of a pageframe of your form, for example, 
it might be better to use THIS.Parent instead. Or you can create a property 
of your container to hold an object reference to the parent object you're 
concerned about that you can set at design time.

Ken
www.stic-cil.org 



_______________________________________________
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/[email protected]
** 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.

Reply via email to