Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!apple!well!svc From: svc@well.UUCP (Leonard Rosenthol) Newsgroups: comp.sys.mac.programmer Subject: Re: List manager and Think C Summary: Here's how to move a list Keywords: Lists, Moving, Think C Message-ID: <13448@well.UUCP> Date: 1 Sep 89 17:15:32 GMT References: <5501@viscous.sco.COM> Reply-To: svc@well.UUCP (Leonard Rosenthol) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 76 In article <5501@viscous.sco.COM> jamesm@sco.COM (James M. Moore) writes: >One question about lists, one comment about the Think object >libraries: > >1. Is there any way to change the location of a list? There doesn't >seem to be a list manager call to do so. The kludge that I tried that >didn't work was to directly modify (**listHandle).rView, and then >InvalRect the entire list. If this isn't possible, how do you clone a >list? It seems like you could just build a new list that's the same >size as the old, then just set (**newListHandle).cells to point to the >old list's data. The first problem I see with that is that when you >delete the old list, it expects to be able to delete its data. I >guess you could set the cells handle to a dummy handle that it could >then delete, but this seems to be moving from the realm of 'hack' into >that of 'kludge.' Anyone have a more elegant way to do this? > Here is some code (yes, I know it's in Pascal, but the Pascal code was closer..) that will Hide and Show LM Lists. You can easily modify it to simply offset lists using the same techniques. PROCEDURE HideDLOGList(theDialog: DialogPtr; theItem: integer; theList: ListHandle); VAR theType: integer; theHandle: handle; theRect: Rect; BEGIN IF theList^^.rView.left < 1000 THEN {Only if not already hidden!} BEGIN GetDItem(theDialog, theItem, theType, theHandle, theRect); HideDItem(theDialog, theItem); OffsetRect(theList^^.rView, 16834, 0); OffsetRect(theList^^.vScroll^^.contrlRect, 16834, 0); HiliteControl(theList^^.vScroll, 255); {Disable it too...} InsetRect(theRect, - 1, - 1); InvalRect(theRect); END; END; PROCEDURE ShowDLOGList(theDialog: DialogPtr; theItem: integer; theList: ListHandle); VAR theType: integer; theHandle: handle; theRect: Rect; BEGIN IF theList^^.rView.left > 1000 THEN {Only if not already shown!} BEGIN ShowDItem(theDialog, theItem); GetDItem(theDialog, theItem, theType, theHandle, theRect); OffsetRect(theList^^.rView, - 16834, 0); {Restore based on Show} OffsetRect(theList^^.vScroll^^.contrlRect, -16834, 0); HiliteControl(theList^^.vScroll, 0); {and enable it!} DrawADLOGList(theDialog, theList); InsetRect(theRect, - 1, - 1); InvalRect(theRect); END; END; {DrawADLOGList is simply a routine which updates a list in a dialog} Hope that helps... -- +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025