[futurebasic] Re: [FB] List boxes

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2003 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Sat, 26 Jul 2003 19:08:53 +0200

Bernie Wylde wrote:
> 
> 
> Many thanks to everyone who replied, esp. Alain and Steve.
> 
> I've not had time to look closely at the examples but how would we get 
> the line numbers of multiple selections?
> 

Bernie,

I don't know what is the good method. You can possibly get all the 
selected cells in a handle for instance.

clear local mode
local fn GetSelectedCells( btnID as long )
dim as point    cell
dim as handle  selCells, @ listH
dim as long   @ actualSize

def GetButtonData( btnID, _kControlListBoxPart, ¬
_kControlListBoxListHandleTag, sizeof(listH), listH, actualSize )
if listH = _nil then exit fn
selCells = Fn NewHandle(0)
long if selCells
while fn LGetSelect( _true, cell, listH )
long if Fn PtrAndHand(@cell,selCells,sizeof(point)) != _noErr
DisposeHandle( selCells) : selCells = _nil
exit while
end if
If fn LNextCell(_true, _true, cell, listH ) = _false then exit while
wend
end if
end fn = selCells

if you want to know the individual lines perhaps you could XRef@ the 
resulting handle.

dim as long cellCount, i
Xref@ theCells(_maxInt) as Point

theCells =  fn GetSelectedCells( id )
long if theCells
cellCount = fn GetHandleSize( theCells ) \\ sizeof(point)

long if cellCount
for i = 0 to cellCount - 1
print theCells.v%(i)+1
next
end if
DisposeHandle(theCells)
end if

I have just tested the above but I am getting an unexpected error that 
doesn't make sense. To get this to run I had to define a custom record:

begin record myPointRec
dim v as Int
dim h as Int
end record

Xref@ theCells( _maxInt ) as myPointRec

I have no idea at the moment why I have to do that.

Alain

PS: I have started a collection of undesired emails that I will sell 
on eBay once it is finished.

PPS: Staz is doing fine...

PPPS: I'm grouping the answers here to trick the spam bot.