1. RE: Win32Lib's setIndex against a tree view
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 03, 2002
- 462 views
Thanks Jonas. Jonas Temple wrote: > All, > > The setIndex in V 57.9 of Win32lib does not work for tree views. If > anyone is interested, here's the code to insert into setIndex to allow > the routine to work for tree views: > > --BEG CJT01 > elsif window_type[id] = TreeView then > cur_index = getTVIndex(id) > if cur_index then > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > getHandle({id,cur_index}), > 0, TVIS_SELECTED,"", 0, 0, 0, 0) > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM ) > release_mem(TVITEM) > end if > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > getHandle({id,index}), > TVIS_SELECTED, TVIS_SELECTED,"", 0, 0, 0, 0) > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM) > release_mem(TVITEM) > return > --END CJT01 > >
2. RE: Win32Lib's setIndex against a tree view
- Posted by Jonas Temple <jktemple at yhti.net> Oct 03, 2002
- 464 views
Don't thank me yet....the way I used is this is to force a selection of a tree view item when an item from a list view is selected. After you call setIndex and then use the mouse to select a tree view item the item used in setIndex remains highlighted. Dang-it! Derek Parnell wrote: > Thanks Jonas. > > Jonas Temple wrote: > > All, > > > > The setIndex in V 57.9 of Win32lib does not work for tree views. If > > anyone is interested, here's the code to insert into setIndex to allow > > the routine to work for tree views: > > > > --BEG CJT01 > > elsif window_type[id] = TreeView then > > cur_index = getTVIndex(id) > > if cur_index then > > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > > getHandle({id,cur_index}), > > 0, TVIS_SELECTED,"", 0, 0, 0, 0) > > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM ) > > release_mem(TVITEM) > > end if > > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > > getHandle({id,index}), > > TVIS_SELECTED, TVIS_SELECTED,"", 0, 0, 0, 0) > > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM) > > release_mem(TVITEM) > > return > > --END CJT01 > > > >
3. RE: Win32Lib's setIndex against a tree view
- Posted by Tony Steward <lockmaster67 at aol.com> Oct 04, 2002
- 463 views
Hi All, I use the following to setLVIndex, can't remember who gave me the code but it works well and means I don't have to alter win32lib. Use: setLVIndex(LVID, row) global function getLViItemFromlParam( integer id, integer lv_id ) atom findlv, item findlv = struct_LVFINDINFO( LVFI_PARAM, "", lv_id, 0, 0, 0 ) item = sendMessage( id, LVM_FINDITEM, -1, findlv ) release_mem( findlv ) return item end function -- Can set multiple selections, and first item will be made visible global procedure setLVIndex( integer id, object sel ) integer iItem atom lvitem, VOID if atom(sel) then sel = {sel} end if lvitem = struct_LVITEM( LVIF_STATE, 0, 0, LVIS_SELECTED, LVIS_SELECTED, 0,0,0) for i = length( sel ) to 1 by -1 do iItem = getLViItemFromlParam( id, sel[i] ) store( lvitem, LVITEM_iItem, iItem ) VOID = sendMessage( id, LVM_SETITEMSTATE, iItem, lvitem ) end for VOID = sendMessage( id, LVM_ENSUREVISIBLE, iItem, 0 ) end procedure Jonas Temple wrote: > Don't thank me yet....the way I used is this is to force a selection of > a tree view item when an item from a list view is selected. After you > call setIndex and then use the mouse to select a tree view item the item > > used in setIndex remains highlighted. Dang-it! > > Derek Parnell wrote: > > Thanks Jonas. > > > > Jonas Temple wrote: > > > All, > > > > > > The setIndex in V 57.9 of Win32lib does not work for tree views. If > > > anyone is interested, here's the code to insert into setIndex to allow > > > the routine to work for tree views: > > > > > > --BEG CJT01 > > > elsif window_type[id] = TreeView then > > > cur_index = getTVIndex(id) > > > if cur_index then > > > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > > > getHandle({id,cur_index}), > > > 0, TVIS_SELECTED,"", 0, 0, 0, 0) > > > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM ) > > > release_mem(TVITEM) > > > end if > > > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > > > getHandle({id,index}), > > > TVIS_SELECTED, TVIS_SELECTED,"", 0, 0, 0, 0) > > > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM) > > > release_mem(TVITEM) > > > return > > > --END CJT01 > > > > > > Give your hardest tasks to your lasiest workers. They will always find the easiest way to complete it.
4. RE: Win32Lib's setIndex against a tree view
- Posted by Tony Steward <lockmaster67 at aol.com> Oct 04, 2002
- 473 views
Hi Again, Below in previous post is how I setLVIndex which works well but, does anyone know how to clear previously selected items? Thanks Tony Tony Steward wrote: > Hi All, > I use the following to setLVIndex, can't remember who gave me the code > but it works well and means I don't have to alter win32lib. > > Use: setLVIndex(LVID, row) > > global function getLViItemFromlParam( integer id, integer lv_id ) > atom findlv, item > > findlv = struct_LVFINDINFO( LVFI_PARAM, "", lv_id, 0, 0, 0 ) > item = sendMessage( id, LVM_FINDITEM, -1, findlv ) > release_mem( findlv ) > > return item > end function > > -- Can set multiple selections, and first item will be made visible > global procedure setLVIndex( integer id, object sel ) > integer iItem > atom lvitem, VOID > if atom(sel) then > sel = {sel} > end if > lvitem = struct_LVITEM( LVIF_STATE, 0, 0, LVIS_SELECTED, > LVIS_SELECTED, > 0,0,0) > for i = length( sel ) to 1 by -1 do > iItem = getLViItemFromlParam( id, sel[i] ) > store( lvitem, LVITEM_iItem, iItem ) > VOID = sendMessage( id, LVM_SETITEMSTATE, iItem, lvitem ) > end for > VOID = sendMessage( id, LVM_ENSUREVISIBLE, iItem, 0 ) > end procedure > > > Jonas Temple wrote: > > Don't thank me yet....the way I used is this is to force a selection of > > a tree view item when an item from a list view is selected. After you > > call setIndex and then use the mouse to select a tree view item the item > > > > > > used in setIndex remains highlighted. Dang-it! > > > > Derek Parnell wrote: > > > Thanks Jonas. > > > > > > Jonas Temple wrote: > > > > All, > > > > > > > > The setIndex in V 57.9 of Win32lib does not work for tree views. If > > > > anyone is interested, here's the code to insert into setIndex to allow > > > > the routine to work for tree views: > > > > > > > > --BEG CJT01 > > > > elsif window_type[id] = TreeView then > > > > cur_index = getTVIndex(id) > > > > if cur_index then > > > > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > > > > getHandle({id,cur_index}), > > > > 0, TVIS_SELECTED,"", 0, 0, 0, 0) > > > > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM ) > > > > release_mem(TVITEM) > > > > end if > > > > TVITEM = struct_TVITEM(or_all({TVIF_HANDLE,TVIF_STATE}), > > > > getHandle({id,index}), > > > > TVIS_SELECTED, TVIS_SELECTED,"", 0, 0, 0, 0) > > > > VOID = sendMessage( id, TVM_SETITEM, 0, TVITEM) > > > > release_mem(TVITEM) > > > > return > > > > --END CJT01 > > > > > > > > > Give your hardest tasks to your lasiest workers. > They will always find the easiest way to complete it. > > Give your hardest tasks to your lasiest workers. They will always find the easiest way to complete it.
5. RE: Win32Lib's setIndex against a tree view
- Posted by Jonas Temple <jktemple at yhti.net> Oct 04, 2002
- 480 views
Tony, Actually, the code I presented does clear any previous selection. The problem here is that Windows doesn't automatically clear the selection for you when you select another item. I'm going to keep looking at this... Jonas Tony Steward wrote: > Hi Again, > Below in previous post is how I setLVIndex which works well but, does > anyone know how to clear previously selected items? > > Thanks > Tony >