Re: win32lib getTVSelectedText Not Working
- Posted by c.k.lester <euphoric at cklester.com> Apr 09, 2007
- 663 views
CChris wrote: > Here's a fix; it involves both getTVIncedx() and getTVText(). I grabbed this code from a version of Win32Lib that does work:
global function getTVIndex( atom id ) atom count, state, item, lParam, TV_ITEM TV_ITEM = struct_TVITEM( 0, 0, 0, TVIS_SELECTED, "", 0, 0, 0, 0) count = sendMessage( id, TVM_GETCOUNT, 0, 0 ) lParam = 0 item = sendMessage( id, TVM_GETNEXTITEM, 0, TVGN_ROOT ) w32store( TV_ITEM, TVITEM_hItem, item ) VOID = sendMessage( id, TVM_GETITEM, 0, TV_ITEM ) for i = 1 to count do state = w32fetch( TV_ITEM, TVITEM_state ) if and_bits(state, TVIS_SELECTED) then lParam = w32fetch( TV_ITEM, TVITEM_lParam) exit end if item = sendMessage( id, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, item ) w32store( TV_ITEM, TVITEM_hItem, item ) VOID = sendMessage( id, TVM_GETITEM, 0, TV_ITEM ) end for w32release_mem( TV_ITEM ) return lParam end function global function getTVText( integer iItem ) if iItem > 0 and iItem <= length(tvitem_data) then return w32peek_string( tvitem_data[iItem][ktv_TextAddr] ) else return "" end if end function