Sign in to follow this  
Followers 0
gobsor

Highlight item that is moved down/up in ListView?

4 posts in this topic

Heyah... once more a problem with ListView!

That's how I'm filling the ListView after browsing a dir, notice that I'm using _GUICtrlListView_SetItemSelected($hSourceView, 0, True, True).

Works perfect, ListView is being filled and 1st item is Focused/Highlighted (in common blue 'this row is highlighted' color).

Func _fillSourceView($path)
    _clearListView($hSourceView)
    $files = _FileListToArray($path, "*.mp3")
    For $i = 1 To UBound($files)-1
        $size = FileGetSize($path&$files[$i])
        _GUICtrlListView_BeginUpdate($hSourceView)
        GUICtrlCreateListViewItem(_properNum($i) & "|" & $files[$i] & "|" & _properSize($size), $hSourceView)
        If Mod($i, 2) = 0 Then 
            GUICtrlSetBkColor(-1, 0xE9F2F5) 
        EndIf
    Next
    _GUICtrlListView_SetItemSelected($hSourceView, 0, True, True)
    $iIndex = 0
    _GUICtrlListView_EndUpdate($hSourceView)
    _GUICtrlButton_Enable($idReload, True)
EndFunc ;==> _fillSourceView($path)

Okay, now I got two buttons to move subitems down/up in ListView, that's how I'm doing it:

Func _clickMoveUp()
    _GUICtrlListView_BeginUpdate($hSourceView)
    _switchItemText($hSourceView, $iIndex, $iIndex-1, 1)
    _switchItemText($hSourceView, $iIndex, $iIndex-1, 2)
    _GUICtrlListView_SetItemSelected($hSourceView, $iIndex-1, True, True)
    _GUICtrlListView_EndUpdate($hSourceView)
    $iIndex = $iIndex - 1
EndFunc ;==> _clickMoveUp()

Func _clickMoveDn()
    _GUICtrlListView_BeginUpdate($hSourceView)
    _switchItemText($hSourceView, $iIndex, $iIndex+1, 1)
    _switchItemText($hSourceView, $iIndex, $iIndex+1, 2)
    _GUICtrlListView_SetItemSelected($hSourceView, $iIndex+1, True, True)
    _GUICtrlListView_EndUpdate($hSourceView)
    $iIndex = $iIndex + 1
EndFunc ;==> _clickMoveDn()

Func _switchItemText($hWnd, $iIndex_1, $iIndex_2, $iSubItem)
    Local $temp = _GUICtrlListView_GetItemText($hWnd, $iIndex_1, $iSubItem)
    _GUICtrlListView_BeginUpdate($hWnd)
    _GUICtrlListView_SetItemText($hWnd, $iIndex_1, _GUICtrlListView_GetItemText($hWnd, $iIndex_2, $iSubItem), $iSubItem)
    _GUICtrlListView_SetItemText($hWnd, $iIndex_2, $temp, $iSubItem)
    _GUICtrlListView_EndUpdate($hWnd)
EndFunc

Works fine so far aswell, subitem is being moved up/down, depending on the button pressed, but why doesn't the moved item get highlighted

after it got moved?

Shouldn't

_GUICtrlListView_SetItemSelected($hSourceView, $iIndex+1, True, True)
_GUICtrlListView_SetItemSelected($hSourceView, $iIndex-1, True, True)

move the 'highlight' down/up in ListView, depending on the button pressed? SubItem's are exchanged and I can move the selected one to either

the button or the top of the list, but somehow it's not highlighted and hard to see which one is moved right now.

Thanks in advance!

Share this post


Link to post
Share on other sites



Bumping this one since I couldn't solve it yet.

Addition:

I was told UDF do not always stack with native AU3 functions. Might that cause the problem, or is it me using the function improperly?

Regards

Share this post


Link to post
Share on other sites

gobsor,

I posted a similar question without realizing it. I figured out the answer to my question and maybe it will help you.

See Here.

Hope this helps.

cj

Share this post


Link to post
Share on other sites

Thanks, works for me now too. Not really sure why $iVar is not working (I had the same issue, using a variable not Number()'ing it).

Regards

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0