Jeremy, Not a boring response at all and gives a good description of what you're doing.
My first thought is that if you want to support both "classic 4D" listboxes and modern, Form based listboxes from the same component you are going to want to branch the code. As you are discovering attempting to use both "modern" and "classic" 4D tools at the same time leads to various problems with complicated workarounds. Especially in a situation like this where the approach to managing what appears on the screen as a 'listbox' is a completely different data structure depending on the way it's constructed. Personally I've found the modern approach so. much. easier. I use a fraction of the code I would have before. But I also commit to the listbox (based on entity selection or collection) being "modern". Working with classic listboxes is where I pull out pointer arrays, selection sets, current row numbers, and all that jazz. I have not had good results attempting to combine the two. Choose one or the other: you're working on a Camero or you're working on a Tesla. Parts for one just don't fit the other even when they are called the same thing. Or perhaps a more germane quip would be a long time ago when I discovered the very expensive Laserwriter I purchased couldn't be "upgraded" to the new generation. "The only thing the two can both use is the power cord," my rep explained. On Wed, Jul 31, 2019 at 8:31 AM Jeremy Roussak via 4D_Tech < [email protected]> wrote: > 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] > ********************************************************************** -- Kirk Brooks San Francisco, CA ======================= What can be said, can be said clearly, and what you can’t say, you should shut up about *Wittgenstein and the Computer * ********************************************************************** 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] **********************************************************************

