1. win32lib getTVSelectedText Not Working
- Posted by c.k.lester <euphoric at cklester.com> Apr 06, 2007
- 635 views
I'm using Win32Lib 0.60 Patch #67, 15-Jan-2007. The getTVSelectedText item doesn't work on sub-items. That is, I have this: Set One - value a - value b - value c and getTVSelectedText won't return values (returns empty sequence) if any of the 'value' items are clicked. It will return 'Set One' when 'Set One' is selected. Anybody have a fix?!
2. Re: win32lib getTVSelectedText Not Working
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Apr 07, 2007
- 609 views
c.k.lester wrote: > > I'm using Win32Lib 0.60 Patch #67, 15-Jan-2007. The getTVSelectedText item > doesn't work on sub-items. That is, I have this: > > Set One > - value a > - value b > - value c > > and getTVSelectedText won't return values (returns empty sequence) if any of > the 'value' items are clicked. It will return 'Set One' when 'Set One' is > selected. > > Anybody have a fix?! Please allow for a few days for me to have a working copy of win32lib 0.60.C that runs, and then I canprovide you with a fix. Probably this weekend, or tuesday. Does this happen with official 0.60.6? CChris
3. Re: win32lib getTVSelectedText Not Working
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Apr 09, 2007
- 606 views
c.k.lester wrote: > > I'm using Win32Lib 0.60 Patch #67, 15-Jan-2007. The getTVSelectedText item > doesn't work on sub-items. That is, I have this: > > Set One > - value a > - value b > - value c > > and getTVSelectedText won't return values (returns empty sequence) if any of > the 'value' items are clicked. It will return 'Set One' when 'Set One' is > selected. > > Anybody have a fix?! The problem is with getTVIndex(), which wrongly assumes that all items are at level 1. The routine should search among all children of the root, then all children of these and so on. I'll post corrected code later tonight (4pm local time right now) or tomorrow. The logic is not completely straightforward, needs some tests. CChris
4. Re: win32lib getTVSelectedText Not Working
- Posted by c.k.lester <euphoric at cklester.com> Apr 09, 2007
- 614 views
CChris wrote: > c.k.lester wrote: > > I'm using Win32Lib 0.60 Patch #67, 15-Jan-2007. The getTVSelectedText item > > doesn't work on sub-items. > > Anybody have a fix?! > > The problem is with getTVIndex(), which wrongly assumes that all items are at > level 1. Thanks, CC! :)
5. Re: win32lib getTVSelectedText Not Working
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Apr 09, 2007
- 614 views
c.k.lester wrote: > > CChris wrote: > > c.k.lester wrote: > > > I'm using Win32Lib 0.60 Patch #67, 15-Jan-2007. The getTVSelectedText item > > > doesn't work on sub-items. > > > Anybody have a fix?! > > > > The problem is with getTVIndex(), which wrongly assumes that all items are > > at > > level 1. > > Thanks, CC! :) Here's a fix; it involves both getTVIncedx() and getTVText().
global function getTVIndex( integer id ) atom state, item, hChild, TV_ITEM sequence path integer p item = sendMessage( id, TVM_GETNEXTITEM, 0, TVGN_ROOT ) TV_ITEM = struct_TVITEM( TVIF_STATE, item, 0, 0, "", 0, 0, 0, 0) path = {} while 1 do VOID = sendMessage( id, TVM_GETITEM, 0, TV_ITEM ) state = w32fetch( TV_ITEM, TVITEM_state) ?state if and_bits(state,TVIS_SELECTED) then -- assuming only one item is selected at a time exit end if hChild = sendMessage( id, TVM_GETNEXTITEM, TVGN_CHILD, item ) if hChild then path &= item item = hChild else item = sendMessage( id, TVM_GETNEXTITEM, TVGN_NEXT, item ) while not item do if not length(path) then exit end if item=path[length(path)] path=path[1..length(path)-1] item = sendMessage( id, TVM_GETNEXTITEM, TVGN_NEXT, item ) end while end if if not length(path) then exit end if w32store( TV_ITEM, TVITEM_hItem, item ) end while w32release_mem( TV_ITEM ) return item end function global function getTVText( atom iItem ) integer item item = find(iItem,tvitem_handle) if item > 0 then return w32peek_string( tvitem_data[item][ktv_TextAddr] ) else return "" end if end function
Probably some small things to optimise, but it works. Remember that "patch #67" is an unreleased alpha version... CChris
6. Re: win32lib getTVSelectedText Not Working
- Posted by c.k.lester <euphoric at cklester.com> Apr 09, 2007
- 617 views
CChris wrote: > c.k.lester wrote: > > CChris wrote: > > > c.k.lester wrote: > > > > I'm using Win32Lib 0.60 Patch #67, 15-Jan-2007. The getTVSelectedText > > > > item > > > > doesn't work on sub-items. > > > > Anybody have a fix?! > > > The problem is with getTVIndex(), which wrongly assumes that all items are > > > at > > > level 1. > Here's a fix; it involves both getTVIncedx() and getTVText(). Fix doesn't work for me. :/ If I have this: A - 1 - 2 - 3 B - 1 - 2 C - 1 D - 1 then no matter what subitem I click on, 'B' is returned from getTVSelectedText().
7. Re: win32lib getTVSelectedText Not Working
- Posted by c.k.lester <euphoric at cklester.com> Apr 09, 2007
- 664 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