1. ListView focusing to an Item
- Posted by Antonio Alessi <a.admin at myway.it> May 30, 2006
- 598 views
I have a problem with the List View focusing. Suppose a List of 300 items, with the 18th selected (highlighted). With:
setIndex( MyLV, 122) setFocus( MyLV)
the Item 122 is highlighted, but I cannot focus on it without clicking on again, i.e. the next arrow movement in LV starts from the previously highlighted Item (18), 1 if none and the Item 122 (or more than one) result unselected. How can I set the index and at the same time keep the cursor position to that point of the List? Thanks, Antonio
2. Re: ListView focusing to an Item
- Posted by Derek Parnell <ddparnell at bigpond.com> May 30, 2006
- 610 views
- Last edited May 31, 2006
Antonio Alessi wrote: > > > I have a problem with the List View focusing. > Suppose a List of 300 items, with the 18th selected (highlighted). > > With: > }}} <eucode> > setIndex( MyLV, 122) > setFocus( MyLV) > </eucode> {{{ > > the Item 122 is highlighted, > but I cannot focus on it without clicking on again, > i.e. the next arrow movement in LV starts from > the previously highlighted Item (18), 1 if none > and the Item 122 (or more than one) result unselected. > > How can I set the index and at the same time keep the cursor > position to that point of the List? > It could be that you are using an old version of Win32lib. In the setIndex() routine you should have lines such as ... VOID = w32Func( xSendMessage, {hWnd, LVM_SETHOTITEM, index-1, 0}) VOID = w32Func( xSendMessage, {hWnd, LVM_ENSUREVISIBLE, index-1, 0}) setLVItem(id, LVIF_STATE, index, 0, or_bits(LVIS_SELECTED,LVIS_FOCUSED), or_bits(LVIS_SELECTED,LVIS_FOCUSED), 0, 0, 0) where ... LVIS_FOCUSED = #0001, LVIS_SELECTED = #0002, LVM_SETHOTITEM = (LVM_FIRST + 60), LVM_ENSUREVISIBLE = (LVM_FIRST + 19), LVIF_STATE = 8, -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
3. Re: ListView focusing to an Item
- Posted by Antonio Alessi <a.admin at myway.it> May 31, 2006
- 648 views
Derek Parnell wrote: > > Antonio Alessi wrote: > > > > > > I have a problem with the List View focusing. > > Suppose a List of 300 items, with the 18th selected (highlighted). > > > > With: > > }}} <eucode> > > setIndex( MyLV, 122) > > setFocus( MyLV) > > </eucode> {{{ > > > > the Item 122 is highlighted, > > but I cannot focus on it without clicking on again, > > i.e. the next arrow movement in LV starts from > > the previously highlighted Item (18), 1 if none > > and the Item 122 (or more than one) result unselected. > > > > How can I set the index and at the same time keep the cursor > > position to that point of the List? > > > > It could be that you are using an old version of Win32lib. In the setIndex() > routine you should have lines such as ... > > VOID = w32Func( xSendMessage, {hWnd, LVM_SETHOTITEM, index-1, 0}) > VOID = w32Func( xSendMessage, {hWnd, LVM_ENSUREVISIBLE, index-1, 0}) > setLVItem(id, LVIF_STATE, index, 0, or_bits(LVIS_SELECTED,LVIS_FOCUSED), > or_bits(LVIS_SELECTED,LVIS_FOCUSED), 0, 0, 0) > > where ... > > LVIS_FOCUSED = #0001, > LVIS_SELECTED = #0002, > LVM_SETHOTITEM = (LVM_FIRST + 60), > LVM_ENSUREVISIBLE = (LVM_FIRST + 19), > LVIF_STATE = 8, > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell _____________________________ Yes, I *must* use the win32lib ver. 59-1 I have replaced (adapting there) both the setIndex( ..ListView section
elsif window_type[id] = ListView then hWnd = getHandle(id) if equal(index, w32SelectAll) then -- deselect all items VOID = w32Func( xSendMessage, {hWnd, LVM_SETHOTITEM, -1, 0}) wParam = w32Func(xSendMessage,{hWnd, LVM_GETITEMCOUNT, 0, 0}) - 1 LV_ITEM = acquire_mem(0, SIZEOF_LVITEM ) store( LV_ITEM, LVITEM_mask, LVIF_STATE ) store( LV_ITEM, LVITEM_stateMask, LVIS_SELECTED ) store( LV_ITEM, LVITEM_state, LVIS_SELECTED) for i = 0 to wParam do store( LV_ITEM, LVITEM_iItem, i) VOID = w32Func(xSendMessage,{hWnd, LVM_SETITEM, 0, LV_ITEM} ) end for release_mem(LV_ITEM) elsif index >= 1 then VOID = w32Func( xSendMessage, {hWnd, LVM_SETHOTITEM, index-1, 0}) VOID = w32Func( xSendMessage, {hWnd, LVM_ENSUREVISIBLE, index-1, 0}) setLVItem(id, LVIF_STATE, index, 0, or_bits(LVIS_SELECTED,LVIS_FOCUSED), or_bits(LVIS_SELECTED,LVIS_FOCUSED), 0, 0, 0) else -- deselect all items VOID = w32Func( xSendMessage, {hWnd, LVM_SETHOTITEM, -1, 0}) wParam = w32Func(xSendMessage,{hWnd, LVM_GETITEMCOUNT, 0, 0}) - 1 LV_ITEM = acquire_mem(0, SIZEOF_LVITEM ) store( LV_ITEM, LVITEM_mask, LVIF_STATE ) store( LV_ITEM, LVITEM_stateMask, LVIS_SELECTED ) for i = 0 to wParam do store( LV_ITEM, LVITEM_iItem, i) VOID = w32Func(xSendMessage,{hWnd, LVM_SETITEM, 0, LV_ITEM} ) end for release_mem(LV_ITEM) end if return
and the whole:
global procedure setFocus( object id ) -- set the focus atom parent, item , hWnd, subitem if sequence(id) then item = id[2] id = id[1] else item = -1 end if if not isEnabled( id ) or not isVisible( id ) then return -- Either can't see it, or shouldn't touch it. end if if window_type[id] = TabItem then parent = window_owner[id] item = find(id, window_tabitems[parent]) - 1 VOID = sendMessage( parent, TCM_SETCURSEL, item, 0) activateTabItems( id ) return end if -- focus_current = id hWnd = getHandle(id) w32Proc( xSetFocus, {hWnd} ) if item > 0 then if window_type[id] = TreeView then subitem = tvitem_handle[item] VOID = w32Func( xSendMessage, {hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, subitem}) VOID = w32Func( xSendMessage, {hWnd, TVM_SELECTITEM, TVGN_CARET, subitem}) elsif window_type[id] = ListView then subitem = item - 1 VOID = w32Func( xSendMessage, {hWnd, LVM_SETHOTITEM, subitem,0}) VOID = w32Func( xSendMessage, {hWnd, LVM_ENSUREVISIBLE, subitem,0}) setLVItem(id, LVIF_STATE, item, 0, or_bits(LVIS_SELECTED,LVIS_FOCUSED), or_bits(LVIS_SELECTED,LVIS_FOCUSED), 0, 0, 0) end if end if end procedure
but the problem remains. There is probably the fDoSetFocus( ) that looks to tell the last word, but I cannot handle it so far. It was a misfortune to start my work with this version. Thanks again, antonio