Kirk,

Thanks for your reply, which is interesting. This is what I’m doing. I wrote 
most of the code quite a while ago, before objects and before dynamic variables.

I have a component to handle listboxes. Its methods can be used in three ways.

1. The box is fully set up in the Form editor. The component’s routines are 
used mainly to record, without any more code, changes in sort order, column 
width and column order.

2. The box is designed in the component’s designer but lives in one of the 
host’s forms. A single call sets up all the columns and deals also with 
everything in option 1.

3. The box is designed as in (2), but lives in a subform containing a form in 
the component. At the host level, all that’s necessary to set up the box is to 
assign the box’s name (set in the designer) to the subform’s variable.

In the component, there’s a global array of objects in the form I described: 
{pointer to listbox; info object}. The info object holds column order, column 
widths, table/field IDs, column expressions and so on.

When the host calls the component’s methods (which include querying, sorting, 
handling clicks and double-clicks and so on), it identifies the relevant box by 
passing a pointer as a parameter. The component can then locate the info object 
for that box by searching on the pointer. Using Find in array with matched 
arrays (one of pointers and one of info objects), it works very nicely, but of 
course the arrays need to be kept in sync. The advantage to the host programmer 
is that listbox pointers can be used to call the component’s methods in the 
same way as 4D’s listbox methods.

Using the listbox variable name doesn’t work well when the box is on a host 
form because the component can’t see objects in the form; and it doesn’t work 
well when the box is in a subform, because they all have the same name. The 
advantage of pointers is that they are truly universal, usable in exactly the 
same way in host and component.

I bore you with the details only because I feel your detailed post merited a 
detailed response. 

Jeremy
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to