[futurebasic] Re: [FB] Trouble using DataBrowser For Dummies with FBtoC

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2008 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Sat, 12 Jan 2008 10:47:20 +0000
> Is it safe to close a window that contains a DataBrowser or is there  
> some kind of clean up that must be done to prevent a memory leak?

DBData auto releases all data on browser dispose.


btw, I suspect this function may be a bit more efficient getting the  
selected row number (itemID):
'------------
local mode
local fn DBDataGetItemIDBySelectionIndex( browser as HIViewRef, index  
as CFIndex )
'~'1
dim as Handle h
dim as CFIndex count, itemID : itemID = 0
xref @ items(_maxLong) as DataBrowserItemID

h = fn NewHandle( 0 )
long if ( h )
long if ( fn GetDataBrowserItems( browser, _kDataBrowserNoItem, _true,  
_kDataBrowserItemIsSelected, h ) == _noErr )
items = h
count = fn GetHandleSize( h )\sizeof(DataBrowserItemID)
long if ( count )
if ( index == 0 ) then index = count
long if ( index <= count )
itemID = items( count - index )
end if
end if
end if
DisposeHandle( h )
end if
end fn = itemID
'------------

Examples:
itemID = fn DBDataGetItemIDBySelectionIndex( browser, 1 )// 1st itemID  
in selection
itemID = fn DBDataGetItemIDBySelectionIndex( browser, 0 )// last  
itemID in selection
itemID = fn DBDataGetItemIDBySelectionIndex( browser, n )// nth itemID  
in selection


Bernie