[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: Fri, 11 Jan 2008 06:55:27 +0000
On 11 Jan 2008, at 04:45, Joe Lertola wrote:

> One thing I do not know how to do is to replace the content of the  
> browser with new items. I tried just calling the browser  
> initialization function again with new content. This seems to work  
> except if the new content is shorter than the previous content old  
> items are retained at the bottom of the list. You can see this  
> happen in the demo when you click the Reset Data Browser button.  
> With DataBrowser for Dummies there is a function called fn  
> DeleteAllItemsInBrowser which I use to erase the old items before I  
> add new content. So far I have not been able to figure out how to  
> accomplish this with DBData.incl. Any help would be appreciated.

Until I get my brain into browser gear, here's a workaround. Add the  
following function to DBData.incl (below the Populate Browser bookmark  
may be a good place):

local mode
local fn DBDataClearBrowser( browser as HIViewRef )
dim as Handle h
dim as OSStatus ignore

h = fn NewHandle( 0 )
long if ( h )
long if ( fn GetDataBrowserItems( browser, _kDataBrowserNoItem,  
_true , _kDataBrowserItemAnyState, h ) == _noErr )
ignore = fn RemoveDataBrowserItems( browser, 0, fn GetHandleSize( h )\ 
\sizeof(DataBrowserItemID), #[h], _nil )
fn DBDataClearArray( browser )
end if
DisposeHandle( h )
end if
end fn

and call it at the top of your InitBrowserData_cBrowser function.