1. RE: [WIN] What's my issue?

> -----Original Message-----
> From: leviathan at uswest.net [mailto:leviathan at uswest.net]
> 
> I have a search box, but after clearing the search listview 
> and trying 
> the search again, it crashes. I got down exactly the line it crashes 
> at, however, I have absolutely no clue why it crashes since I 
> unfortunatly don't have the full version interpreter quite yet (I'm 
> working on it), so can someone tell me whats wrong?

I've found a few bugs in deleteItem.  They'll be fixed in the next release.
Until then, the full function should read:

global function deleteItem( atom id, integer pos )

    -- deletes an item at position

    integer msg
    
    -- Begin Matt Lewis 
    atom LV_FINDINFO, lParam, iItem
    
    lParam = 0
    -- End Matt Lewis
    
    -- get the message, based on control type
    if      window_class[ id ] = LISTBOX then msg = LB_DELETESTRING
    elsif   window_class[ id ] = COMBO   
    -- Begin Matt Lewis
    or window_type[id] = ComboBoxEx      then msg = CB_DELETESTRING
    
    elsif window_type[ id ] = ListView then
        if pos = -1 then
            msg = LVM_DELETEALLITEMS
            
            iItem = 1
            
            while iItem <= length( lvitem_owner ) do
                if lvitem_owner[iItem] = id then
                    removeLVItem( iItem )
                    if iItem < length(lvitem_owner) then
                        iItem += 1
                    end if
                else 
                    iItem += 1
                end if
                
            end while
            
        else
            
            LV_FINDINFO = struct_LVFINDINFO( LVFI_PARAM, "", pos, 0, 0, 0)
            
            iItem = sendMessage( id, LVM_FINDITEM, -1, LV_FINDINFO ) + 1
            
            release_mem(LV_FINDINFO)
            
            if not iItem then
                return 0
            end if
            
            msg = sendMessage( id, LVM_DELETEITEM, iItem-1, lParam )
            if msg then
                removeLVItem( pos )
            end if
            
            return msg
            
        end if
        
    elsif window_type[ id ] = TreeView then
        msg = TVM_DELETEITEM
        if pos = -1 then
            lParam = TVI_ROOT
            
            -- changed to only delete items in the treeview specified
            iItem = 1
            
            while iItem <= length( tvitem_owner ) do
                if tvitem_owner[iItem] = id then
                    removeTVItem( iItem )
                    if iItem < length(tvitem_owner) then
                        iItem += 1
                    end if
                else 
                    iItem += 1
                end if
                
            end while
            
        else
            
            -- take care of any children
            iItem = find(pos, tvitem_parent)
            while iItem do
                if deleteItem( id, iItem ) then end if
                iItem = find(pos, tvitem_parent)
            end while
            
            lParam = tvitem_handle[pos]
            removeTVItem( pos )
        end if
        pos = 1
        
    -- End Matt Lewis
    
    end if
    return sendMessage( id, msg, pos-1, lParam )
end function

Matt Lewis

new topic     » topic index » view message » categorize

2. RE: [WIN] What's my issue?

> -----Original Message-----
> From: leviathan at uswest.net [mailto:leviathan at uswest.net]
> 
> I have a search box, but after clearing the search listview 
> and trying 
> the search again, it crashes. I got down exactly the line it crashes 
> at, however, I have absolutely no clue why it crashes since I 
> unfortunatly don't have the full version interpreter quite yet (I'm 
> working on it), so can someone tell me whats wrong?

I've found a few bugs in deleteItem.  They'll be fixed in the next release.
Until then, the full function should read:

global function deleteItem( atom id, integer pos )

    -- deletes an item at position

    integer msg
    
    -- Begin Matt Lewis 
    atom LV_FINDINFO, lParam, iItem
    
    lParam = 0
    -- End Matt Lewis
    
    -- get the message, based on control type
    if      window_class[ id ] = LISTBOX then msg = LB_DELETESTRING
    elsif   window_class[ id ] = COMBO   
    -- Begin Matt Lewis
    or window_type[id] = ComboBoxEx      then msg = CB_DELETESTRING
    
    elsif window_type[ id ] = ListView then
        if pos = -1 then
            msg = LVM_DELETEALLITEMS
            
            iItem = 1
            
            while iItem <= length( lvitem_owner ) do
                if lvitem_owner[iItem] = id then
                    removeLVItem( iItem )
                    if iItem < length(lvitem_owner) then
                        iItem += 1
                    end if
                else 
                    iItem += 1
                end if
                
            end while
            
        else
            
            LV_FINDINFO = struct_LVFINDINFO( LVFI_PARAM, "", pos, 0, 0, 0)
            
            iItem = sendMessage( id, LVM_FINDITEM, -1, LV_FINDINFO ) + 1
            
            release_mem(LV_FINDINFO)
            
            if not iItem then
                return 0
            end if
            
            msg = sendMessage( id, LVM_DELETEITEM, iItem-1, lParam )
            if msg then
                removeLVItem( pos )
            end if
            
            return msg
            
        end if
        
    elsif window_type[ id ] = TreeView then
        msg = TVM_DELETEITEM
        if pos = -1 then
            lParam = TVI_ROOT
            
            -- changed to only delete items in the treeview specified
            iItem = 1
            
            while iItem <= length( tvitem_owner ) do
                if tvitem_owner[iItem] = id then
                    removeTVItem( iItem )
                    if iItem < length(tvitem_owner) then
                        iItem += 1
                    end if
                else 
                    iItem += 1
                end if
                
            end while
            
        else
            
            -- take care of any children
            iItem = find(pos, tvitem_parent)
            while iItem do
                if deleteItem( id, iItem ) then end if
                iItem = find(pos, tvitem_parent)
            end while
            
            lParam = tvitem_handle[pos]
            removeTVItem( pos )
        end if
        pos = 1
        
    -- End Matt Lewis
    
    end if
    return sendMessage( id, msg, pos-1, lParam )
end function

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

3. RE: [WIN] What's my issue?

> -----Original Message-----
> From: Vincegg at AOL.COM [mailto:Vincegg at AOL.COM]
 
> Looking at the getLVItemText function I wonder why the id variable is 
> required since it's not used within the function.  Perhaps 
> that is what is 
> wrong?  How does the function know which ListView's data it's 
> supposed to 
> look at?  It got me wondering.

No, it's not really necessary.  I'm pretty sure I had it in there for
possible future compatibilty with getText.  ListView item id's are separate
from control id's.  Part of the data stored is what ListView the item
belongs to, but it's not necessary to fetch the text.  This is because
Win32Lib stores the text for each item for windows.  Whenever windows needs
the text, it asks Win32Lib.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu